我想要三个小页面顶部对齐。我尝试了以下代码:
\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{minipage}[t][][s]{.45\linewidth}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}
\begin{minipage}[t][][s]{.1\linewidth}
\begin{tikzpicture}
\draw[dash pattern=on 3pt off 6pt] (0,0.0) -- (0,10);
\end{tikzpicture}
\end{minipage}
\begin{minipage}[t][][s]{.45\linewidth}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}
\caption{Numerous images.}
\end{figure}
\end{document}
以下是输出:
第二个小页面不遵循顶部对齐。我想在两列 TikZ 图像之间的空间中心插入虚线。如何解决这个问题,或者有没有更好的方法来实现所需的输出?
答案1
这展示了如何使用 tikz 的 [baseline] 选项来对齐图像的实际顶部。
请注意,如果缺少第二个可选参数,则第三个参数无关紧要。毕竟,它们是可选的。
\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{figure}
\begin{minipage}[t]{.45\linewidth}
\begin{tikzpicture}[baseline=(current bounding box.north),
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}% what you put here matters
\begin{minipage}[t]{.1\linewidth}
\begin{tikzpicture}[baseline=(current bounding box.north)]
\draw[dash pattern=on 3pt off 6pt] (0,0.0) -- (0,10);
\end{tikzpicture}
\end{minipage}% what you put here matters
\begin{minipage}[t]{.45\linewidth}
\begin{tikzpicture}[baseline=(current bounding box.north),
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}
\caption{Numerous images.}
\end{figure}
\end{document}
答案2
具有三个垂直居中的小页面或单一tikzpicture
环境:
\documentclass[10pt]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{positioning, calc}
\begin{document}
\begin{figure}
\begin{minipage}[c]{.45\linewidth}
\centering
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}%
\begin{minipage}[c]{.1\linewidth}
\centering
\begin{tikzpicture}
\draw[dash pattern=on 3pt off 6pt] (0,0.0) -- (0,8);
\end{tikzpicture}
\end{minipage}%
\begin{minipage}[c]{.45\linewidth}
\centering
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\vspace*{1cm}
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A) {A};
\node[pool] (B) [right=of A] {B};
\draw [<->] (A) -- (B);
\end{tikzpicture}
\end{minipage}
\caption{Numerous images.}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[
pool/.style={
circle, draw=blue!50, fill=blue!20, thick,
inner sep=0pt, minimum size=10mm
}
]
\node[pool] (A1) {A};
\node[pool] (B1) [right=of A1] {B};
\draw [<->] (A1) -- (B1);
\node[pool] (A2) [below=of A1] {A};
\node[pool] (B2) [right=of A2] {B};
\draw [<->] (A2) -- (B2);
\node[pool] (A3) [below=of A2] {A};
\node[pool] (B3) [right=of A3] {B};
\draw [<->] (A3) -- (B3);
\node[pool] (A4) [below=of A3] {A};
\node[pool] (B4) [right=of A4] {B};
\draw [<->] (A4) -- (B4);
\node[pool] (A5) [right=3cm of B1] {A};
\node[pool] (B5) [right=of A5] {B};
\draw [<->] (A5) -- (B5);
\node[pool] (A6) [below=of A5] {A};
\node[pool] (B6) [right=of A6] {B};
\draw [<->] (A6) -- (B6);
\node[pool] (A7) [below=of A6] {A};
\node[pool] (B7) [right=of A7] {B};
\draw [<->] (A7) -- (B7);
\node[pool] (A8) [below=of A7] {A};
\node[pool] (B8) [right=of A8] {B};
\draw [<->] (A8) -- (B8);
\node (C1) at ($(B1.north)!0.5!(A5.north)$) {};
\node (C2) at ($(B4.south)!0.5!(A8.south)$) {};
\draw[dash pattern=on 3pt off 6pt] (C1) -- (C2);
\end{tikzpicture}
\caption{Numerous images.}
\end{figure}
\end{document}