17

I have an addition to this question: Two figures side by side.

Suppose we have two pictures, making them of uneven height. I am looking for a way to not use subfig and align two figures side-by-side, while keeping the captions vertically aligned.

I've created the following example:

\documentclass{article}
\title{Two Figures Side by Side}
\author{Little Bobby Tables}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\exedout}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}

\newcommand{\exedouttwo}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}
\begin{document}
\maketitle
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering\exedout
\caption{first figure but with more comments than the second picture to see what the different is.}
\end{minipage}
\begin{minipage}{0.45\textwidth}
\centering\exedouttwo
\caption{second figure}
\end{minipage}
\end{figure}

\lipsum

\end{document}

It gives the following result:

wrong alignment

But I need this:

right alignment

  • 1
    minipage environments have placement parameters [c], [t] and [b], do they help? – uli Dec 6 '11 at 12:43
  • why are you not using the \includegraphics[width=\textwidth]{flower1.jpg}, how are you inserting an image exactly then? – Charlie Parker Oct 25 '16 at 21:33
19

Use the [t] optional argument of minipage to align both to the top baseline (i.e. the image baseline / lower line). I also added %s to your macros to avoid extra spaces being inserted by the source code line breaks.

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\exedout}{%
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}%
}

\newcommand{\exedouttwo}{%
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}%
}
\begin{document}
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\centering
\begin{minipage}[t]{0.45\textwidth}
\centering\exedout
\caption{first figure but with more comments than the second picture to see what the different is.}
\end{minipage}
\begin{minipage}[t]{0.45\textwidth}
\centering\exedouttwo
\caption{second figure}
\end{minipage}
\end{figure}

\lipsum

\end{document}
  • Yes, this is what I was looking for. I already tried it with only a single [t], but didn't come up with doing it at both minipages. – Marnix Dec 6 '11 at 13:28
  • why are you not using the \includegraphics[width=\textwidth]{flower1.jpg}, how are you inserting an image exactly then? – Charlie Parker Oct 25 '16 at 21:33
  • @CharlieParker: Figures don't have to include \includegraphics. They can include any content you like, like a drawing made by the TikZ package in this case. If you want to include the image instead just replace the \exedout and \exedouttwo macros with \includegraphics... – Martin Scharrer Oct 26 '16 at 17:36
4

Is using floatrow an option?

Note that in the following example I made the two figures narrower by changing \exedout and \exedouttwo, as ffigbox doesn't seem to change \textwidth as minipage does, hence the two figures would be too wide.

\documentclass{article}
\title{Two Figures Side by Side}
\author{Little Bobby Tables}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{floatrow}
\newcommand{\exedout}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.4\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}

\newcommand{\exedouttwo}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.4\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}
\begin{document}
\maketitle
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\begin{floatrow}
\ffigbox{\caption{first figure but with more comments than the second picture to see what the different is.}}{\exedout}
\ffigbox{\caption{second figure}}{\exedouttwo}
\end{floatrow}
\end{figure}

\lipsum

\end{document}

enter image description here

  • Seems like a good alternative if I need any other configurations like aligning them both at the top. – Marnix Dec 6 '11 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.