如何让图形标题跨越多页,而不必将所有内容切换到 capt-of?

如何让图形标题跨越多页,而不必将所有内容切换到 capt-of?

我在 TeX.SE 和其他地方发现了几个关于如何让图片标题跨越多页的问题(例如,如何使图形标题跨越多页?)。我了解到caption包裹将标题放在牢不可破的盒子里。

有些答案建议使用capt-of包。capt-of似乎工作正常,但会破坏caption实例。 因此,使用capt-of启用长图标题似乎需要我将论文中的每个标题都切换为capt-of,这是一种负担,似乎消除了浮动图的好处。

以下是 MWE(也在背页) 中一个数字为短caption,一个数字为长captionof我希望能够\usepackage{capt-of} 同时\usepackage[font={small,sf}, singlelinecheck=false]{caption}启用,而且我的长标题仍然跨越多页。

\documentclass{article}

% I can't have both caption and capt-of enabled.

% Caption alone doesn't let long captions span multiple pages.    
\usepackage[font={small,sf}, singlelinecheck=false]{caption}

% Capt-of alone would require me to reformat many figures.
\usepackage{capt-of}

% But enabling both breaks capt-of's ability to span captions across pages.

\usepackage{lipsum}

\begin{document} 

\lipsum[1]

% I have many figures that are formatted like this.
\begin{figure}[h!]
   \centering
   \rule{0.3\textwidth}{0.3\textheight}
\caption[Short caption]{\lipsum[1]}
\end{figure}

\lipsum[1-10]

% This seems to be the best way to get long captions to span multiple pages, while being styled like the above figure.
\begin{centering}
\sffamily
   \rule{0.5\textwidth}{0.75\textheight}
\captionof{figure}[short caption]{\lipsum[1-4]}
   \label{figure}
\end{centering}

\end{document}

或者,如果能找到一些可以轻松caption跨页面而不需要重新格式化的方法就更好了。

答案1

您不需要capt-of只有一行的包,但是caption标题框中包含相同的定义,因此如果您想破坏它,您需要将其取消装箱:

\documentclass{article}

% I can't have both caption and capt-of enabled.

% Caption alone doesn't let long captions span multiple pages.    
\usepackage[font={small,sf}, singlelinecheck=false]{caption}


\usepackage{lipsum}

\begin{document} 

\lipsum[1]

% I have many figures that are formatted like this.
\begin{figure}[h!]
   \centering
   \rule{0.3\textwidth}{0.3\textheight}
\caption[Short caption]{\lipsum[1]}
\end{figure}

\lipsum[1-10]

% This seems to be the best way to get long captions to span multiple pages, while being styled like the above figure.
\begin{center}

   \rule{0.5\textwidth}{0.75\textheight}

\bigskip
\setbox0\vbox{\makeatletter
\let\caption@rule\relax
\captionof{figure}[short caption]{\lipsum[1-4]}
\global\skip1\lastskip\unskip
\global\setbox1\lastbox
}
\unvbox0
\setbox0\hbox{\unhbox1\unskip\unskip\unpenalty
\global\setbox1\lastbox}
\unvbox1
\vskip\skip1



\end{center}

\end{document}

答案2

默认情况下,caption包将标题内容放在 中,\parbox因为这是支持某些caption包选项(边距等)所必需的。但是可以使用 进行更改\captionsetup{parbox=...},例如:

\documentclass{article}

\usepackage[font={small,sf}, singlelinecheck=false]{caption}
\usepackage{lipsum}

\begin{document} 

\lipsum[1]

% I have many figures that are formatted like this.
\begin{figure}[h!]
   \centering
   \rule{0.3\textwidth}{0.3\textheight}
\caption[Short caption]{\lipsum[1]}
\end{figure}

\lipsum[1-10]

% This seems to be the best way to get long captions to span multiple pages, while being styled like the above figure.
\begin{centering}
\sffamily
   \rule{0.5\textwidth}{0.75\textheight}
\captionsetup{parbox=none}% don't put this caption into a \parbox
\captionof{figure}[short caption]{\lipsum[1-4]}
   \label{figure}
\end{centering}

\end{document}

相关内容