如何让图表列表使用自动缩短版本的标题?

如何让图表列表使用自动缩短版本的标题?

我的许多标题都很长,在图片列表中显示为 5 行或更多行。为了节省我在标题中使用可选参数的精力,是否有任何软件包可以生成仅包含第一行和某种符号的图片列表,以表明这不是完整的标题?

答案1

另一种实现方式是,在排版时缩短 lof 中的标题......

在此处输入图片描述

\documentclass{article}
\showboxdepth1
\showboxbreadth100
\makeatletter
\long\def\l@figure#1#2{%
\setbox0\vbox{%
\def\lpx{\interlinepenalty-\@M}%
\advance\hsize -1em
\@dottedtocline{1}{1.5em}{2.3em}{\aftergroup\lpx#1bbbb}{#2}}%
\ifdim\ht0>\baselineskip
\begingroup
\vbadness\maxdimen
\setbox2=\vsplit0to \baselineskip
\setbox4\vbox{%
\unvbox2
\global\setbox1\lastbox}%
\endgroup
\noindent\hbox to \linewidth{\unhbox1\unskip!!%
\dotfill\hb@xt@\@pnumwidth{\hfil\normalfont \normalcolor #2}%
%\kern\@tocrmarg
}%
\else
\@dottedtocline{1}{1.5em}{2.3em}{#1}{#2}%
\fi
}
\begin{document}

\listoffigures

\begin{figure}[!b]
\caption{One one one a  longish caption.}
\end{figure}



\begin{figure}[!b]
\caption{A short caption.}
\end{figure}


\begin{figure}[!b]
\caption{This one is a very  very  very  very  very  very  very 
 very  very  very  very  very long caption.}
\end{figure}


\def\z{even longer than before }
\begin{figure}[!b]
\caption{Hmmm \z\z\z. Very long caption. More \z\z\z.}
\end{figure}

\end{document}

答案2

您可以尝试截断标题参数,但请注意,从印刷上看,这会看起来很差。

在此处输入图片描述

您需要添加两个包,一个是caption包,另一个是truncate包。我们定义一个新命令\Caption用作:

\Caption[optional width spec.]{caption text ..............}

也可能存在变化,我留给您去尝试。

\documentclass{article}
\usepackage{truncate}
\usepackage{caption}
\begin{document}
\listoffigures
\DeclareRobustCommand\Caption[2][130pt]{\captionof{figure}{\truncate{#1}{#2}}}
\begin{figure}
\Caption{This is my famous half a kilometer long caption that has been truncated}
\end{figure}
\begin{figure}
\Caption{This is my famous half a kilometer long caption that has not been truncated}
\end{figure}
\end{document}

您可以稍后通过重新声明命令来禁用效果\Caption,如下所示:

 \DeclareRobustCommand{\Caption}[2][]{\captionof{figure}{#2}}

我可以想到很多其他提供输入的方式,而这最终取决于是否需要永久保留缩短版本。

相关内容