是否可以将 TikZ 图提取为图像文件? [英] Is it possible to extract TikZ diagrams as image files?

查看:12
本文介绍了是否可以将 TikZ 图提取为图像文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 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*}

ewlength{imagewidth}

ewlength{imagescale}
pagestyle{empty}
	hispagestyle{empty}
egin{document}
egin{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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆