1

So, a bit ago I asked a question regarding a specific format for my sections, which worked out great.

However, when I create my table of contents, it lists each section like this : (without the ellipses though, I didn't know how to right align the pg numbers)

1 FIRST SECTION TITLE ............................... 1

FIRST SECTION TITLE .................................. 1

2 SECOND SECTION TITLE ........................... 3

SECOND SECTION TITLE ...............................4

And so on.

I also notice that the second section is listed on page 3 the first time, and page 4 the second time... In the actual document, the second section begins at the top of page 4 (I set each section to begin on a new page).

Basically, I'm wondering how to get rid of redundant tableofcontents entries. I want the name to include the number, but I also want it to be the right page number...

Also I need dotted lines between the section titles as well, not just subsections, although that's probably a much easier fix that I can google later.

4

Your problem is \clearpage in \titleformat. Get rid of it. You can issue \clearpage before each section using etoolbox and its \preto macro. To put dotted lines, use titletoc.

\documentclass{article}
\usepackage{titlesec}
\usepackage{titletoc}
\titleformat{\section}[display]%
{\sffamily\Large\bfseries\filcenter}{CHAPTER \thesection}{1em}{}[]
\titlespacing*{\section}{0pt}{1em}{2cm}

\titlecontents{section}
[1.5em] % ie, 1.5em (chapter) + 2.3em
{}
{\contentslabel{1.5em}}
{\hspace*{-1.5em}}
{\titlerule*[0.5pc]{.}\contentspage}

\usepackage{etoolbox}
\preto\section{\clearpage}

\begin{document}
\tableofcontents

\section{SECTION TITLE GOES RIGHT HERE}
bla bla
\section{SECTION TITLE GOES RIGHT HERE}
bla bla

\end{document}
  • Worked great, thank you! Can I ask why this is an issue though? Just something from experience or what? – Conor Sep 19 '15 at 19:49
  • @Conor It is logic. You start the section, without typesetting anything issue a \clearpage and then typeset the section. So section starts in one page and ends in the other page. You have to pass \clearpage before starting the section to keep the section intact at one place. – user11232 Sep 19 '15 at 22:59

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.