質問
Tikzを使用してLaTexで図を描画し、オンラインにする画像ファイルとして分離したいと考えています。私の推測では、完成した.pdfファイルからそれらをいじめることなく、これらの図を直接抽出する方法があります。どうやってそれをしますか? (それが重要な場合、私はTexnicCenterを使用しています。)
解決
私のコメントのフォローアップ: Cirkuit 次のコマンドのシーケンスのようなものを実行することにより、Tikzダイアグラムを画像に変換します。
pdflatex img.tex
pdftops -eps img.pdf
convert -density 300 img.eps img.png
ここ img.tex
このテンプレートに従うラテックスファイルになります。
\documentclass{article}
\usepackage{tikz,amsmath,siunitx}
\usetikzlibrary{arrows,snakes,backgrounds,patterns,matrix,shapes,fit,calc,shadows,plotmarks}
\usepackage[graphics,tightpage,active]{preview}
\PreviewEnvironment{tikzpicture}
\PreviewEnvironment{equation}
\PreviewEnvironment{equation*}
\newlength{\imagewidth}
\newlength{\imagescale}
\pagestyle{empty}
\thispagestyle{empty}
\begin{document}
\begin{tikzpicture}
% (your TikZ code goes here)
\end{tikzpicture}
\end{document}
Cirkuitまたは同様のエディターを使用したり、スクリプトを作成して図式をそのテンプレートに入れて適切なツールを実行できる場合は、TikzコードをPNG画像に迅速に変換する方法があります。
あなたの質問にもっと直接答えるために...いいえ、私はティク図を変換する方法がわかりません 直接 ある段階でPDFファイル(または少なくともDVI)を通過せずにPNGに。
他のヒント
次のアプローチをお勧めします。 Tikzの写真を別のファイルに置き、「スタンドアロン」クラスを使用してスタンドアロンをコンパイルします。他の回答に記載されている「プレビュー」パッケージを使用します。メインドキュメントに写真を含めるには、「スタンドアロン」をロードします パッケージ そこに最初に、画像ファイルに入力を使用します。
これにより、マージンなしでTikz画像の1つのPDFを取得できます。次に、PDF-to-Say PNGコンバーターを使用して、PNG(図面のWeb公開に推奨)を取得できます。 SVG形式はベクトル形式であるため、より優れていますが、すべてのブラウザが表示できるわけではありません。
ここでいくつかの例コード:
Tikz Pictureファイル( 'pic.tex'など):
\documentclass{standalone}
\usepackage{tikz}
% all other packages and stuff you need for the picture
%
\begin{document}
\begin{tikzpicture}
% your picture code
\end{tikzpicture}
\end{document}
主なドキュメント:
\documentclass{article} % or whatever class you are using
\usepackage{standalone}
\usepackage{tikz}
% All other packages required
\begin{document}
% Text text text
% somewhere where you want the tikz picture
\input{pic}
% Text text text
\end{document}
次に、画像をコンパイルして、たとえばImageMagick(例えばLinuxの下)で変換します。
pdflatex pic
convert -density 600x600 pic.pdf -quality 90 -resize 800x600 pic.png
またはSVGを試してください:
convert pic.pdf pic.svg
Tikzマニュアルセクション「外部化グラフィックス」を参照してください。これにより、グラフィックスのEPSまたはPDFバージョンを作成できます。 EPSファイルを使用し、それらをTIFFSに変換し、必要な場所に配置できます。
私は通常、これらの線に沿って何かを使用しています:
\documentclass{article}
\usepackage[pdftex,active,tightpage]{preview}
%\setlength\PreviewBorder{2mm} % use to add a border around the image
\usepackage{tikz}
\begin{document}
\begin{preview}
\begin{tikzpicture}
\shade (0,0) circle(2); % background
\draw (0,0) circle(2); % rim
\draw (.75,1) circle(.5); % right eye
\fill (.66,.9) circle(.25); % right pupil
\draw (-.75,1) circle(.5); % left eye
\fill (-.66,.9) circle(.25);% left pupil
\fill (.2,0) circle (.1); % right nostril
\fill (-.2,0) circle (.1); % left nostril
\draw (-135:1) arc (-135:-45:1) -- cycle; % mouth
\end{tikzpicture}
\end{preview}
\end{document}
生成されたPDFファイルには、スタンドアロンのTikz画像が含まれています。他のファイル形式に変換するには、GIMPで開くだけです。
これを使用して、それぞれ1つのTikzPictureを含む.texファイルからPNGファイルとサムネイルを作成するFileルールを作成します。画像の作成と同様に機能します texample.net:
%.png: %.tex @sed 's/^\\begin{document}/\ \\pgfrealjobname{dummy}\\begin{document}\\beginpgfgraphicnamed{example}/' $< | \ sed 's/^\\end{document}/\\endpgfgraphicnamed\\end{document}/' > example.tex ; \ pdflatex --jobname=example example.tex ; \ gs -dNOPAUSE -r120 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -sDEVICE=png16m \ -sOutputFile=$@ -dBATCH example.pdf ; \ convert -thumbnail 200 $@ $(addsuffix .thumb.png, $(basename $@)) ; \ mv example.pdf $(addsuffix .pdf, $(basename $<)) ; rm example.*
GhostView(gs
)おそらく置き換えることができます convert
そして、あなたは交換することができます example
別のTempfileプレフィックス付き。
Windows:私のような初心者のために完全に明示的であること
ハビが上記のラテックスコードで提案したように、Prewiewパッケージを使用して、マージンを削除します。
MiktexとInkscapeをインストールし、次のバットファイルを使用します。
cd = "C:\Path to tex"
pdflatex input-file-name.tex
"C:\Program Files (x86)\Inkscape\inkscape.exe" input-file-name.pdf --export-plain-svg=output-file-name.svg