我想将四个tikzpicture
s 放在同一条水平线上,但我无法将它们设置tikzpicture
在同一条水平线上(请参阅下面的 LaTeX 代码)。使用下面报告的代码,每个 stikzpicture
都放置在前一个 s 的下方tikzpicture
(这不是我要搜索的)。
有办法解决这个问题吗?
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{adjustbox}
\begin{document}
% 1
\begin{adjustbox}{valign=t,minipage={.10\textwidth}}
\begin{center}
\begin{tikzpicture}[-,thick,
auto]
\node (z){0}
child {
node {a} };
\end{tikzpicture}
\end{center}
\end{adjustbox}
\hfill
% 2
\begin{adjustbox}{valign=t,minipage={.45\textwidth}}
\begin{center}
\begin{tikzpicture}[-,thick,
auto]
\node (z){0}
child {
node {b} };
\end{tikzpicture}
\end{center}
\end{adjustbox}
\begin{adjustbox}{valign=t,minipage={.65\textwidth}}
\begin{center}
\begin{tikzpicture}[-,thick,
auto]
\node (z){0}
child {
node {b} };
\end{tikzpicture}
\end{center}
\end{adjustbox}
\begin{adjustbox}{valign=t,minipage={.85\textwidth}}
\begin{center}
\begin{tikzpicture}[-,thick,
auto]
\node (z){0}
child {
node {b} };
\end{tikzpicture}
\end{center}
\end{adjustbox}
\end{document}
答案1
四个minipage
s 的总宽度大于\textwidth
;此外,您的代码中有一些空行(我不知道它们是在实际代码中还是只是问题中复制粘贴的结果),这些空行不应该存在(空行结束段落,后面的内容将开始新的段落)。minipage
例如,将 s 的宽度调整为 ,0.25\textwidth
并注意空格(我还将环境更改center
为\centering
):
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usepackage{adjustbox}
\begin{document}
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
child { node {a} };
\end{tikzpicture}
\end{adjustbox}%
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
child { node {b} };
\end{tikzpicture}
\end{adjustbox}%
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
child { node {b} };
\end{tikzpicture}
\end{adjustbox}%
\begin{adjustbox}{valign=t,minipage={.25\textwidth}}
\centering
\begin{tikzpicture}[-,thick,auto]
\node (z){0}
child { node {b} };
\end{tikzpicture}
\end{adjustbox}
\end{document}
结果: