3

The code below complain for an overfull hbox in the list of figure, albeit the line is well within pagemargin. How can the warning be removed? What is Latex typesetting after the number?

\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} 

enter image description here

  • Tocloft sets \rightskip to 25.5pt. Use \cftsetrmarg{0pt}. – John Kormylo Oct 3 '18 at 15:04
1

This solution will never generate an overfull \hbox, at least not due to the page number.

\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}

This solution allows the page number and only the page number all the way to the right margin.

\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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.