4

The alignment is broken when a long caption is there. How to fix?

\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=1\linewidth]{images/Image_34}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System
  \label{fig:Image_34}}
\end{minipage}%
\begin{minipage}{.5\textwidth}
  \centering
  \includegraphics[width=1\linewidth]{images/Image_001}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System load buses only \label{fig:Image_001}}
\end{minipage}
\end{figure}

enter image description here

2 Answers 2

2

If you want to align the images and captions independently, use a tabular, but you must put the captions in \parboxes or minipages.

\documentclass{article}
\usepackage{graphicx}
\usepackage{showframe}% debugging tool
\begin{document}

\newlength{\halfwidth}
\setlength{\halfwidth}{\dimexpr 0.5\textwidth-\tabcolsep}

\begin{figure}
\begin{tabular}{@{}p{\halfwidth}p{\halfwidth}@{}}
  \raisebox{-\height}{\includegraphics[width=1\linewidth]{example-image-4x3}}&
    \raisebox{-\height}{\includegraphics[width=1\linewidth]{example-image-1x1}}\\
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System}\label{fig:Image_34}&
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System load buses only}\label{fig:Image_001}
\end{tabular}
\end{figure}

\end{document}

demo

0
7

To align the captions use the [t] option of minipage.

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{figure}
\centering
\begin{minipage}[t]{.5\textwidth}
  \centering
  \includegraphics[width=1\linewidth]{example-image-4x3}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System
  \label{fig:Image_34}}
\end{minipage}%
\begin{minipage}[t]{.5\textwidth}
  \centering
  \includegraphics[width=1\linewidth]{example-image-1x1}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System load buses only \label{fig:Image_001}}
\end{minipage}
\end{figure}

\end{document}

enter image description here

If you want to align the top of the figures, additionally use \adjincludegraphics[...,valign=T] from the adjustbox package.

\documentclass{article}
\usepackage{graphicx}
\usepackage{adjustbox}
\begin{document}

\begin{figure}
\centering
\begin{minipage}[t]{.5\textwidth}
  \centering
  \adjincludegraphics[width=1\linewidth,valign=T]{example-image-4x3}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System
  \label{fig:Image_34}}
\end{minipage}%
\begin{minipage}[t]{.5\textwidth}
  \centering
  \adjincludegraphics[width=1\linewidth,valign=T]{example-image-1x1}
  \caption{{\fontfamily{pcr}\selectfont spy} Plot of 4-bus Test System load buses only \label{fig:Image_001}}
\end{minipage}
\end{figure}

\end{document}

enter image description here

0

You must log in to answer this question.

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