原始信息
我想强制两个或多个元素tikzpictures
在类中彼此低于彼此standalone
。我不确定该怎么做。以下是最小工作示例:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
% line break here!
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\end{document}
更新
答案1
就像这样,一页纸上有一个图表,另一页纸上有一个图表?(只需添加varwidth
类别选项,如 Torbjørn 所建议的那样。)
\documentclass[varwidth]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
%\vbox{% <-- redundant, thanks to `varwidth' class option
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
%}
\end{document}
或者,在单独的页面上?
\documentclass[tikz]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\end{document}
答案2
您可以简单地使用tabular
:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\begin{document}
\begin{tabular}{@{}c@{}}
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\\
\begin{tikzpicture}
\begin{axis}[
axis y line=left,
axis x line=middle,
width=12cm,
height=3cm,
]
\end{axis}
\end{tikzpicture}
\end{tabular}
\end{document}