2

This question is a follow-up of this other question, where I asked how to add an additional ToC in a document showing only some selected sections (a "fast track ToC"). Based on Robert's answer, I got these two ToCs:

Normal Toc + Fast track ToC

Which is awesome. However, I realised that the names of the sections do not make clear to which chapter they belong. Is it possible to make the fastrack ToC look similar to the normal ToC (same/similar formatting), showing the Chapter (without page number if possible) before the fast track sections? Something like this would be awesome:

Fast track ToC with Chapter names (without chapter page number)

I don't really understand the code for the fastrack ToC, but by analogy I managed to include the chapters in it. However, I cannot control how it looks, the indentation and make it not sow the page number.

Here the code so far:

\documentclass[11pt, a4paper, oneside]{report}
\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{hyperref}
\usepackage{tocloft}

\newlistof[chapter]{fasttrack}{ftk}{Fast track contents} % Define the list of fast... 

\newcommand{\fasttracksection}[1]{% This is the special section 
  \section{#1}
  \addcontentsline{ftk}{fasttrack}{\protect\numberline{\thefasttrack}\quad #1}}
  
\newcommand{\fasttrackchapter}[1]{% This is the special section 
  \chapter{#1}
  \addcontentsline{ftk}{fasttrack}{\protect\numberline{\thefasttrack}\quad #1}}

\renewcommand{\thefasttrack}{\thesection}


\begin{document}

\tableofcontents

\listoffasttrack

  \fasttrackchapter{This is Chapter1} 
    \fasttracksection{This is Section1.1} % Fast track
    \fasttracksection{This is Section1.2} % Fast track
    \fasttracksection{This is Section1.3} % Fast track

  \fasttrackchapter{This is Chapter2}
    \section{This is Section2.1}
    \fasttracksection{This is Section2.3} % Fast track
    \section{This is Section2.3}

  \fasttrackchapter{This is Chapter3}
    \section{This is Section3.1}
    \fasttracksection{This is Section3.2} % Fast track
    \section{This is Section3.3}


\end{document}
2
  • 1
    Perhaps you need is to use the command \addtocontents instead of \addcontentsline: try "\addtocontents{ftk}{#1}" (or "\addtocontents{ftk}{\thechapter~#1}", if you want to print the chapter number) instead of "\addcontentsline{ftk}{fasttrack}{\protect\numberline{\thefasttrack}\quad #1}" Commented Jun 15, 2020 at 7:09
  • Awesome! With your advise and what I'm sure is very bad code I achieved the layout I wanted! (at least in the example, let's see how it looks afterwards in my document) Thanks :-)
    – Miquel
    Commented Jun 15, 2020 at 13:52

1 Answer 1

1

With the comment from Robert (thanks!) and a little of messing around I could make the layout as intended. I'm sure is very bad coding, but may help somebody:

\documentclass[11pt, a4paper, oneside]{report}

\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{tocloft} \newlistof[chapter]{fasttrack}{ftk}{Fast track contents} % Define the list of fast... 

\newcommand{\fasttracksection}[1]{% This is the special section
\section{#1}
\addcontentsline{ftk}{fasttrack}{\protect\numberline{~\quad\thefasttrack}~\quad~#1}}

\newcommand{\fasttrackchapter}[1]{% This is the special chapter
\chapter{#1}
\addtocontents{ftk}{\bigskip\textbf{\thechapter~~#1}}}

\renewcommand{\thefasttrack}{\thesection}


\begin{document}

\tableofcontents

\listoffasttrack


  \fasttrackchapter{This is Chapter1} 
    \fasttracksection{This is Section1.1} % Fast track
    \fasttracksection{This is Section1.2} % Fast track
    \fasttracksection{This is Section1.3} % Fast track

  \fasttrackchapter{This is Chapter2}
    \section{This is Section2.1}
    \fasttracksection{This is Section2.3} % Fast track
    \section{This is Section2.3}

  \fasttrackchapter{This is Chapter3}
    \section{This is Section3.1}
    \fasttracksection{This is Section3.2} % Fast track
    \section{This is Section3.3}


\end{document}

The final result is as follows:

Normal ToC + Fast track ToC


Edit: I managed to add a command to include subsections in the fast track ToC (although it gives a warning which I don't understand 'LaTeX Error: Command \thefasttracksub undefined'):

\documentclass[11pt, a4paper, oneside]{report}

\usepackage[left=4cm,right=2cm,top=2.5cm,bottom=2.5cm]{geometry}
\usepackage{hyperref}

\usepackage{tocloft}
\newlistof[chapter]{fasttrack}{ftk}{Fast track contents} % Define the list of fast... 

\newcommand{\fasttracksection}[1]{% This is the special section 
  \section{#1}
  \addcontentsline{ftk}{fasttrack}{\protect\numberline{~\quad\thefasttrack}~\quad ~#1}}
  
\newcommand{\fasttrackchapter}[1]{% This is the special section 
  \chapter{#1}
\numberline{\thefasttrack}\quad #1}}
  \addtocontents{ftk}{\bigskip\textbf{\thechapter~~#1}}}
  
  \newcommand{\fasttracksubsection}[1]{% This is the special section 
  \subsection{#1}
  \addcontentsline{ftk}{fasttrack}{\protect\numberline{~\quad~\quad\thefasttracksub}\quad\quad\quad~~#1}}


\renewcommand{\thefasttracksub}{\thesubsection}
\renewcommand{\thefasttrack}{\thesection}



\begin{document}

\tableofcontents

\listoffasttrack


  \fasttrackchapter{This is Chapter1} 
    \fasttracksection{This is Section1.1} % Fast track
    \subsection{This is Subsection1.1.1}
    \fasttracksection{This is Section1.2} % Fast track
    \fasttracksection{This is Section1.3} % Fast track

  \fasttrackchapter{This is Chapter2}
    \section{This is Section2.1}
    \fasttracksection{This is Section2.3} % Fast track
    \fasttracksubsection{This is Subsection2.3.1} % Fast track
    \section{This is Section2.3}

  \fasttrackchapter{This is Chapter3}
    \section{This is Section3.1}
    \fasttracksection{This is Section3.2} % Fast track
    \section{This is Section3.3}


\end{document}

And here is the outcome:

Example with Fast Track subsections

1
  • One problem with this answer is that Texmaker (and I guess this will be the case with other Latex editors) don't show the Fast track sections in the structure of the document, which makes it a bit tedious to navigate the document. Therefore, it is advisable that adding the fast track contents is the last thing one does to the document.
    – Miquel
    Commented Jul 3, 2020 at 8:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .