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

