TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I right-align the section/subsection/.. number in the ToC? The distance between the number and the heading should be fixed.

Instead of

|  1     Section
|        1.1      Subsection

I'd like to have something like

|      1 Section
|             1.1 Subsection

(|= left margin)

There must be a package for that...

(And I'd like to play with the indentation as well)

share|improve this question
you might want to think about this a bit more. while i agree with the concept in general, when section numbers are formatted as "chapter.section" and section goes to two digits, to me it looks a bit nicer with the compound number aligned on the decimal point. (of course, there's really no hope for a three-part subsection number with segments numbered 10 or greater.) – barbara beeton Aug 17 '12 at 12:54
@barbarabeeton I have thought about it for quite some time and for my case the best solution is to have the numbers right aligned and only a little bit of indentation to the next sublevel :) I have very, very, very long section numbers. The default is just not feasible. – topskip Aug 17 '12 at 13:10
up vote 10 down vote accepted

\numberline could be redefined:


  \hb@xt@\@tempdima{\hfil#1 }%



Table of contents with right aligned numbers

share|improve this answer
See also tocloft package, page 11. It offers facilities to play with the indentation. – Guido Aug 17 '12 at 12:54
Thanks Heiko for the perfect solution. I should read latex.ltx more often. – topskip Aug 17 '12 at 13:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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