## LaTeX forum ⇒ Page Layout ⇒ "Section 1" instead of "1 Section"

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
sveioen
Posts: 28
Joined: Tue Mar 06, 2007 1:04 am

### "Section 1" instead of "1 Section"

Hello all!

I was wondering if anybody know how to change to way sections/subsections etc. are being numbered. I would like to make LaTeX format, say, "\section{Stuff}" into "Stuff 1" instead of "1 Stuff".

Thank you!

corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm
You could have a look at the titlesec package, you are able to change the label format, but I guess with this package you won´t be able to change the order between label (2.1 for example) and title.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
Using titlesec (as suggested by corderin) does allow to achieve the desired result. Take a look at the following example:
\documentclass{book}\usepackage[nobottomtitles*]{titlesec}\usepackage{ifthen}\usepackage{lipsum}% just to generate some text \titleformat{\section}[runin]   {\normalfont\Large\bfseries}   {}{0pt}{}%   [\ifthenelse{\equal{\thesection}{0}}{\\\vspace*{0pt}}{\space\thesection\\}] \titlespacing{\section}   {0pt}{*2}{0pt} \begin{document}\tableofcontents \chapter{Dummy chapter}\section{A test section}\lipsum[1-2]\section{Another test section}\lipsum[1-2] \end{document}

Remark: use with caution; this solution is highly volatile
1,1,2,3,5,8,13,21,34,55,89,144,233,...

sveioen
Posts: 28
Joined: Tue Mar 06, 2007 1:04 am
Thank you so much for the example, gmedina. This is just what I've been looking for!

corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm
The only problem I have found with this wonderful code of gmedina are the TOC entries, I have been trying to get the same line as for the section titles using the titletoc package, but it seems a bit difficult.

Maybe gmedina can achieve solve that matter too!

With titletoc you can put some code after the TOC entry, but I have seen it puts this code just rigth after the whole entry, this is, after the page...

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm
corderin wrote:The only problem I have found with this wonderful code of gmedina are the TOC entries, I have been trying to get the same line as for the section titles using the titletoc package, but it seems a bit difficult.

Maybe gmedina can achieve solve that matter too!...

A possible solution using titletoc:
\documentclass{book}\usepackage[nobottomtitles*]{titlesec}\usepackage{titletoc}\usepackage{ifthen}\usepackage{lipsum}% just to generate some text \titleformat{\section}[runin]   {\normalfont\Large\bfseries}   {}{0pt}{}%   [\ifthenelse{\equal{\thesection}{0}}{\\\vspace*{0pt}}{\space\thesection\\}] \titlespacing{\section}   {0pt}{*2}{0pt} \titlecontents{section}   [1.5em]   {}{}   {\hspace*{-2.3em}}   {\space\contentslabel{0pt}\hfill\contentspage} \begin{document}\tableofcontents \chapter{Dummy chapter}\section{A test section}\lipsum[1-4]\section{Another test section}\lipsum[1-2] \end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...

corderin
Posts: 77
Joined: Sun Dec 14, 2008 2:27 pm
Gmedina I have been a time trying to solve this and I couldn´t, the result is achieved, and modifiying the last line as follows you get the separation dots between title and page in the TOC!

\titlecontents{section}   [1.5em]   {}{}   {\hspace*{-2.3em}}   {\space\contentslabel{0pt}\titlerule*[1pc]{.}\contentspage}