0

How can I add an unnumbered \chapter (\chapter*) or \section (\section*) that is also included in the table of contents (TOC) and the PDF bookmarks? Ideally, for the standard classes and Koma classes.

  • This question is obviously a duplicate, see here for example.
  • But I just helped a smart friend with his Ph.D. thesis and he had a hard time solving the question (finding the right answers).
  • Therefore, I try to provide here a clearer and more complete question and answer so that future LaTeX users find the solution easier.

Not Working Example

\documentclass{article}

\usepackage{hyperref} % or bookmark

\begin{document} \tableofcontents

\section*{Thanks} Text.

\section{Introduction} Text.

\end{document}

enter image description here

1 Answers1

0

Please leave a comment or edit the answer if I made a mistake or do not follow best practices.

Solution for article Class

Thanks, @UlrikeFischer for the hint.

\documentclass{article}

% Small pages for demo purposes. \usepackage[a6paper]{geometry} \usepackage{blindtext}

% "bookmarksnumbered" is optional: It adds the heading number to the bookmark. \usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package

\begin{document}

\tableofcontents

% Start % --- --- \setcounter{secnumdepth}{-1} \section{Thanks} % <-- Replace "Thanks" with your heading title. \sectionmark{Thanks} % <-- Replace "Thanks" with your heading title. \setcounter{secnumdepth}{2} % --- --- % End

\blindtext

\section{Introduction} \subsection{SubSection} \blindtext

\end{document}

enter image description here

Solution for book or report Class

Thanks, @UlrikeFischer for the hint.

\documentclass{book} % or "report"

% Small pages for demo purposes. \usepackage[a6paper]{geometry} \usepackage{blindtext}

% "bookmarksnumbered" is optional: It adds the heading number to the bookmark. \usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package

\begin{document}

\tableofcontents

% Start % --- --- \setcounter{secnumdepth}{-1} \chapter{Thanks} % <-- Replace "Thanks" with your heading title. \chaptermark{Thanks} % <-- Replace "Thanks" with your heading title. \setcounter{secnumdepth}{2} % --- --- % End

\blindtext

\chapter{Introduction} \section{Section} \blindtext

\end{document}

enter image description here

Solution for scrartcl KOMA Class

\documentclass{scrartcl}

% Small pages for demo purposes. \usepackage[a6paper]{geometry} \usepackage{blindtext}

% "bookmarksnumbered" is optional: It adds the heading number to the bookmark. \usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package

\begin{document} \tableofcontents

% Start % --- --- \addsec{Thanks} % <-- Replace "Thanks" with your heading title. % --- --- % End

\blindtext

\section{Introduction} \subsection{SubSection} \blindtext

\end{document}

enter image description here

Solution for scrbook or scrreport KOMA Class

\documentclass{scrbook} % or "scrreport"

% Small pages for demo purposes. \usepackage[a6paper]{geometry} \usepackage{blindtext}

% "bookmarksnumbered" is optional: It adds the heading number to the bookmark. \usepackage[bookmarksnumbered]{hyperref} % or "bookmark" package

\begin{document} \tableofcontents

% Start % --- --- \addchap{Thanks} % <-- Replace "Thanks" with your heading title. % --- --- % End

\blindtext

\chapter{Introduction} \section{Section} \blindtext

\end{document}

enter image description here

  • 1
    I would use a numbered section and set the secnumdepth counter to -1 – Ulrike Fischer Apr 08 '22 at 19:34
  • @UlrikeFischer Thanks! I added the Alternative Solution. Your proposal seems to cover more side effects with less effort, right? – Dr. Manuel Kuehner Apr 08 '22 at 20:08
  • 1
    I wouldn't plant \markboth everywhere. If the default behaviour of section doesn't do what you want, redefine \sectionmark. – Ulrike Fischer Apr 08 '22 at 20:08
  • @UlrikeFischer Thanks again, I updated the two alternatives (nit sure if this is correct though). Going offline now (lunch break). Would you say that I should delete the previous solutions for the article class and the book class? – Dr. Manuel Kuehner Apr 08 '22 at 20:39