2

I have a section which I don't want to be numbered, but which I still want in the table of contents. So I have written

\addtotoc{section}{My section}
\section*{My section}

I have done the same thing for all the subsections in this section. The problem is just that the subsections end up at separate pages, creating a lot of empty space in my document. If I remove the \addtotoc macro then the problem disappears. The question is why \addtotoc automatically starts a new page and if this can be turned off?

  • Please edit your question and add a complete example that reproduces the problem. Without this it will be difficult for anyone to help you. – Ian Thompson Jul 5 '12 at 14:35
  • 3
    I've found \addtotoc in the ClemsonThesis class and it has a very bizarre definition. If you're using that class, I strongly suggest never using that command. – egreg Jul 5 '12 at 14:51
4

It's quite difficult to answer without any example and the indication of the used class. I guess it's ClemsonThesis, where the \addtotoc command is defined as

\newcommand{\addtotoc}[2]{
    \phantomsection
    \addcontentsline{toc}{chapter}{#1}
    #2 \clearpage
}

and the definition makes clear why a new page is started. It's quite difficult to understand what's the intended usage of this macro, but it's rather clear that it doesn't suit your needs.

If your sections are never numbered, you solve all problems by saying

\setcounter{secnumdepth}{0}

in your document preamble and then using \section{Section Title} without any other code.

An occasional unnumbered section can be treated by

\phantomsection
\section*{My section}
\addcontentsline{toc}{section}{My section}

You might want to define a special command:

\newcommand{\usection}[1]{%
  \phantomsection
  \section*{#1}
  \addcontentsline{toc}{section}{#1}
}
  • 2
    Ah, \addcontentsline was the command I really should have used! Thank you very much! :) – StrawberryFieldsForever Aug 13 '12 at 11:07

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.