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}{\chapapp\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[appendixprefix=true]{scrbook}
\usepackage{blindtext}
\usepackage{tocstyle}
\renewcommand*{\addchaptertocentry}[2]{%
\addtocentrydefault{chapter}{\chapapp\nobreakspace #1}{#2}%
}
\usetocstyle{KOMAlike}
\begin{document}
\tableofcontents
\blinddocument
\appendix
\blinddocument
\end{document}
If you are using \chapter
in \fronmatter
, remember to use the starred version to avoid a Chapter .
with empty number in your Table of Contents. Also, if you are using the command \addchap
in you document, use the starred version (\addchap*
}.
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
.
There are two and a half solutions (only the second one is valid if you need to use \include
):
- Use
\input
instead of \include
(if you don't need the functionality of \include
).
- Put
\appendices
into appendixA.tex
.
Manually configure the TOC file from
\contentsline {chapter}{\numberline {1}First things}{1}
\contentsline {chapter}{\numberline {A}The initial stuff}{3}
\contentsline {section}{\numberline {A.1}A section within the initial appendix}{3}
\contentsline {chapter}{Appendices}{3}
\contentsline {chapter}{\numberline {B}Another addendum}{5}
to
\contentsline {chapter}{\numberline {1}First things}{1}
\contentsline {chapter}{Appendices}{3}
\contentsline {chapter}{\numberline {A}The initial stuff}{3}
\contentsline {section}{\numberline {A.1}A section within the initial appendix}{3}
\contentsline {chapter}{\numberline {B}Another addendum}{5}
The package manual states:
There is an unfortunate interaction between the LaTeX kernel commands \include
and \addcontentsline
. […]
Things work as expected if the \addcontentsline
command is placed
within the \included
file, or if the imported file is \input
ed instead of \includ
ed.
On another note: appencides
is an environment not a macro, so you better use \appendices … \endappendices
or \begin{appendices} … \end{appendices}
.
Best Answer
You can use the
pdfpages
to include otherpdfs
in your document- there are lots of options for this package, all of which are well documented. In the MWE below, I've usedso that it includes all of the pages of
myotherdocument.pdf
If you want to add content to your
toc
, then you can use\addcontentsline
which has the general formYou can choose the
<level>
to bechapter
,section
, etc depending on how you want it to look.As discussed in the comments, your third and fourth requests conflict :)
Here's a MWE, assuming that you have
myotherdocument.pdf
in your current working directory.