[Tex/LaTex] Introduction as “chapter 0”

chapterssectioningtable of contents

I've been looking for an aswer to this, but the keywords I can think about lead me to anwers that are related but opposite to what I need. I'm trying to achieve something like this:

enter image description here

that is, I want the introduction to have a title, and to have the word "Introduction" where usually you find "Chapter n" (that is exactly what is removed if I use \chapter*).

I can control the counter so that the following one will be Chapter 1 as needed, and I can temporarily rename the header with \renewcommand{\chaptername}{Introduction}, but what I get is "Introduction 0", how can I get rid off that "0"? Of course I want a coherent appearance in the TOC, as here:

enter image description here

How can I accomplish this? I'd like a solution that works as independently as possible from the document class I'm in, but in case I'd say I need it in "book" or in "octavo".

Thank you very much!


A working example could be this, but actually it's not working, it does the wrong thing as I have described! I'd need some code that outputs like the images I posted!

\documentclass[11pt,twoside]{book}
\usepackage[a5paper,inner=14mm,outer=20mm,top=20mm,bottom=25mm]{geometry}


\begin{document}

\tableofcontents

\setcounter{chapter}{-1}
\renewcommand{\chaptername}{Introduction}
\chapter{A wonderful journey}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

\renewcommand{\chaptername}{Chapter}
\chapter{Let's go}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

\chapter{Keep going}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...

\end{document}

Best Answer

If you want to have "Introduzione" instead of "Capitolo 0" and also an additional heading, using standard class book you could redefine \@chapapp to "Introduzione" and \thechapter to an empty string before \chapter, e.g.:

\documentclass{book}

\usepackage[italian]{babel}% or english instead of italian for an English example
\usepackage{mwe}

\begin{document}
\chapter*{Prefazione}% or Preface instead of Prefazione for an English example
\addcontentsline{toc}{chapter}{Prefazione}% add ToC entry (see comment above to switch to English)
\lipsum

\tableofcontents

\setcounter{chapter}{-1}% the introduction will be chapter 0
\renewcommand*{\thechapter}{}% Get rid of the page number
\makeatletter
\renewcommand*{\@chapapp}{Introduzione}% replace "Chapter" (or "Appendix") by "Introdutione" (use "Introduction" instead of "Introduzione" for an English example)
\makeatother
\chapter{Un viaggio nella matematica}% or "A Trip to Math" in English
\lipsum

\renewcommand*{\thechapter}{\arabic{chapter}}% bring back the chapter numbers
\makeatletter\renewcommand*{\@chapapp}{\chaptername}\makeatother% and the chapter name
\blinddocument

\end{document}

This would be enough for the heading:

enter image description here

But not for the table of contents:

enter image description here

So you would need an additional package to change the ToC entries.


Using a KOMA-Script class you would be able to reconfigure not only the ToC entries but also to define a new chapter command only for the introduction:

\documentclass[chapterprefix]{scrbook}
\usepackage[italian]{babel}% or \usepackage[english]{babel} for English
\usepackage{mwe}

\DeclareNewSectionCommand[%
  style=chapter,% use chapter heading style for the new command
  level=0,% same level as chapter (could also use \chapternumdepth)
  pagestyle=plain,% use page style plain for the starting page like \chapter does
  % following options are only needed, if you are using scrbook before 3.24.2626
  % With KOMA-Script 3.24.2626 or newer you should remove the following 5 lines.
  beforeskip=\dimexpr\csname scr@chapter@beforeskip\endcsname,%
  innerskip=\dimexpr\csname scr@chapter@innerskip\endcsname,%
  afterskip=\dimexpr\csname scr@chapter@afterskip\endcsname,%
  prefixfont=\usekomafont{chapterprefix},%
  font=\usekomafont{chapter},%
  % following options are from tocbasic but with prefix `toc`:
  tocstyle=chapter,% use chapter entry style for the ToC entry
  tocindent=0pt,% do not indent the ToC entry
  tocnumwidth=8em,% enough for "Introduzione" or "Introduction"
  tocpagenumberbox=\underlinepagenumberbox% use a special kind of page number (see below)
  ]{introduction}

\RedeclareSectionCommand[%
  tocnumwidth=8em,% enough for "Capitolo" or "Chapter" + Number
  tocentrynumberformat=\chapapp\enskip,% add "Chapter" before the number of the ToC entry
  tocpagenumberbox=\underlinepagenumberbox
]{chapter}

\RedeclareSectionCommand[tocindent=0pt]{section}% don't indent section entries to the ToC
\RedeclareSectionCommand[tocindent=2.3em]{subsection}% not used in this example
\setcounter{tocdepth}{\sectiontocdepth}% show only chapter and section in ToC (like the image in the question)

\makeatletter
% The following command is used to print the page numbers of chapter
% and introduction entries to the ToC. It does not only format the
% page number but additionally add a rule below the entry.
\newcommand*{\underlinepagenumberbox}[1]{%
  \makebox[\@pnumwidth][r]{#1}% page number as usual
  \nobreak
  \makebox[0pt][r]{%
    \raisebox{-\dp\strutbox}[0pt][2\dp\strutbox]{\rule{\columnwidth}{.5pt}}}% rule
}
\makeatother

\setkomafont{chapterprefix}{\Large\mdseries}% make the prefix line of the headings less strong

\renewcommand*{\theintroduction}{Introduzione}% text instead of number (use "Introduction" for an English example)

\begin{document}
\addchap{Prefazione}% use "Preface" for an English example
\lipsum

\tableofcontents

\introduction{Un viaggio nella matematica}% or \introduction{Trip to Math} for an English example
\lipsum

\blinddocument
\end{document}

This would result in a ToC:

enter image description here

and an introduction:

enter image description here

Very similar to the images you've shown in your question. For all the commands, like \DeclareNewSectionCommand or \RedeclareSectionCommand see the English KOMA-Script manual or the German KOMA-Script manual. Note, some options (all with prefix toc) are inherited from the TOC style tocline of package tocbasic. The KOMA-Script manual has a chapter about tocbasic.


Here is one more example using other KOMA-Script commands to do almost the same but without the need of a new chapter command:

\documentclass[chapterprefix]{scrbook}
\usepackage[english]{babel}
\usepackage{mwe}

\makeatletter
% scrbook internally does not use \@chapapp directly but \chapapp
% So we can redefine it to change the result depending on whether counter
% chapter is 0 or -1 or (else) > 0:
\renewcommand*{\chapapp}{%
  \ifcase -\value{chapter}\relax
    \introductionname
  \or
    \prefacename
  \else
    \@chapapp
  \fi
}
% But \thechapter should output nothing, if counter chapter is <= 0
\renewcommand*{\thechapter}{%
  \ifnum \value{chapter}>\z@\arabic{chapter}\else\fi
}
% We do want to have \chapapp also before the number in the ToC entry.
% So we add it, if the first argument (this is the number argument) of
% \addchaptertocentry is not empty. If it is empty, we do not need to change
% anything:
\let\orig@addchaptertocentry\addchaptertocentry% Todo: better use letltxmacro
\renewcommand*{\addchaptertocentry}[2]{%
  \IfArgIsEmpty{#1}{\orig@addchaptertocentry{#1}{#2}}{%
    \orig@addchaptertocentry{\chapapp\nobreakspace#1}{#2}%
  }%
}
\makeatother
\newcommand*{\introductionname}{Introduction}% The new name for introduction

\RedeclareSectionCommand[%
  tocnumwidth=8em,% enough for "Chapter" + Number or "Introduction" or "Preface"
  tocpagenumberbox=\underlinepagenumberbox
]{chapter}

\RedeclareSectionCommand[tocindent=0pt]{section}% don't indent section entries to the ToC
\RedeclareSectionCommand[tocindent=2.3em]{subsection}% not used in this example
\setcounter{tocdepth}{\sectiontocdepth}% show only chapter and section in ToC (like the image in the question)

\makeatletter
% The following command is used to print the page numbers of chapter
% and introduction entries to the ToC. It does not only format the
% page number but additionally add a rule below the entry.
\newcommand*{\underlinepagenumberbox}[1]{%
  \makebox[\@pnumwidth][r]{#1}% page number as usual
  \nobreak
  \makebox[0pt][r]{%
    \raisebox{-\dp\strutbox}[0pt][2\dp\strutbox]{\rule{\columnwidth}{.5pt}}}% rule
}
\makeatother

\setkomafont{chapterprefix}{\Large\mdseries}% make the prefix line of the headings less strong

\begin{document}
\setcounter{chapter}{-2}% We start with a preface
\chapter{About how to do it a bit more complicate}
\lipsum

\tableofcontents

\chapter{Trip to math}
\lipsum

\blinddocument
\end{document}

This results in the following preface, table of contents, introduction and first chapter pages:

enter image description hereenter image description here

For this last example even KOMA-Script 3.22 would be enough.

Related Question