2

I use the following for side by side figures. However, the caption of the left figure is positioned higher than the right. How can I make the caption position be at the same line?

\documentclass{article}
\usepackage{graphicx}

        \begin{document}

            \begin{figure}[H]
                \centering
            \begin{minipage}{.45\linewidth}
                \includegraphics [width=\linewidth]{example-image-a}
                \caption{Text for A}
            \label{fig:VisJ48}
                    \end{minipage}
                \hspace{.05\linewidth}
            \begin{minipage}{.45\linewidth}
                \includegraphics [width=\linewidth]{example-image-b}
                \caption{Text for B}
            \label{fig:TextJ48}
            \end{minipage}
            \end{figure}
    \end{document}
1
  • 2
    Well, this 1) not compilable due to the H specifier and 2) not useful at the moment since we don't have the relevant figures at hand which cause the non-alignment. I suspect: \begin{minipage}[b]{....}, i.e. bottom alignment
    – user31729
    Commented Jun 21, 2016 at 15:18

3 Answers 3

3

Add [b] to minipages, it will vertically align them to the bottom. \begin{minipage}[b]{.45\linewidth}

As pointed out by Mico, there is no use for \centering here.

Output

enter image description here

Code

\documentclass{article}
\usepackage{graphicx}
    \begin{document}
        \begin{figure}[h]
        \begin{minipage}[b]{.45\linewidth}
            \includegraphics[width=.5\linewidth]{example-image-a}
            \caption{J48 visual representation of IRIS dataset}
        \label{fig:VisJ48}
                \end{minipage}%
                \hfill%
        \begin{minipage}[b]{.45\linewidth}
            \includegraphics[width=\linewidth]{example-image-b}
            \caption{J48 Textual representation of IRIS dataset}
        \label{fig:TextJ48}
        \end{minipage}
        \end{figure}
\end{document}
1
  • Yes, in the future I'll have a closer look at the code, to look for other improvements.
    – Runar
    Commented Jun 21, 2016 at 15:27
3

You may wish to move the content into place for the smaller image. To do so, place the larger image inside a box - \imagebox - so you can measure its height:

enter image description here

\documentclass{article}

\usepackage{graphicx}
\newsavebox{\imagebox}
\begin{document}

\begin{figure}
  \savebox{\imagebox}{\includegraphics[width=.45\linewidth]{example-image-9x16}}%
  \begin{minipage}[b]{.45\linewidth}
    \raisebox{\dimexpr.5\ht\imagebox-.5\height}{\includegraphics[width=\linewidth]{example-image}}
    \caption{J48 visual representation of IRIS dataset}
  \end{minipage}%
  \hspace{.05\linewidth}%
  \begin{minipage}[b]{.45\linewidth}
    \includegraphics[width=\linewidth]{example-image-9x16}
    \caption{J48 Textual representation of IRIS dataset}
  \end{minipage}%
\end{figure}

\end{document}

The smaller image is moved vertically via \raisebox{<height>}{<stuff>} a height of 50% of the larger image (.5\ht\imagebox) minus 50% of the smaller image (.5\height).

2

An alternative approach using tabularand \captionof from thecaption`-package. I do not really like using tabulars for this, but it works. You can then align the images and caption individually.

Output

enter image description here

Code

\documentclass{article}
\usepackage{graphicx}
\usepackage{array}
\usepackage{caption}
\begin{document}
\begin{tabular}{m{4cm}m{6cm}}
    \includegraphics[width=\linewidth]{example-image-a}&\includegraphics[width=\linewidth]{example-image-b}\\
    \captionof{figure}{Figure A}&\captionof{figure}{Figure B}\\
\end{tabular}
\end{document}

You must log in to answer this question.

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