Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My first question is how to add the chapter or appendix prefix in the table of contents of scrbook class instead of the its default appearance.

For example, in the figure below, I want to change the chapter entry in TOC to Chapter 1. Introduction.

and the same goes for the appendix entry in TOC, which means typesetting Appendix A. Electro... instead of the figure below.

Additionally, I have used \appendix before starting my appendices, so it treats all the subsequent chapters as chapters A, B, etc. However, I want to treat them as appendices to appear correctly in the page headings as "Appendix A. Electro..." instead of "Chapter A. Electro..." in the page heading as shown below.

enter image description here

Thanks in advance

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

Your first question can be solved by using the tocstyle-package included in the KOMAscript-bundle. Try

 texdoc tocstyle

at an command prompt to see the documentation.

By redefining some internal variables, if I understand your question correctly, you will have the answer to your first question. Put this commands in your preamble:

\usepackage{tocstyle}
\renewcommand*{\addchaptertocentry}[2]{%
  \addtocentrydefault{chapter}{\chaptername\nobreakspace #1}{#2}%
}
\usetocstyle{KOMAlike}

Your second question was:

However, I want to treat them as appendices to appear correctly in the page headings as "Appendix A. Electro..."

This be solved by using the class-option chapterprefix=true or appendixprefix=true, if I understand your question correctly.

A complete MWE, which (hopefully) solve all questions:

\documentclass[chapterprefix=true]{scrbook}
\usepackage{blindtext}
\usepackage{tocstyle}
\renewcommand*{\addchaptertocentry}[2]{%
  \addtocentrydefault{chapter}{\chaptername\nobreakspace #1}{#2}%
}

\usetocstyle{KOMAlike}

\begin{document}
\tableofcontents
\blinddocument

\appendix
\let\chaptername\appendixname % or
%\renewcommand*{\chaptername}{\appendixname}

\blinddocument

\end{document}

For further reading, see page 80 in the English manual, and this discussion at the KOMAscript homepage.

NB! This code needs a recent version of komascript.

share|improve this answer
    
Thanks for help, but the MWE doesnt work and I got this "! LaTeX Error: \addchaptertocentry undefined." –  Diaa Abidou Jul 7 '12 at 1:32
    
Strange, The MWE works on my system (updated MikTeX on Win 7). What is your version of koma-script? –  Sveinung Jul 7 '12 at 7:44
    
After updating the Miktex 2.9 packages, the same error appears. Regarding the Koma version, here is the line from log file: Document Class: scrbook 2010/09/17 v3.07 KOMA-Script document class (book –  Diaa Abidou Jul 7 '12 at 18:12
    
@Diaa Current version of komascript is 3.11a. My scrbook reports: scrbook 2012/05/15 v3.11 KOMA-Script document class (book). If your miktex that does not update your packages correctly, or maybe you have a copy of scrbook in your texmf-local (or whatever you have named your private TeX directory). The code need a recent version of komascript. –  Sveinung Jul 7 '12 at 20:22
1  
I fixed it by removing the option "bibliography=totoc" and inserting "\addcontentsline{toc}{chapter}{References}" after \bibliography{<bibfile.bib>}. If available, can you tell me why does this awkward entry appear in case of using the class option ? –  Diaa Abidou Jul 9 '12 at 0:36
show 8 more comments

Thanks to the answer of the question \chaptername is used even for appendix chapters in ToC

the syntax of

\usepackage{tocloft,calc}
\renewcommand{\cftchappresnum}{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
\makeatletter
\g@addto@macro\appendix{%
  \addtocontents{toc}{%
    \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
  }%
}
\makeatother

has a successful result in prefixing the chapters entries in TOC with the word "Chapter" (same for appendices).

For the running headings in the in the appendices environment, the following syntax changes

Chapter to Appendix

\begin{document}

\appendix
\renewcommand{\chaptermark}[1]{\markboth{Appendix\ \thechapter.\ #1}{}}
\chapter{Appendix A}
\chapter{Appendix B}

\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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