是否可以将TikZ图提取为图像文件? [英] Is it possible to extract TikZ diagrams as image files?
问题描述
我正在使用TikZ在LaTeX中绘制图表,然后将其隔离为图像文件以使其联机.我正在使用TeXnicCenter编辑源.
I’m using TikZ to draw diagrams in LaTeX that I then want to isolate as image files to put online. I’m using TeXnicCenter to edit the sources.
是否有一种方法可以直接提取这些图而不必从完成的PDF文件中提取它们?
Is there is a way to extract these diagrams directly without having to extract them from the finished PDF file?
推荐答案
关注我的评论: Cirkuit 通过运行以下命令序列将TikZ图转换为图像:
Following up on my comment: Cirkuit converts TikZ diagrams into images by running something like the following sequence of commands:
pdflatex img.tex
pdftops -eps img.pdf
convert -density 300 img.eps img.png
此处 img.tex
将是遵循此模板的LaTeX文件:
Here img.tex
would be a LaTeX file that follows this template:
\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图像.
If you are able to use Cirkuit or a similar editor, or write a script for yourself to put your diagram into that template and run the appropriate tools, you'll have a quick way to convert TikZ code into a PNG image.
要直接直接回答您的问题...不,我不知道有什么方法可以直接将TikZ图 转换为PNG,而无需通过PDF文件(或至少是DVI)某个阶段.
To answer your question more directly... no, I don't know of any way to convert a TikZ diagram directly to PNG without going through a PDF file (or at least DVI) at some stage.
这篇关于是否可以将TikZ图提取为图像文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!