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?


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:



  • /doublefacepalm... – DevSolar Aug 9 '11 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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