4

I have a small problem with vertical alignment in LaTeX. I have 3 figures with different height and I want to show them in one figure (side-by-side). Unfortunately, by default they are aligned to the bottom edge and it doesn't look good. However if I try to align them to the top edge it doesn't look good either, because the captions of subfigures are not aligned.

The image showing the subfigures align to the top edge

I cannot use subfig package, because there are some conflict with another package I use, but I use a lot of packages so I'm not sure what package is making the trouble.

Is there some possible way, how to align the subfigures to the top edge and prevent the alignment of the subcaption?

Here is my current code:

\begin{figure}[!ht]
    \begin{subfigure}[t][1\width]{0.3\textwidth}
        \centering\vspace{0pt}
        \includegraphics[width=\textwidth]{content/indoor/convex_space}
        \caption{Convex Spaces}
        \label{fig:convex_space}
    \end{subfigure}
    ~
    \begin{subfigure}[t][1\width]{0.3\textwidth}
        \centering\vspace{0pt}
        \includegraphics[width=\textwidth]{content/indoor/axial_line}
        \caption{Axial Map}
        \label{fig:axial_line}
    \end{subfigure}
    ~
    \begin{subfigure}[t][1\width]{0.3\textwidth}
        \centering\vspace{0pt}
        \includegraphics[width=\textwidth]{content/indoor/intersection_graph}
        \caption{Intersection graph}
        \label{fig:intersection_graph}
    \end{subfigure}
    \caption{Examples of some spatial analysis technique\cite{dawes2013}}
    \label{fig:scene_walls_3d}
\end{figure}

migrated from stackoverflow.com Jun 7 '13 at 15:09

This question came from our site for professional and enthusiast programmers.

4

A TikZ based solution:

\documentclass{article}

\usepackage{subcaption}
\usepackage{tikz}

\begin{document}

\begin{figure}[!ht]
    \begin{subfigure}{0.3\textwidth}
        \begin{tikzpicture}
          \node{\includegraphics[width=\textwidth]{tall}};
          % obtain coordinates of size of the largest bounding box to 
          % be used in the other two subfigures
          \coordinate (ne)at(current bounding box.north east);
          \coordinate (sw)at(current bounding box.south west);
        \end{tikzpicture}
        \caption{Convex Spaces}
        \label{fig:convex_space}
    \end{subfigure}
    ~
    \begin{subfigure}{0.3\textwidth}
        \begin{tikzpicture}
          \useasboundingbox(ne)rectangle(sw);
          \node[below] at(current bounding box.north){\includegraphics[width=\textwidth]{med}};
        \end{tikzpicture}
        \caption{Axial Map}
        \label{fig:axial_line}
    \end{subfigure}
    ~
    \begin{subfigure}{0.3\textwidth}
        \begin{tikzpicture}
          \useasboundingbox(ne)rectangle(sw);
          \node[below] at(current bounding box.north){\includegraphics[width=\textwidth]{short}};
        \end{tikzpicture}
        \caption{Intersection graph}
        \label{fig:intersection_graph}
    \end{subfigure}
    \caption{Examples of some spatial analysis technique}
    \label{fig:scene_walls_3d}
\end{figure}

\end{document}

enter image description here

  • Wow, it actually helped. Thanks a lot, I'd never thought to use TikZ. – Higgcz Jun 8 '13 at 14:19

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.