39

This code:

\begin{figure*}[t]
\begin{center}
        \begin{subfigure}[a]{0.3\textwidth}
                \label{im:device_front}
        \includegraphics[width=\textwidth]{images/bsn_side}
        \caption{a) Frontal view of the sensor system}
    \end{subfigure}
                \quad    
    \begin{subfigure}[b]{0.3\textwidth}
                \label{im:device_schuin}
        \includegraphics[width=\textwidth]{images/bsn_front}
        \caption{b) Perspective view of the sensor system}
    \end{subfigure} 
            \quad
    \begin{subfigure}[b]{0.25\textwidth}
                \label{im:device_side}
        \includegraphics[width=\textwidth]{images/bsn_schuin}
        \caption{c) Side view of the sensor system}
    \end{subfigure} 
\caption{Overview of the system as worn by the subjects}
\label{default}
\end{center}
\end{figure*}

produces result:

enter image description here

But I want them to be vertically aligned. How can I do this?

janpf
  • 3
  • 3
jorrebor
  • 699

4 Answers4

48

I simply couldn't pass this one by, if only just to produce a solution that makes note of the obvious similarities between the sample provided and the classic Tron Guy.

The actual solution uses subfig package, but who cares.

\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage[labelsep=quad,indention=10pt]{subfig}
\captionsetup*[subfigure]{position=bottom}
\begin{document}
    \begin{figure}[h]
        \centering
           \subfloat[Frontal view]{%
              \includegraphics[height=5cm]{tron_side.jpg}%
              \label{fig:left}%
           } 
           \subfloat[Perspective view]{%
              \includegraphics[height=5cm]{tron_front.jpg}%
              \label{fig:middle}%
           }
           \subfloat[Side view]{%
              \includegraphics[height=5cm]{tron_right2.jpg}%
              \label{fig:right}%
           }
           \caption{Overview of the sensor system as worn by the subjects.}
           \label{fig:default}
    \end{figure}    
\end{document}

Solution

  • 11
    But in your example you're using 3 pictures of the same size. I thought the point of the question was to align pictures of different sizes. – Andreina Sep 14 '17 at 12:16
  • 2
    also the captions are mixed up – TomDLT Jun 26 '18 at 10:38
  • 1
    @Andreina They are not of the same size. They are of different sizes. They were scaled proportionately to have the same height so they could be aligned, and that is my solution. – Nicholas Hamilton Jun 26 '18 at 11:37
33

The interface provided by the subfigure package, specifies the first (optional) argument to indicate the vertical alignment. Using [b] should align be bottom of the sub figures. Analogously, [t] should align the tops.

Instead of numbering the captions manually

\caption{a) ...}

you could use the accompanying \subfigure command:

\subfigure{...}

and change the format of the numbering to your liking.

Werner
  • 603,163
  • subcaption seems to be incompatible with subfig. Is there a solution. But I have many subfloats. Is there a solution with subfig / one that does not require to change all subfloats (without setting height explicitly)? – Martin Thoma Dec 17 '13 at 06:47
  • Thank you so much for pointing out this easy solution. I've seen others where they use minipages inside minipages to align images and captions separately and was already losing hope. – Big_Chair Nov 03 '19 at 10:19
  • 1
    @Big_Chair: The subfigure package is considered obsolete. It's best to use the subcaption package; it's distributed with the caption package, something that is pretty standard for setting \caption properties and layouts. – Werner Nov 03 '19 at 22:21
10

I found this code:

\begin{figure}
\subfigure{\includegraphics[width=67mm]{PipeScannerUnderGround}}
\subfigure{\raisebox{10mm}{\includegraphics[width=47mm]{CylScanGeometryPipe}}}
\caption{}
\end{figure}

here

Worked perfectly :)

Use \usepackage{subfigure} in the preamble

Sang
  • 103
Ragni
  • 101
1

From webpage https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

\begin{figure}
    \centering
    \begin{subfigure}[b]{0.3\textwidth}
        \includegraphics[width=\textwidth]{gull}
        \caption{A gull}
        \label{fig:gull}
    \end{subfigure}
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. 
      %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.3\textwidth}
        \includegraphics[width=\textwidth]{tiger}
        \caption{A tiger}
        \label{fig:tiger}
    \end{subfigure}
    ~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. 
    %(or a blank line to force the subfigure onto a new line)
    \begin{subfigure}[b]{0.3\textwidth}
        \includegraphics[width=\textwidth]{mouse}
        \caption{A mouse}
        \label{fig:mouse}
    \end{subfigure}
    \caption{Pictures of animals}\label{fig:animals}
\end{figure}
Zarko
  • 296,517
Mujdat
  • 21
  • 5
    Without some more content, this doesn't really add much more value than is already included in the OP. What is the vertical alignment if gull, tiger and mouse have different heights? – Werner Nov 08 '16 at 20:29