0

I have a document structured like

\documentclass{memoir}
\usepackage{graphics}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\includegraphics{a_map.jpg}

[...]

\chapter{Chapter 2}

[...]

\chapter{Maps}

\includegraphics{b_map.jpg}
\addcontentsline{toc}{section}{Map B}
\newpage
\includegraphics{c_map.jpg}
\addcontentsline{toc}{section}{Map C}
\end{document}

I would like to include a table to contents entry for map A, which is an image file located in Chapter 1. However, I would like to include the entry as a section under the "Maps" chapter-level entry in the TOC. In other words, I want a TOC that looks like

Chapter 1 ................ 3
    Section 1.1........... 2
    Section 1.2........... 4
Chapter 2 ................ 5
Maps ..................... 7
   Map A ................. 3
   Map B ................. 7
   Map C ................. 8

Are there any suggestions how this could be achieved?

  • There are no \chapter with article!? – Johannes_B May 12 '18 at 14:03
  • You can just insert the \addcontentsline where you want it to appear. – Johannes_B May 12 '18 at 14:04
  • @Johannes_B you're right, it was me being too fast putting the MWE together. – Ubiquitous May 12 '18 at 14:04
  • 1
    It is not an MWE if you didn't test it and it doesn't work. ;-) – Johannes_B May 12 '18 at 14:05
  • @Johannes_B but if I put the \addcontentsline command at the start of the maps chapter then the page number will be wrong, because the map is on p3. – Ubiquitous May 12 '18 at 14:08
2

\addcontentsline is

\def\addcontentsline#1#2#3{%
  \addtocontents{#1}{\protect\contentsline{#2}{#3}{\thepage}}}

so as you want to fake the page number use

\addtocontents{toc}{\protect\contentsline{section}{Map A}{3}
\addcontentsline{toc}{section}{Map B}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.