5

I have a fiction book to typeset and I am using scrbook class as I thought that it is very flexible. For every chapter beginning I am using \chapter{} command and leave the field inside {} empty, so the command gives me only the text "Chapter 1." and so on.

However, if there is no name for a chapter, it does not appear in TOC. Is it possible to make them appear?

I hope this explains what I'm trying to achieve.

EDIT1: I am strongly considering to use memoir class, so if somebody knows how to do this in memoir class, please, let me know.

EDIT2: I just noticed, that with memoir class it happens automatically, but I am still interested in scrbook class hacks.

4 Answers 4

6

With scrbook you can get what you want with the following:

\documentclass{scrbook}
\renewcommand{\numberline}[1]{\chaptername~#1}
\begin{document}
\tableofcontents
\chapter{\null}
abc
\chapter{\null}
def
\end{document}

I assume that you don't use sections; in that case the trick must be different.


For using also parts, one can take a different approach:

\documentclass{scrbook}
\usepackage{etoolbox}

\makeatletter
\def\part@numberline#1{\partname~#1}
\def\chapter@numberline#1{\chaptername~#1}
\patchcmd{\l@part}{\begingroup}{\begingroup\let\numberline\part@numberline}{}{}
\patchcmd{\l@chapter}{\begingroup}{\begingroup\let\numberline\chapter@numberline}{}{}
\makeatother

\begin{document}
\tableofcontents
\part{\null}
\chapter{\null}
abc
\chapter{\null}
def
\end{document}
2
  • This works if I am using only chapters. Is it possible to do it if I have parts and chapters? Thanks
    – aignas
    Aug 10, 2012 at 0:12
  • That's an amazing answer... Thank you so much!
    – aignas
    Aug 10, 2012 at 14:33
2

You can use the two lines code before every chapter to do it:

\chapter[]{}
\addcontentsline{toc}{chapter}{\chaptername{} \thechapter}

Minimal example:

\documentclass{scrbook}

\begin{document}
\tableofcontents
\chapter[]{}
\addcontentsline{toc}{chapter}{\chaptername{} \thechapter}

\end{document}

But before every chapter you will not get the word chapter, only the chapter number.

2

And here's a solution for the book document class. It relies on using the tocloft package.

\documentclass{book}
\usepackage{tocloft}
\renewcommand\cftchappresnum{Chapter }
\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{}
\chapter{}
\end{document}

enter image description here

1

If that should be done only for chapters you can patch \addchaptertocentry.

\documentclass[toc=flat]{scrbook}
\usepackage{xpatch}
\xpatchcmd{\addchaptertocentry}
  {\addtocentrydefault{chapter}{#1}{#2}}
  {\addtocentrydefault{chapter}{\chaptername~#1}{#2}}
  {}{\PatchFailed}
\begin{document}
\tableofcontents
\chapter{\null}
abc
\chapter{\null}
def
\end{document}

Of course you can do the same for other sectioning levels.

\documentclass[toc=flat]{scrbook}
\usepackage{xpatch}
\xpatchcmd{\addparttocentry}
  {\addtocentrydefault{part}{#1}{#2}}
  {\addtocentrydefault{part}{\partname~#1}{#2}}
  {}{\PatchFailed}
\xpatchcmd{\addchaptertocentry}
  {\addtocentrydefault{chapter}{#1}{#2}}
  {\addtocentrydefault{chapter}{\chaptername~#1}{#2}}
  {}{\PatchFailed}
\begin{document}
\tableofcontents
\part{\null}
\chapter{\null}
abc
\chapter{\null}
def
\end{document}

Result

enter image description here

You must log in to answer this question.

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