3

Is it possible to have chapters, sections, etc. that appear in the ToC but not as actual headers in the document? Basically I just want tell the ToC "make a chapter mark here" but without making the actual chapter header. I would like to do that for my appendix in an internship report which consists of quite some NMR spectra.

\documentclass[11pt,a4paper]{scrreprt}

\begin{document}
\tableofcontents

\setcounter{chapter}{0}
\renewcommand{\thechapter}{\Alph{chapter}}
\chapter{Spectra}
\section{Compounds for Teaching Purposes}
\includepdf[angle=90]{./spectra/DHcompd197_1}
\end{document}

The ToC should look like here:

The ToC should look like here:

But I do not want the title here:

But I do not want the title here:

2
  • 1
    Take a look at addcontentsline and phantomsection.
    – leandriis
    Commented Mar 2, 2020 at 17:07
  • Did you try using an empty optional argument: \chapter[][Introduction} for instance?
    – Bernard
    Commented Mar 2, 2020 at 17:08

2 Answers 2

2

Issue

\cleardoublepage
\addcontentsline{toc}{chapter}{<chapter title>}% Add fake chapter to ToC
\includepdf[..]{...}

\cleardoublepage puts you on the correct (recto) page for a regular \chapter. You can do the same for \sections and other sectional units, for example

\addcontentsline{toc}{chapter}{\numberline{A}Spectra}
\addcontentsline{toc}{section}{\numberline{A.1}Compounds for Teaching Purposes}

If you're using hyperref as well, you'll need to add a \phantomsection before each use of an arbitrary \addcontentsline in order for the hyperlink to jump appropriately. More specifically,

\usepackage{hyperref}
...
\cleardoublepage
\phantomsection
\addcontentsline{toc}{chapter}{\numberline{A}Spectra}
\phantomsection
\addcontentsline{toc}{section}{\numberline{A.1}Compounds for Teaching Purposes}
0

With a KOMA-Script class I would use

\cleardoubleoddpage
\refstepcounter{chapter}
\addchaptertocentry{\thechapter}{<chapter title>}

Example:

\documentclass[
  %11pt,a4paper,% default
  numbers=enddot% <- added
]{scrreprt}
\usepackage{pdfpages}%<- added
\usepackage{hyperref}

\newcommand\chapteronlytocentry[1]{%
  \cleardoubleoddpage
  \refstepcounter{chapter}%
  \addchaptertocentry{\thechapter}{#1}%
}
\newcommand\sectiononlytocentry[1]{%
  \cleardoubleoddpage
  \refstepcounter{section}%
  \addsectiontocentry{\thesection}{#1}%
}

\begin{document}
\tableofcontents
\clearpage
See appendix \ref{sec:asec} (page \pageref{sec:asec}).

\appendix

\chapteronlytocentry{Spectra}
\sectiononlytocentry{Compounds for Teaching Purposes}
\includepdf[angle=90,pages=1,pagecommand={}]{dummy-l.pdf}

\sectiononlytocentry{Another Section}\label{sec:asec}%
\includepdf[angle=90,pages=2]{dummy-l.pdf}

\end{document}

Result:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .