0

I want some chapters to appear at the level and with the layout of a part in the TOC. The chapters should still be numbered with their chapter number (also in the TOC) and should look like chapters in the text (no title page).

A special case of this is the list of abbreviations. Currently, I use:

\usepackage[automake, abbreviations, acronym, nomain, section=part]{glossaries-extra}

With this the TOC looks like I want but in the text there is a title page (empty besides title) which I do not want.

For normal chapters I could use:

\addcontentsline{toc}{part}{Chapter 0}

This results in an entry in the TOC with the right layout but without the chapter number in front. However, the number of the chapter should be shown in the TOC.

Here is a MWE:

\documentclass[a4paper]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[hang,tight]{subfigure}
\usepackage[subfigure]{tocloft}
\usepackage[toc,automake, abbreviations, acronym, nomain, section=part]{glossaries-extra}
\usepackage{hyperref} 

\cftsetindents{chapter}{1em}{2.5em}
\cftsetindents{section}{2em}{3em}
\cftsetindents{subsection}{5em}{4.2em}
\cftsetindents{subsubsection}{9.2em}{7em}

\makeglossaries
\newabbreviation{test}{TEST}{test}

\begin{document}
        \tableofcontents
        \glsaddall
        \printabbreviations %should not generate a title page
\chapter{Chapter 0} %should look like Part 1
%\addcontentsline{toc}{part}{Chapter 0} %no number in front
\label{test0}
\part{Part 1}
\chapter{Chapter 1}
\label{test3}
\end{document}

UPDATE: I found this related question and modified the answer therein. So between \tableofcontents and glsaddall there is now:

    \makeatletter
    \def\toclevel@chapter{1}\def\toclevel@part{2}
    \addtocontents{toc}{\string\let\string\l@chapter\string\l@part}
    \makeatother

and the option "section" was set to "chapter" (instead of "part") for the "glossaries-extra" package.

Now I need to revert it for the next chapter. Another suggested solution for the question mentioned above uses \xpatchcmd but besides I included \usepackage{regexpatch} the command is not recognized. So, how could the command be reverted for the next chapter?

0

I do not understand why you want to do such strange things. But here is a suggestion:

\documentclass[a4paper]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[toc,automake, abbreviations, acronym, nomain]{glossaries-extra}
\usepackage{hyperref}

\RedeclareSectionCommand[tocindent=1em,tocnumwidth=2.5em]{chapter}
\RedeclareSectionCommand[tocindent=2em,tocnumwidth=3em]{section}
\RedeclareSectionCommand[tocindent=5em,tocnumwidth=4.2em]{subsection}
\RedeclareSectionCommand[tocindent=9.2em,tocnumwidth=7em]{subsubsection}

\makeglossaries
\newabbreviation{test}{TEST}{test}

\makeatletter
\newcommand*\original@l@chapter{}
\BeforeStartingTOC[toc]{\let\original@l@chapter\l@chapter}
\newcommand*\ChapterAsPartInTOC{%
  \addtocontents{toc}{\protect\let\protect\l@chapter\protect\l@part}%
}
\newcommand*\RestoreChapterInTOC{%
  \addtocontents{toc}{\protect\let\protect\l@chapter\protect\original@l@chapter}%
}
\makeatother


\begin{document}
\tableofcontents
\glsaddall

\ChapterAsPartInTOC
\printabbreviations %should not generate a title page
\chapter{Chapter 0} %should look like Part 1 in TOC
\label{test0}
\RestoreChapterInTOC

\part{Part 1}
\chapter{Chapter 1}
\label{test3}
\end{document}

Result:

enter image description here

Additional remarks: Do not use package tocloft together with a KOMA-Script class. Package subfigure is outdated. Use subfig or subcaption instead.

  • Great, it works! Thank you! Just a short explanation for the strange layout wishes. I have a very short abstract (1-2 pages) at the beginning and it would be strange (in my -maybe weird- aesthetic sense) if there is a leading, nearly empty title page for just 2 following pages. On the other hand, it looks strange in the TOC if the first entries (chapters) are more indented and differently formatted as the following (like parts). – aquila Dec 9 '18 at 13:01

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.