1

I have just been playing around with this solution to a question I asked Extending table of contents dots up to large page numbers. I noticed the following behaviour.

For some very long Roman page numbers, if they extend into the table of content's entry's text and leave room for some dots, then alignment is preserved. If however, there is no space for dots, then the page number is pushed into the right margin.

I realise the behaviour is contrived, but I am curious as to why this is happening, as I thought because the page numbers were being put in a right aligned box it would still preserve right alignment, and more likely have double printed characters in the table entry.

enter image description here

\documentclass{extarticle} \usepackage{lipsum} \usepackage[nottoc]{tocbibind} \usepackage{tocbasic} \DeclareTOCStyleEntries[ rightindent=10em, pagenumberbox=\pagenumberbox ]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table} \newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}} \begin{document} \tableofcontents \pagenumbering{Roman} \setcounter{page}{12340} \section{Some big page numbers} \subsection{Something} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it} \end{document} 

1 Answer 1

1

You could add option raggedentrytext:

\documentclass{extarticle} \usepackage{lipsum} \usepackage[nottoc]{tocbibind} \usepackage{tocbasic} \DeclareTOCStyleEntries[ rightindent=10em, raggedentrytext,% <- added pagenumberbox=\pagenumberbox ]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table} \newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}} \begin{document} \tableofcontents \pagenumbering{Roman} \setcounter{page}{12340} \section{Some big page numbers} \subsection{Something} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it} \end{document} 

Result:

enter image description here

Or you could use \sloppy in the ToC:

\documentclass{extarticle} \usepackage{lipsum} \usepackage[nottoc]{tocbibind} \usepackage{tocbasic} \DeclareTOCStyleEntries[ rightindent=10em, pagenumberbox=\pagenumberbox ]{tocline}{section,subsection,subsubsection,paragraph,subparagraph,figure,table} \newcommand*\pagenumberbox[1]{\mbox{\hspace{1em}#1}} \begin{document} \tableofcontents \addtocontents{toc}{\sloppy}% <- added \pagenumbering{Roman} \setcounter{page}{12340} \section{Some big page numbers} \subsection{Something} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this} \subsection{Some possibly very long title section that might just decide to span several lines in the table of contents. Why would someone write this, but a line break fixes it} \end{document} 

enter image description here

1
  • sloppy gives a nicer finish I think. Commented Mar 4, 2020 at 12:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.