理想情况下,我希望tikzpicture
s 位于一行中,水平居中,其标题保留其节点大小和线强度,并垂直对齐到公共底线。然而,我陷入困境 - 因此非常感谢所有帮助,因为我根本没有时间阅读手册subcaption
(如果有更好的替代方案,也非常感谢提示),而且pgf
现在肯定没有手册文档 - 虽然pgf
手册肯定在我的待办事项清单上。
\documentclass[a4paper, twoside]{book}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,shapes,positioning,petri,topaths}
\begin{document}
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.16\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,3) [circle, draw] {};
\end{tikzpicture}
\caption{$K_1$}
\label{fig:20140812k1}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (2,3) [circle, draw] {};
\draw (v1) -- (v2);
\end{tikzpicture}
\caption{$K_2$}
\label{fig:20140806k2}
\end{subfigure}
\begin{subfigure}[b]{0.16\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (1,1) [circle, draw] {};
\node (v2) at (3,1) [circle, draw] {};
\node (v3) at (2,3) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v2) -- (v3);
\draw (v1) -- (v3);
\end{tikzpicture}
\caption{$K_3$}
\label{fig:20140812k3}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.16\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (1,1) [circle, draw] {};
\node (v2) at (5,1) [circle, draw] {};
\node (v3) at (3,2) [circle, draw] {};
\node (v4) at (3,4) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v3) -- (v4);
\end{tikzpicture}
\caption{$K_4$}
\label{fig:20140812k4}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.16\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (4,1) [circle, draw] {};
\node (v3) at (1,3) [circle, draw] {};
\node (v4) at (5,3) [circle, draw] {};
\node (v5) at (3,4) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v1) -- (v5);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v2) -- (v5);
\draw (v3) -- (v4);
\draw (v3) -- (v5);
\draw (v4) -- (v5);
\end{tikzpicture}
\caption{$K_5$}
\label{fig:20140812k5}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.16\textwidth}
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (4,1) [circle, draw] {};
\node (v3) at (1,3) [circle, draw] {};
\node (v4) at (5,3) [circle, draw] {};
\node (v5) at (2,5) [circle, draw] {};
\node (v6) at (4,5) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v1) -- (v5);
\draw (v1) -- (v6);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v2) -- (v5);
\draw (v2) -- (v6);
\draw (v3) -- (v4);
\draw (v3) -- (v5);
\draw (v3) -- (v6);
\draw (v4) -- (v5);
\draw (v4) -- (v6);
\draw (v5) -- (v6);
\end{tikzpicture}
\caption{$K_6$}
\label{fig:20140812k6}
\end{subfigure}%
\caption{Vollständige Graphen $K_1$ bi $K_6$}\label{fig:completeGraphs}
\end{figure}
\end{document}
答案1
首先,您必须将每个 tikzpicture 置于每个子图的中心。您可以使用\centering
左侧的 来实现这一点\begin{tikzpicture}
。
此外,赋予每个子图相同的宽度(0.16\textwidth
)也是一个好办法。
要使每个子图都在同一行,您可能应该调整文档边距,因为如果有六个图,您很可能超出\textwidth
。我认为这是不可能的,因为为了让它们在同一行,我将左右边距设置为 10[mm]。也许更好的选择是每行有三个,只需在第三和第四个 之间subfigure
添加一个 即可实现。\\
subfigure
这是通过以下 LaTeX 代码实现的:
\documentclass[a4paper, twoside]{book}
\usepackage{subcaption}
\usepackage[left=10mm,right=10mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{shapes,backgrounds,shapes,positioning,petri,topaths}
\begin{document}
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.16\textwidth}
\centering
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,3) [circle, draw] {};
\end{tikzpicture}
\caption{$K_1$}
\label{fig:20140812k1}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.1\textwidth}
\centering\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (2,3) [circle, draw] {};
\draw (v1) -- (v2);
\end{tikzpicture}
\caption{$K_2$}
\label{fig:20140806k2}
\end{subfigure}
\begin{subfigure}[b]{0.16\textwidth}
\centering\begin{tikzpicture}[scale=0.50]
\node (v1) at (1,1) [circle, draw] {};
\node (v2) at (3,1) [circle, draw] {};
\node (v3) at (2,3) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v2) -- (v3);
\draw (v1) -- (v3);
\end{tikzpicture}
\caption{$K_3$}
\label{fig:20140812k3}
\end{subfigure}%
\begin{subfigure}[b]{0.16\textwidth}
\centering\begin{tikzpicture}[scale=0.50]
\node (v1) at (1,1) [circle, draw] {};
\node (v2) at (5,1) [circle, draw] {};
\node (v3) at (3,2) [circle, draw] {};
\node (v4) at (3,4) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v3) -- (v4);
\end{tikzpicture}
\caption{$K_4$}
\label{fig:20140812k4}
\end{subfigure}%
\begin{subfigure}[b]{0.16\textwidth}
\centering\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (4,1) [circle, draw] {};
\node (v3) at (1,3) [circle, draw] {};
\node (v4) at (5,3) [circle, draw] {};
\node (v5) at (3,4) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v1) -- (v5);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v2) -- (v5);
\draw (v3) -- (v4);
\draw (v3) -- (v5);
\draw (v4) -- (v5);
\end{tikzpicture}
\caption{$K_5$}
\label{fig:20140812k5}
\end{subfigure}%
%\quad
\begin{subfigure}[b]{0.16\textwidth}
\centering
\begin{tikzpicture}[scale=0.50]
\node (v1) at (2,1) [circle, draw] {};
\node (v2) at (4,1) [circle, draw] {};
\node (v3) at (1,3) [circle, draw] {};
\node (v4) at (5,3) [circle, draw] {};
\node (v5) at (2,5) [circle, draw] {};
\node (v6) at (4,5) [circle, draw] {};
\draw (v1) -- (v2);
\draw (v1) -- (v3);
\draw (v1) -- (v4);
\draw (v1) -- (v5);
\draw (v1) -- (v6);
\draw (v2) -- (v3);
\draw (v2) -- (v4);
\draw (v2) -- (v5);
\draw (v2) -- (v6);
\draw (v3) -- (v4);
\draw (v3) -- (v5);
\draw (v3) -- (v6);
\draw (v4) -- (v5);
\draw (v4) -- (v6);
\draw (v5) -- (v6);
\end{tikzpicture}
\caption{$K_6$}
\label{fig:20140812k6}
\end{subfigure}%
\caption{Vollständige Graphen $K_1$ bi $K_6$}\label{fig:completeGraphs}
\end{figure}
\end{document}