1

I am trying to add a preface section to the table of contents, by using

  \addcontentsline{toc}{chapter}{Preface}

This partially works. the preface is added, but without the page number for it (in roman letters, it should be, because it is in the frontmatter section).

In addition, the Preface line (which doesn't appear with a page number) is not aligned with the rest of the text for the chapters, since I use chapter* for it, and therefore, there is no number before it.

So it appears as:

      Preface
      1 Introduction

instead of

        Preface
      1 Introduction

When I look into the .toc file, I see:

     \contentsline {chapter}{Preface}{x}{chapter*.1}
     \contentsline {chapter}{\numberline {1}{Introduction}}{1}{chapter.1}

so obviously I can hack it to add a line number, I guess, but I would like to avoid it. I am not sure how to fix the alignment problem, though, through the .toc file (though, again, I wouldn't want to touch the .toc files).

  • 1
    The solution to your problem is relevant to the documentclass in use. Without this information, best in form of a minimal working example, everything will be just guesswork. – Johannes_B Nov 4 '14 at 15:13
  • Touching the .toc files is useless as they are regenerated during any compilation run, unless \nofiles is used. – user31729 Nov 4 '14 at 15:21
  • 2
    If using a KOMA class, you can save yourself a lot of trouble: How to use unnumbered chapters with KOMA-script? – Johannes_B Nov 4 '14 at 16:02
4

Just a wild guess, but you could use package unnumberedtotoc with option indentunnumbered found in https://tex.stackexchange.com/a/199086/37907.

As you didn't provide any useful code, this is just guesswork.

\documentclass{book}
\usepackage{blindtext}
\usepackage[indentunnumbered]{unnumberedtotoc}

\begin{document}
\tableofcontents

\addchap{Preface}
\blindtext[13]
\chapter{Introduction}
\blindtext[13]
\end{document}

enter image description here

| improve this answer | |

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.