
我想居中對齊子標題對應於其對應的子圖,如下所示:
我目前的嘗試使他們左對齊即使我已經\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}