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

Having a problem somewhat akin to "How to put section number into the right side of section title in LaTeX" (and neither of the two answers there floating my boat), I was tinkering with titlesec, and came across an error message I cannot fathom.

Ignoring good looks of the example for the sake of brevity, this works:


\titleformat{\section}[hang]{}{\thesection}{0pt}{}{}   %% <--


(Yields "0.1Section".)

Switching the marked line to this also works:


(Yields "0.1Section".)

However, the following line does not work:


(Expected "Section0.1", but yields LaTeX Error, "Missing \begin{document}".)

Apparently the "after"-Field of \titleformat handles things differently. Why does this happen, and can it be avoided?

share|improve this question
up vote 8 down vote accepted

The "after" field is optionally specified in square brackets after the "before" field, not in curly braces. This is why this fails.

The proper syntax is thus:


which yields the expected result:



share|improve this answer
/doublefacepalm... – DevSolar Aug 9 '11 at 13:44

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.