caption
宏包中有一个\DeclareCaptionTextFormat
命令,可以用来定制标题内容部分的样式,定制好的样式由\captionsetup
命令中的textformat
键调用。
是否有更好的利用caption
包的办法而不是抖机灵呢?
这里退而求其次吧,将varwidth
环境封装在\DeclareCaptionTextFormat
中。
MWE:
\documentclass{ctexart}
\usepackage{showframe}
\usepackage{graphicx}
\usepackage{varwidth}
\usepackage{caption}
% ------------------------------------------------- %
\DeclareCaptionTextFormat{foo}{\begin{varwidth}[t]{.8\linewidth}#1\end{varwidth}\par}
\captionsetup{textformat=foo,justification=centering}
% ================================================= %
\usepackage{bicaption}
% ------------------------------------------------- %
\bicaptionsetup[figure]{name=图}{name=Fig.}
% ================================================= %
\usepackage{lipsum,zhlipsum}
\begin{document}
\begin{figure}[h]
\centering
\includegraphics[width=.3\textwidth]{example-image}
\bicaption{中文中文中文}{English text English text English text English text English text English text English text English text English text English text English text}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=.3\textwidth]{example-image}
\bicaption{中文中文中文中文中文中文中文}{English text English text English text[]\\
English text English text English text English text English text English text English text English text}
\end{figure}
\lipsum[2]
\end{document}
\caption
所生成标题的水平对齐效果只能由justification
键修改,因此实现悬挂缩进的最佳实践应该就是给标题内容套用盒子。
但这里有个疑问:段落盒子由varwidth
环境换成\parbox
,即
\parbox[t]{0.8\linewidth}{#1}
其无法实现标题的居中对齐(结果偏左),原因不清楚。
问 在使用bicaption时,如何同时实现「caption悬挂缩进」、「手动指定换行」同时「实现caption居中」?