最小 TikZ standalone 示例
此示例包含使用 standalone 包的简单 TikZ 图形,即它将导出为页面恰好适应内容的 PDF/DVI:
MyDiagram.tex
\documentclass[tikz, border=1mm]{standalone}
\begin{document}
\begin{tikzpicture}
\draw (0,0) node [draw=black] {My text};
\end{tikzpicture}
\end{document}结果看起来像这样:
假设文件名为 MyDiagram.tex,你可以使用以下命令将其编译为 PDF
build_my_diagram.sh
pdflatex MyDiagram.tex注意我们的示例默认包含 1mm 边框,因为这似乎比完全没有边框更适合平均用例。要更改此设置,你只需修改第一行,例如
no_border_diagram.tex
\documentclass[tikz]{standalone} % 无边框or
five_mm_border_diagram.tex
\documentclass[tikz]{standalone, border=5mm} % 5mm 边框Check out similar posts by category:
LaTeX
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow