小页面图片标题对齐

小页面图片标题对齐

标题较长时对齐会中断。如何修复?

\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}

在此处输入图片描述

答案1

如果你想单独对齐图片和标题,可以使用表格,但你必须将标题放在\parboxes 或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}

演示

答案2

要对齐标题,请使用[t]选项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}

在此处输入图片描述

如果要对齐图形的顶部,请另外使用包\adjincludegraphics[...,valign=T]中的adjustbox选项。

\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}

在此处输入图片描述

相关内容