我想居中对齐子标题与其对应的子图相对应,如下所示:
我目前的尝试使它们左对齐即使我已经\centering
在相应的\begin{subfigure} ... \end{subfigure}
块中指定了。
我想要的是将整个副标题移动到红色的框。其他格式应保持不变。
梅威瑟:
\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage{mwe}
\usepackage{caption}
\captionsetup{format=plain,font=small,labelfont={sc,bf},labelsep=period}
\usepackage{subcaption}
\captionsetup[subfigure]{format=hang,font=footnotesize,labelfont=up,singlelinecheck=false}
\renewcommand{\thesubfigure}{\alph{subfigure}}
\begin{document}
\begin{figure}[!htbp]
\centering
\begin{subfigure}[t]{0.49\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{
Caption of subfigure1 \\ (e.g., load case 1 and 2).
}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.49\textwidth}
\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{
Caption of subfigure2 \\ (e.g., load case 3 and 4).
}
\end{subfigure}%
\caption{
Comparison of two subfigures.
}
\end{figure}
\end{document}
答案1
justification=centering
您需要为提供参数\captionsetup[subfigure]{...}
。此时,您不妨删除参数format=hang
和 ,singlelinecheck=false
因为它们似乎没有任何用处。
我还会删除(或至少注释掉)所有三个\centering
指令,因为它们除了产生不必要的代码混乱之外没有任何作用。
\documentclass{article}
\usepackage{graphicx,mwe}
\usepackage{caption}
\captionsetup{format=plain,font=small,
labelfont={sc,bf},labelsep=period}
\usepackage{subcaption}
\captionsetup[subfigure]{font=footnotesize,
labelfont=up,
%%singlelinecheck=false,
%%format=hang,
justification=centering % <-- new
}
%\renewcommand{\thesubfigure}{\alph{subfigure}} % that's the default
\begin{document}
\begin{figure}[!htbp]
%%\centering
\begin{subfigure}[t]{0.49\textwidth}
%%\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{Caption of subfigure 1\\(e.g., load cases 1 and 2).}
\end{subfigure}%
\hfill
\begin{subfigure}[t]{0.49\textwidth}
%%\centering
\includegraphics[width=\linewidth]{example-image-b}
\caption{Caption of subfigure 2\\(e.g., load cases 3 and 4).}
\end{subfigure}%
\caption{Comparison of two subfigures.}
\end{figure}
\end{document}