我怎样才能将 kaobook 包中的子标题放入子图的中心。我试过了 \captionsetup[subfigure]{justification=centering}
,但这对子标题的位置没有影响。
我期望与 kaobook 使用的 floatrow 包有一些交互,但我找不到合适的选项来更改子标题的位置。
梅威瑟:
\documentclass{kaobook}
\usepackage{subcaption}
\begin{document}
\begin{figure*}
\captionsetup[subfigure]{justification=centering}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=1\linewidth,keepaspectratio]{example-image-1x1}
\caption{subcap 1}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=1\linewidth,keepaspectratio]{example-image-golden-upright}
\caption{subcap 2}
\end{subfigure}
\caption{big caption}
\end{figure*}
\end{document}
答案1
kao.sty
设置以下标题选项:
% Set the global caption style
\captionsetup{
format=margin, % Use the style previously declared
strut=no,%
%hypcap=true, % Links point to the top of the figure
singlelinecheck=false,%
%width=\marginparwidth,
indention=0pt, % Suppress indentation
parindent=0pt, % Suppress space between paragraphs
aboveskip=6pt, % Increase the space between the figure and the caption
belowskip=6pt, % Increase the space between the caption and the table
}
要使短(子)标题居中,需要恢复format=margin
和singlelinecheck=false
设置,例如:
\documentclass{kaobook}
\usepackage{subcaption}
\begin{document}
\begin{figure*}
\captionsetup[subfigure]{format=plain,singlelinecheck=true}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=1\linewidth,keepaspectratio]{example-image-1x1}
\caption{subcap 1}
\end{subfigure}
\begin{subfigure}{0.45\textwidth}
\includegraphics[width=1\linewidth,keepaspectratio]{example-image-golden-upright}
\caption{subcap 2}
\end{subfigure}
\caption{big caption}
\end{figure*}
\end{document}
答案2
感谢 PM 指点我指向\captionsetup
。解决方案有效,但子标题的字体大小略有不同。
要解决这个问题,可以定义类似于margin
和 的@margin@par
标题格式kao.sty
,并用\justifying
替换\Centering
。
\newcommand{\subcappar}{%
\Centering% center text
\setlength{\RaggedRightParindent}{0em}% Suppress indentation
\setlength{\parindent}{0em}% Suppress indentation
\setlength{\parskip}{0.5pc}% Set the space between paragraphs
%%\singlespacing% Set the space between lines
\frenchspacing% No additional space after periods
\normalfont% Use the default font
\footnotesize% Use a smaller size
}
\DeclareCaptionFormat{subcap}{\subcappar #1#2#3}
可以将以下行添加到标题中以影响所有子标题,也可以添加到图形环境中以仅影响一个图形。
\captionsetup[subfigure]{format=subcap}