将 tikzpictures 并排放置

将 tikzpictures 并排放置

我有以下 tikzpictures,我想将它们显示在两列中。但是,无论我尝试什么,无论是multicolminipagesubcaption,它们都顽固地停留在一列中。您可能认为这是一个重复的问题,但我已经尝试了所有其他方法,但它们都不起作用!

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{tikz}
\usetikzlibrary{positioning}

\usepackage{float}

\begin{document}
    \begin{figure} [b]
        \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}
        \caption{Two-site exchange.}
        \label{fig:simple2}
    \end{figure}

    \begin{figure} %[h]
        \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) [below left=of A] {B};
        \node[pool] (C) [below right=of A]{C};
        \draw [<->] (A) -- (B);
        \draw [<->] (A) -- (C);
        \end{tikzpicture}
        \caption{Partial three-site exchange.}
        \label{fig:partial3}
    \end{figure}

    \begin{figure} %[h]
        \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) [below left=of A] {B};
        \node[pool] (C) [below=of A]{C};
        \node[pool] (D) [below right=of A]{D};
        \draw [<->] (A) -- (B);
        \draw [<->] (A) -- (C);
        \draw [<->] (A) -- (D);
        \end{tikzpicture}
        \caption{Partial four-site exchange.}
        \label{fig:partial4}
    \end{figure}

    \begin{figure} %[h]
        \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) [below left=of A] {B};
        \node[pool] (C) [below right=of A]{C};
        \draw [<->] (A) -- (B);
        \draw [<->] (A) -- (C);
        \draw [<->] (B) -- (C);
        \end{tikzpicture}
        \caption{General three-site exchange.}
        \label{fig:general3}
    \end{figure}

\end{document}

答案1

您只需使用一个figure环境。图形可以放在小页面中,以确保正确对齐(垂直和水平)。

我计算出 5cm,找到最佳高度。由于一个标题只有一行长,所以必须进行最后的调整(\vspace{\baselineskip})。

\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{figure}
\centering
\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\vfill
\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}
\vfill
\caption{Two-site exchange.}\label{fig:simple2}
\vspace{\baselineskip}
\end{minipage}\qquad
\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\vfill
\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) [below left=of A] {B};
  \node[pool] (C) [below right=of A]{C};
  \draw [<->] (A) -- (B);
  \draw [<->] (A) -- (C);
\end{tikzpicture}
\vfill
\caption{Partial three-site exchange.}\label{fig:partial3}
\end{minipage}

\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\vfill
\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) [below left=of A] {B};
  \node[pool] (C) [below=of A]{C};
  \node[pool] (D) [below right=of A]{D};
  \draw [<->] (A) -- (B);
  \draw [<->] (A) -- (C);
  \draw [<->] (A) -- (D);
\end{tikzpicture}
\vfill
\caption{Partial four-site exchange.}\label{fig:partial4}
\end{minipage}\qquad
\begin{minipage}[b][5cm][s]{.45\textwidth}
\centering
\vfill
\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) [below left=of A] {B};
  \node[pool] (C) [below right=of A]{C};
  \draw [<->] (A) -- (B);
  \draw [<->] (A) -- (C);
  \draw [<->] (B) -- (C);
\end{tikzpicture}
\vfill
\caption{General three-site exchange.}\label{fig:general3}
\end{minipage}
\end{figure}

\end{document}

在此处输入图片描述

相关内容