# Reference other chapters by chapter number without \label

In short, I need to recode the table of contents, as I intend to include a short intro or summary as to what the chapter is about and all. Of course, if a package is already constructed for this purpose, that would be great too.

\begin{enumerate}
\item \Nameref{<chapter-number>} \hfill \Pageref{<chapter-number>}
\end{enumerate}


However, I don't want to constantly keep labeling every chapter of the book to go back and update this over and over.

Is there any code for \Nameref and \Pageref commands above (which function similar to \nameref and \pageref but reference the chapter number directly)?

• I think you want something like tex.stackexchange.com/a/10189/1952 – Ignasi Jun 1 '17 at 13:55
• Depends on the class you use (you give no information), I'd simply add the intro directly into the toc from right after the appropriate \chapter cmd in your doc. For example, the memoir class has build in features to do this. If you're using another class, the memoir code can easily be copied. – daleif Jun 1 '17 at 14:38
• @daleif I was using a book class, but I think something like that could be changed. First time I heard of memoir. – Mad Maniac Jun 1 '17 at 18:07
• Look up \chaptertocprecis in the manual. It something presis. Memoir should be a drop in replacement for book, already contains the code from a lot of packages – daleif Jun 1 '17 at 18:14

A version with automatic label generation and a helpchapter associated counter. The \label is injected after \refstepcounter{chapter} and is prefixed with helpchapter:

The macro \DisplayEnumTocLine{Foo} uses enumi as counter and retracts the name and page reference as \nameref{helpchapter:\number\value{enumi}} etc. The content of the mandatory argument is displayed as description text.

The starred version of \DisplayEnumTocLine does not generate hyperlinks for the name and page references, the example shows usages of both versions.

(Note: The xassoccnt package is not really necessary here, but it simplifies the automatic stepping of helpchapter here).

\documentclass{book}

\usepackage{enumitem}
\usepackage{xassoccnt}

\newcounter{helpchapter}
\DeclareAssociatedCounters{chapter}{helpchapter}

\usepackage{xpatch}

\makeatletter
\xpatchcmd{\@chapter}{%
\refstepcounter{chapter}%
}{%
\refstepcounter{chapter}%
\label{helpchapter:\number\value{helpchapter}}%
}{}{}

\NewDocumentCommand{\DisplayEnumTocLine}{sO{helpchapter:}+m}{%
\IfBooleanTF{#1}{%
\nameref*{#2\number\value{enumi}} \hfill  \pageref*{#2\number\value{enumi}}%
}{%
\nameref{#2\number\value{enumi}} \hfill  \pageref{#2\number\value{enumi}}%
}%

#3%
}

\makeatother

\usepackage{hyperref}

\usepackage{blindtext}

\begin{document}

\begin{enumerate}
\item \DisplayEnumTocLine{A foo chapter}
\item \DisplayEnumTocLine*{\blindtext}
\end{enumerate}

\chapter{Foo chapter}

\chapter{Other chapter}

\end{document}


\documentclass{book}

}
\makeatletter
\newcommand{\l@chapterinfo}[2]{%
\begingroup
\leftskip 1.5em% same as \l@chapter uses
\noindent #1\par
\endgroup
}
\makeatother

\usepackage{mwe}

\begin{document}
\tableofcontents
\chapter{First Chapter}

If you don't like the section entries in the ToC, use \setcounter{tocdepth}{0}. This will result in: