1

My problem is this one: I'm creating a LaTeX template for reports, my goal is to make a .tex file that is the simplest possible. I use a .cls file, where I'd like to redefine \chapter* (and so on), but not \chapter. I didn't find a way to do this precisely, so I ask my question here.

What I want to do is, to keep the \chapter*, \section* and \subsection* in the Table of Contents, plus keeping the \chapter* name in the headings.

For now, each time I want to call

\chapter*{A random Chapter}

I have to call

\chapter*{A random Chapter}\addcontentsline{toc}{chapter}
{A random Chapter}\markboth{A random Chapter}{A random Chapter}

Which is not really convenient, in the sight of a template.

Does anyone what's the best solution to redefine them in a separate .cls file?

Thank you for your help!

PS: I'm quite new in LaTeX, I didn't know what tags to put on that topic, but I can add them by editing this post as soon as I know :)

  • 2
    With scrbook (or any KOMA-Script class) you have \addchap{..} which does exactly what you want. – Manuel Jun 19 '15 at 9:47
  • Or use a very buggy package that tries to implement a bit of KOMA-functionality for the standard classes unnumeredtotoc. – Johannes_B Jun 19 '15 at 9:49
  • You should show us the .cls file first. Most likely it's an offspring of book or something like that. Either use unnumberedtotoc or xpatch to patch the starred commands. – user31729 Jun 19 '15 at 9:51
  • 1
    The titlesec package and its siblings titletoc and titleps packages can do that easily, since it defines a numberless key for formatting/spacing section-like structures. – Bernard Jun 19 '15 at 11:00
  • Is your class based on one of the standard ones (book, report)? – Gonzalo Medina Jun 19 '15 at 13:57
1

One simple way to suppress numbering globally is issuing:

\setcounter{secnumdepth}{0}

In that case you can just use the unstarred versions, they would be unnumbered but appear in the toc.

For more advanced configurations I would advise you to use the titlesec package.

  • This would suppress all numbers, wouldn't it? – user31729 Jun 19 '15 at 9:53
  • Yes it would, but from the question it was not clear if he needed both numbered and unnumbered versions. I nevertheless thought the secnumdepth thing could be useful to know – Bordaigorl Jun 19 '15 at 17:18
  • It is, in fact. And you're right. As long there is not more information, it's justified to assume that no sectioning numbers should be shown at all – user31729 Jun 19 '15 at 22:23

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.