如何从 LaTeX 文件生成 SVG 图像 - 更准确地说,是 tikz 图?我在 Windows 中工作。
小智 9
做最简单的方法,因此我们将首先生成一个PDF或DVI 与刚才所说图/方程,然后转换到一个矢量格式。
如果小页面大小的 PDF 适合您,那么您可以使用 * 使用ghostscript:
gswin32c.exe -sDEVICE=pdfwrite -dMaxSubsetPct=100 -dPDFSETTINGS=/ebook -sOutputFile="outfile.pdf" -dNOPAUSE -dBATCH "infile.pdf"
where -dPDFSETTINGS is used to define how images are resampled. Using -dPDFSETTINGS=/screen will yield dpi=72. I just tried this with a sample pdf and it seems to work fine.
Run Code Online (Sandbox Code Playgroud)
否则,请使用以下描述的任何方法:https : //stackoverflow.com/questions/10288065/convert-pdf-to-clean-svg
此外,此答案适用于多个页面:https : //stackoverflow.com/a/4502030
这个资源也很有用:svgkit.sourceforge.net/SVGLaTeX.html
当然,提到的一些命令可以很好地使用 MinGW 实现,或者具有本机 Windows 实现,您必须下载它们。当然,然后将可执行文件的目录添加到 PATH 变量环境(在计算机属性的高级设置中可用)。 对于inkscape,请参阅此链接:http : //kaioa.com/node/42#inkcl_bat_usage 在这里,您只需在inkscape 目录中放置一个批处理文件(InkCL.bat)。并使用它而不是在命令行中输入inkscape。墨水
总而言之,它通常只需要 3 个命令
说,input.tex:
\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsfonts}
\thispagestyle{empty}
\begin{document}
\[
2 \pi f t
\]
\end{document}
Run Code Online (Sandbox Code Playgroud)现在,使用以下任何一种方法:
pdflatex input.tex
Run Code Online (Sandbox Code Playgroud)
这将创建文件 input.pdf 现在,使用以下任何一种方法:
来自 Inkscape:
inkscape -l output.svg input.pdf
Run Code Online (Sandbox Code Playgroud)(同上):
inkscape \
--without-gui \
--file=input.pdf \
--export-plain-svg=output.svg
Run Code Online (Sandbox Code Playgroud)对于多个页面(以及单个页面),请使用pdf2svg [cityinthesky.co.uk/opensource/pdf2svg/]。它使用 poppler 和 Cairo 将 pdf 转换为 SVG。这对于批量转换特别有用:
pdf2svg <input.pdf> <output.svg> [<pdf page no. or "all" >]
Run Code Online (Sandbox Code Playgroud)
注意:如果您指定所有页面,您必须给出一个包含 %d 的文件名(它将自动被适当的页码替换)。例如
pdf2svg input.pdf output_page%d.svg all
Run Code Online (Sandbox Code Playgroud)latex input.tex
Run Code Online (Sandbox Code Playgroud)
这将创建文件 output.dvi
然后,
dvisvgm --no-fonts input.dvi output.svg
Run Code Online (Sandbox Code Playgroud)
这对于使用 LaTeX 公式的实例非常有效(使用选项 --no-fonts)
还有 soandos 的回答(包括全面性):
dvips -q -f -e 0 -E -D 10000 -x 10000 -o eqn.ps eqn.dvi
Run Code Online (Sandbox Code Playgroud)
从 dvips 手册页 (ma.utexas.edu/cgi-bin/man-cgi?dvips%201):
然后,
pstoedit -f plot-svg -dt -ssp eqn.ps eqn.svg
Run Code Online (Sandbox Code Playgroud)
这将创建文件 eqn.svg
为了获得高质量的文本到多边形转换,我们必须以高放大率运行 dvips,因此必须缩小生成的 SVG。
| 归档时间: |
|
| 查看次数: |
18419 次 |
| 最近记录: |