如果我这样做:
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\newline
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\end{document}
我得到的是这个,而不是 2x2 的图表网格:
我该如何修改它才能得到 2x2 的网格图表?
答案1
您可以只使用一个,并使用环境和一些stikzpicture
移动每个部分。scope
shift
\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\begin{scope}[xshift=1.3cm]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{scope}
\begin{scope}[yshift=-1.3cm]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{scope}
\begin{scope}[shift={(1.3cm,-1.3cm)}]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{scope}
\end{tikzpicture}
\end{document}
答案2
您可以尝试以下方法。请注意,这依赖于实验包,因此不能保证其面向未来。为了避免使用实验包,您可以使用 LaTeX 3 内核开发提供的底层内容,因为等效的编程函数未标记为实验性的 - 只有我在这里使用的用户级界面。
买者自负 ...
\documentclass{standalone}
\usepackage{tikz,xcoffins}
\begin{document}
\NewCoffin\myCoffin
\SetHorizontalCoffin\myCoffin{%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
}%
\NewCoffin\mySpareCoffin
\SetHorizontalCoffin\mySpareCoffin{%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
}%
\JoinCoffins\myCoffin [b,l] \mySpareCoffin [t,l]
\TypesetCoffin\myCoffin
\end{document}
显然,使用较低级别的 TeX 也必须能够实现这一点,但是棺材要容易得多!
答案3
手册第 10 页,使用该varwidth
选项。
\documentclass[varwidth]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}%
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\begin{tikzpicture}[scale=3,>=latex, font=\sffamily]
\draw [->](0,0) -- (0,1) node[at end, above left, rotate=90] {engine output};
\draw [->](0,0) -- (1,0) node[at end, below left] {pedal input};
\draw [-](0,0) -- (0.8,0.8);
\draw [dashed, ->](0.8,0.8) -- (1,1);
\end{tikzpicture}
\end{document}
我没有修复%
第二行缺失的部分,因为%
第一行可能不需要它。你自己选择吧。