Doc & example: Unnumbered chapter #7

Open
opened 2023-09-13 10:48:47 +00:00 by Ambroise · 0 comments
Owner

In memoir, any call of \chapter{...} in the \frontmatter or \backmatter, will result in an unnumbered chapter which will be automatically placed in the ToC with no alignment.

In the \mainmatter, the call to \chapter{...} will result in a numbered chapter. In order to create one that is not numbered, the starred version \chapter*{...} can be used.
However, this presents two problems:

  1. the header is not changed from the previous call to \chapter{...},
  2. no entry is created in the ToC for this chapter.

The solutions to these problems are as follows:

  1. the optional argument of the starred command should be used to repeat the chapter name, that is, using \chapter*[My chapter name]{My chapter name} instead of simply \chapter*{My chapter name};
  2. a manual entry in the ToC should be added after \chapter* by calling the command \addcontentsline{toc}{chapter}{My chapter name}.

Remark 1: In other to avoid having to modify all instances of the chapter's name in the commands above in the event of a later change in the name, a possibility is to create a label, say \label{mychaplabel}, placed after the command \chapter* and using it in the command adding the entry to the ToC with \addcontentsline{toc}{chapter}{\nameref{chap:intro}}

Remark 2: By default, the \addcontentsline{toc}{chapter}{...} command will place the name given in the ToC as a chapter sectioning aligned with the other unnumbered chapters of the \frontmatter. If one wishes to align it with the numbered chapters of the \mainmatter, the command \relax\numberline{} should be used in the \addcontentsline command in front of the name given to the chapter so that it will appear in the ToC with the the correct indent.

As a complete example, here is how to create an unnumbered chapter (in the main matter) called Introduction which will be listed in the ToC aligned with the numbered chapters.

\chapter*[Introduction]{Introduction}\label{chap:intro}
\addcontentsline{toc}{chapter}{\relax\numberline{}\nameref{chap:intro}} % add line in toc
In memoir, any call of `\chapter{...}` in the `\frontmatter` or `\backmatter`, will result in an unnumbered chapter which will be automatically placed in the ToC with no alignment. In the `\mainmatter`, the call to `\chapter{...}` will result in a numbered chapter. In order to create one that is not numbered, the starred version `\chapter*{...}` can be used. However, this presents two problems: 1. the header is not changed from the previous call to `\chapter{...}`, 2. no entry is created in the ToC for this chapter. The solutions to these problems are as follows: 1. the optional argument of the starred command should be used to repeat the chapter name, that is, using `\chapter*[My chapter name]{My chapter name}` instead of simply `\chapter*{My chapter name}`; 2. a manual entry in the ToC should be added after `\chapter*` by calling the command `\addcontentsline{toc}{chapter}{My chapter name}`. Remark 1: In other to avoid having to modify all instances of the chapter's name in the commands above in the event of a later change in the name, a possibility is to create a label, say `\label{mychaplabel}`, placed after the command `\chapter*` and using it in the command adding the entry to the ToC with `\addcontentsline{toc}{chapter}{\nameref{chap:intro}}` Remark 2: By default, the `\addcontentsline{toc}{chapter}{...}` command will place the name given in the ToC as a chapter sectioning aligned with the other unnumbered chapters of the `\frontmatter`. If one wishes to align it with the numbered chapters of the `\mainmatter`, the command `\relax\numberline{}` should be used in the `\addcontentsline` command in front of the name given to the chapter so that it will appear in the ToC with the the correct indent. As a complete example, here is how to create an unnumbered chapter (in the main matter) called `Introduction` which will be listed in the ToC aligned with the numbered chapters. ```latex \chapter*[Introduction]{Introduction}\label{chap:intro} \addcontentsline{toc}{chapter}{\relax\numberline{}\nameref{chap:intro}} % add line in toc ```
Ambroise added the
enhancement
doc
examples
labels 2023-09-13 10:48:47 +00:00
Sign in to join this conversation.
No description provided.