117

I'm using the report document class for a thesis, and I need to add things like "Acknowledgements" and an "Introduction". I noticed that there is an \abstract command which would have been wonderful if applied similarly. How do I add these without messing up the chapters' numbering while being picked up by the ToC in proper order and page numbering?

  • 1
    Are you really using \documentstyle? That's LaTeX2.09 (pre-1994) syntax. – Joseph Wright Nov 19 '11 at 22:56
  • @JosephWright: Without even thinking, I modified "documentstyle" to "document style" in the post. Not sure how intentional this was from the OP. – Werner Nov 19 '11 at 22:59
  • 2
    For unnumbered chapters, you could just use \chapter*{Acknowledgements} and \chapter*{Introduction}. These chapter will be formatted similarly to \chapter, without the number and not show up in the ToC. Subsequent chapters will be numbered 1, 2, ... Is this what you're after? Or are you interested in have something look similar to \abstract from the article document class? Note that the report document class does not provide \abstract, only an abstract environment. – Werner Nov 19 '11 at 23:02
  • I know that this seems like a potentially big shift, but I recommend the book class over the report class. That way you get the handy \frontmatter, \mainmatter and \backmatter switches that handle this for you. Otherwise it's not a lot different from report. – qubyte Nov 20 '11 at 4:33
  • @Werner: I appologize; I meant the abstract environment indeed. Yes it would be nice to have something like that for introductions and acknowledgements. – Ayman Elmasry Nov 22 '11 at 0:17
140

To get unnumbered chapters, parts, sections, subsections, etc, you just affix a * (asterisk) to the respective sectioning command; hence, you'd type something like

\section*{Acknowledgments} 

or

\chapter*{Introduction}

Exactly which sectioning command you ought to use will depend importantly on aspects of the document that you haven't told us about. E.g., should the respective parts begin on a page of their own, and how prominent do you want the caption of the sectioning command to be?

Note that unnumbered parts, chapters, sections, etc are not included automatically in the table of contents (ToC). In case you need some (or all) of them to be included, you should insert an \addcontentsline instruction after each such sectioning command. For example, you'd type:

\chapter*{Foreword} 
\addcontentsline{toc}{chapter}{Foreword}

The second argument of the \addcontentsline instruction -- here, chapter -- instructs LaTeX to typeset the entry in a given style, here, "chapter style".

The following MWE

\documentclass{report}
\begin{document}
\tableofcontents
\chapter*{Acknowledgments}
\addcontentsline{toc}{chapter}{Acknowledgments}
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\chapter{Experiments}
\chapter{Conclusion}
\end{document}

generates this ToC:

enter image description here

  • 1
    That's wrong. :) A \chapter command in the \frontmatter produces by itself an unnumbered chapter which goes in the ToC. The OP uses report, it seems, so no \frontmatter and \mainmatter. – egreg Nov 19 '11 at 23:46
  • I had missed the fact that the OP was using the report rather than the book document class. I've updated my MWE. – Mico Nov 20 '11 at 0:00
  • If the book class is really better, I suppose I should give it a try, but I would need the support for such an endeavour, probably post a new thread to see if it is more fitting for a thesis. I really don't have time to experiment, I couldn't even check my own post (this one) for 2 days. – Ayman Elmasry Nov 22 '11 at 0:38
  • 1
    in \addcontentsline{toc}{chapter}{Acknowledgments} what does {toc} do? – snoram Sep 10 '16 at 19:20
  • 3
    @snoram - The option toc tells LaTeX to write the output to \jobname.toc, where \jobname is set to the name of your main tex file. Other options are lot (to write to \jobname.lot, for the "List of Tables", generated by \listoftables) and lof (to write to \jobname.lof, for the "List of Figures", generated by \listoffigures. (Note, though, that the sample document features a \tableofcontents instruction but no \listoftables or \listoffigures instructions.) – Mico Sep 10 '16 at 19:41
32

Besides adding unnumbered chapters/sections to the ToC, you may also want to ensure that they are correctly displayed in the header/footer. In the report and book class this may be done by writing, e.g.,

\chapter*{Introduction}
\markboth{Introduction}{Introduction}

for unnumbered chapters (the second argument of \markboth controls "right" [odd] pages in twoside documents; it may also be left empty) and

\section*{Introduction}
\markright{Introduction}

for unnumbered sections. (Should you have enabled headers in the article class, use \markboth in conjunction with \section* and \markright in conjunction with \subsection*.)

Note that the above code snippets will produce non-capitalized names in the header; should you want to capitalize them (as for numbered chapters in the standard classes), replace Introduction with \MakeUppercase{Introduction}.

Addendum: Both Mico's and my answer refer to the standard document classes (article, book, report). The answers should work for most other classes; however, some classes may offer easier solutions. E.g., with the KOMA-Script classes you may simply use the commands \addchap/\addsec to create unnumbered chapters/sections that will be displayed in the ToC and the header.

  • wow - literally took a couple dozen answer-trials till i found this one. amazing - thanks! – trdavidson Aug 25 at 15:09
3

A little package on github that might never hit CTAN can be of help here.

It takes care of the entries and the headings automatically.

\documentclass{book}
\usepackage{blindtext}
\usepackage[
    %   indentunnumbered
]{unnumberedtotoc} %get it from https://github.com/johannesbottcher/unnumberedtotoc
\usepackage{hyperref}

\begin{document}
\tableofcontents

\addchap{unnumbered chapter with toc and head}
\blindtext[10]

\addchap[title for toc and head]{chapter title}
\blindtext[10]
\addsec*{starred addsec}
\blindtext[10]
\addsec{regular addsec}
\blindtext[10]
\addsec*{starred addsec}
\blindtext[10]
\chapter{usual chapter}
\blindtext[10]
\chapter*{look at the header}
\blindtext[10]
\addchap*{really nothing, header cleared}
\blindtext[10]
\end{document}
  • Any reason why you haven't contributed this to CTAN? – Chris Charabaruk Mar 28 '18 at 20:08
  • @ChrisCharabaruk Because it is not ready yet. – Johannes_B Mar 30 '18 at 6:04

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.
https://tex.stackexchange.com/questions/35433/creating-unnumbered-chapters-sections-plus-adding-them-to-the-toc-and-or-header
tex.stackexchange.com
crawl=CC-MAIN-2019-43
173062
application/http; msgtype=response
sha1:QGUGD45C7YHVVCEXGBDZZT5PZJ36TQOH
<urn:uuid:7844cb8d-6f48-4e83-a916-38f0487c2143>
2019-10-15T08:06:16Z
151.101.1.69
text/html
sha1:37KO6SNKUVBXGHD6NROGEQ4VKIEQZY3G
<urn:uuid:8375cdf2-2cc2-4381-a2ab-d64116212f80>
https://tex.stackexchange.com/questions/35433/creating-unnumbered-chapters-sections-plus-adding-them-to-the-toc-and-or-header
response
<urn:uuid:0815a436-0f20-41c0-8097-2cfc8185feb0>
isPartOf: CC-MAIN-2019-43
publisher: Common Crawl
description: Wide crawl of the web for October 2019
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-81.ec2.internal
software: Apache Nutch 1.16 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.1-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: http://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/