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

I am having difficulty adding the section number after the section title. Normally the order is section number followed by section title. I want it to be the opposite. I am looking for what I should add to the following .tex file code:

share|improve this question

migrated from stackoverflow.com Oct 22 '11 at 4:11

This question came from our site for professional and enthusiast programmers.

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Werner Oct 22 '11 at 4:22

You need to use the explicit package option with titlesec. It enables you to "explicitly" state where the section title is printed using #1 to denote the title. In this case, we place the title code in the <before code> section of \titleformat:

enter image description here

\usepackage[compact,explicit]{titlesec}% http://ctan.org/pkg/titlesec
\section{First section}
\section{Second section}
\section{Last section}

The general structure of title formatting provided by titlesec is via


Since the <label> is no longer needed, it is explicitly inserted in <before-code> together with (after) the section title #1. I've placed \quad between the two components, but you can modify this to your like, using (say) \hspace{<len>} where <len> is any recognized (La)TeX length.

I kept your other settings for the sake of convenience since you didn't provide a complete MWE.

share|improve this answer
This is nice, but won't deal properly with \section*. – Raphael Apr 26 '12 at 10:23
I haven't found the option "explicit" in my titlesec in teTeX-2.0. – imz -- Ivan Zakharyaschev Jul 28 '13 at 21:05
@imz--IvanZakharyaschev: teTeX seems to not be supported anymore (last updated May 2006), and TUG suggests using TeX Live. Do so and you'll have more up-to-date packages. According to the titlesec CHANGELOG, the explicit option was added March 27, 2007. It may also be relevant to read How do I update my TeX distribution? – Werner Jul 29 '13 at 5:32
@Werner Thanks! yes, indeed, the version of the package in teTeX is too old. – imz -- Ivan Zakharyaschev Jul 29 '13 at 21:43

Your Answer


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