下面的代码抱怨图形列表中的水平框过满,尽管该行完全在页边距内。如何消除警告?数字后的 Latex 排版是什么?
\documentclass{book}
\usepackage{tocloft}
\usepackage[showframe]{geometry}
\makeatletter
\renewcommand{\cftfigleader}{}
\renewcommand{\cftfigafterpnum}{\cftparfillskip}
\makeatother
\overfullrule=5mm
\begin{document}
\listoffigures
\mainmatter
\begin{figure}
\framebox{FIGURE}
\caption{A very looooooooooooooooooooooooooooooooooooooooooooooong captioooonnnnn}
\label{figure2}
\end{figure}
\end{document}
答案1
这个解决方案永远不会产生过满的情况\hbox
,至少不会因为页码而产生过满的情况。
\documentclass{book}
\usepackage{tocloft}
\usepackage[showframe]{geometry}
\usepackage{blindtext}
\cftsetrmarg{0pt}
\renewcommand{\cftfigafterpnum}{\cftparfillskip}
\makeatletter
\renewcommand{\cftfigleader}{\hspace{0pt plus \@pnumwidth}\allowbreak}
\makeatother
\overfullrule=5mm
\begin{document}
\listoffigures
\mainmatter
\begin{figure}
\framebox{FIGURE}
\caption{A very looooooooooooooooooooooooooooooooooooooooooooooong captioooonnnnnnnn}
\label{figure1}
\end{figure}
\begin{figure}
\framebox{FIGURE}
\caption{\blindtext}
\label{figure2}
\end{figure}
此解决方案允许页码并且只允许页码一直到右边距。
\documentclass{book}
\usepackage{tocloft}
\usepackage[showframe]{geometry}
\usepackage{blindtext}
\renewcommand{\cftfigleader}{}
\renewcommand{\cftfigafterpnum}{\cftparfillskip
\advance\parfillskip by -\rightskip}
\makeatletter
\cftsetrmarg{\@pnumwidth}
\makeatother
\overfullrule=5mm
\begin{document}
\listoffigures
\mainmatter
\begin{figure}
\framebox{FIGURE}
\caption{A very looooooooooooooooooooooooooooooooooooooooooooooong captioooonnnnnnn}
\label{figure1}
\end{figure}
\begin{figure}
\framebox{FIGURE}
\caption{\blindtext}
\label{figure2}
\end{figure}
\end{document}