[Tex/LaTex] Alignment of page numbers in table of contents

bidihorizontal alignmentright-to-lefttable of contentstypography

Consider the following example:

\documentclass[a4paper,12pt]{article}
\begin{document}
\tableofcontents
\newpage
\section{test}
\newpage
\setcounter{page}{22}
\section{introduction}
\newpage
\setcounter{page}{222}
\section{discussion}
\end{document}

which produces:

enter image description here

As you can see the page numbers are aligned so that ones are written under ones, tens are written under tens, etc. Was this alignment the aim of LaTeX or LaTeX aim was simply to put page numbers at the end of each line?

In other words, if this document was RTL, which of the followings would be the correct alignment of page numbers?

enter image description here

enter image description here

Best Answer

In my opinion, the alignment of the numbers has nothing to do with the direction of the text.

Whether you write in english (LTR) or arabic (RTL), you should always align numbers on their right edge. The reason for this is that when using the hindu-arabic numeral system, you "sort of" write digits RTL: the smallest order of magnitude goes to the most right (the "ones"), with each following order of magnitude right on its left (the "tens", the "hundreds", etc.).
Given then that for readability consideration (the number one objective of typography) you should align digits that represent the same order of magnitude, you should align digits on their right edge in this / our numeral system.

If you were to use a numeral system that was "sort of" LTR, whatever the direction of the text, the logic would be to align the digits on their left edge.

Note that for the TOC in particular, you do not have to write the page numbers after their labels. Many books use styles that first write the page number followed by the label, as bellow:

TOC with page numbers before labels

but the page numbers would usually still be aligned on their right edge for readability (even if that degrades the page grid to some extent).

Related Question