6

I have the following tikzpictures, and I would like to present them in two columns. However, no matter what I try, whether it be multicol or minipage or subcaption, they stubbornly stay in one column. You may think this is a duplicate question, but I've tried all the others and they don't work!

\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}
3
  • 1
    there is nothing special about positioning a tikzpicture, it is positioned like an X If you put two X side by side they come side by side, if you put two X with a blank line between, they come one above the other, if you put two X in separate figure environments they float separately and will go one above the other Nov 4, 2014 at 23:44
  • This is exactly what I was missing. I had nice newlines between each minipage environment. Of course, these behaved exactly as you describe.
    – daviewales
    Nov 5, 2014 at 0:33
  • oh no and I've deleted my answer so you'll have to accept egreg's and he'll pick up the points, oh well:-) Nov 5, 2014 at 0:36

1 Answer 1

7

You have to use just one figure environment. The figures can be put in minipages so as to ensure proper alignment, both vertical and horizontal.

I computed 5cm, find the best height. Since one caption turns out to be only one line long, a final adjustment has to be made (\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}

enter image description here

3
  • 1
    hmm beat me by a minute, I'll delete Nov 4, 2014 at 23:58
  • You sir, are a magician. I could have sworn I used just one figure with minipages inside it, but apparently I didn't. Thank you very much.
    – daviewales
    Nov 5, 2014 at 0:28
  • 1
    For future reference, @DavidCarlisle's comment on my answer was the missing link. minipages will only go side by side if there is NO NEWLINE between them.
    – daviewales
    Nov 5, 2014 at 0:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .