副标题居中对齐

副标题居中对齐

我正在使用以下代码来放置两个子图:

\documentclass[a4paper, 12pt]{article}
\usepackage[margin=0.8in]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float}

\newcommand{\rulesep}{\unskip\ \vrule\ }
  \begin{document}
    \begin{figure}[H]
      \centering
        \begin{subfigure}{.48\linewidth}
        \centering
        \includegraphics[width=\linewidth]{subfigure_1.jpeg}
        \caption[caption]{This is the caption\\Isosurface corresponding to \, $\lambda_{2,m} = -3$.}
        \label{subfig1}
        \end{subfigure} 
        \hfill
        \rulesep
        \begin{subfigure}{.48\linewidth}
        \centering
        \includegraphics[width=\linewidth]{subfigure_2.jpeg}
        \caption[caption]{This is the caption\\Isosurface corresponding to \, $\lambda_{2,m} = -3$.}
        \label{subfig2}
        \end{subfigure}
        \caption{Figure 1}
        \end{figure}
  \end{document}

该代码的输出是:

在此处输入图片描述 正如我们所见,子标题并未出现在子图的中心。

我希望标题的两行都位于子图的中心。我想要类似这样的效果: 在此处输入图片描述

有人能告诉我该怎么做吗?

答案1

像这样?

在此处输入图片描述

(红色规则表示文本区域边框)

\documentclass[12pt]{article}
\usepackage[margin=0.8in]{geometry}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}

%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\begin{figure}[ht]
  \centering
  \setkeys{Gin}{width=\linewidth,height=95mm}
  \captionsetup[subfigure]{justification=centerlast}
  \begin{subfigure}{65mm}
    \includegraphics{example-image}
    \caption[Short caption]{Top view.\\ Isosurface corresponding to $\lambda_{2,m} = -3$}
    \label{subfig1}
  \end{subfigure}
  \hfil
  \begin{subfigure}{65mm}
    \includegraphics{example-image-duck}
    \caption[Short caption]{Top view.\\ Isosurface corresponding to \mbox{$\lambda_{2,m} = -3$}
    \label{subfig2}
  \end{subfigure}
  \caption{Figure 1}
\end{figure}
\end{document}

相关内容