0

The title says it all.

Im a little confused on why this is happening and im blind to whats wrong. (dont mind the second appendix B, i've changed that to C) However, the appendix A is a subfile.tex with chapter*.

The appendix are un-numbered chapters*

This is document.tex (main)

\providecommand{\main}{.}
\documentclass[12pt,a4paper]{scrreprt} 
\usepackage[english]{babel}
\usepackage{enumitem}
%\usepackage[utf8]{inputenc}% only needed for older TeX distributions
\usepackage[automark,headsepline]{scrlayer-scrpage} 
  \clearpairofpagestyles 
   \ofoot[\pagemark]{\pagemark} % \ofoot = outer footer, change to \ifoot for 
    inner footer \cfoot for center footer
\pagestyle{scrheadings} 
\usepackage[titles]{tocloft}
    \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % Fill dots also 
     for chapter leaders
     \renewcommand{\cftdot}{.} % Define the symbol used for dots; can use - 
     or asterisk* or @
\renewcommand{\contentsname}{Table of Content} 

\usepackage{subfiles} % For using 'standalone' or individual files, so each 
 can be compiled and seen individually.
    \newcommand{\onlyinsubfile}[1]{#1}
    \newcommand{\notinsubfile}[1]{}
\usepackage[nottoc,numbib]{tocbibind} % add list of tables, list of figures 
 and bibliography to TOC (numbered)

\begin{document}

\tableofcontents

\clearpage
\bibliographystyle{plain}
\bibliography{./library}
\cleardoublepage

\subfile{\main/app/app1}\label{sec:app1} % Appendix A 
\addcontentsline{toc}{chapter}{\numberline{}Appendix A}

\end{document}

This is app1.tex:

\providecommand{\main}{..}
\documentclass[\main/document.tex]{subfiles}


\begin{document}

\onlyinsubfile
\notinsubfile

\chapter*{\center{ {\large Appendix} {\Huge I}}}
\cleardoublepage

%------------------------------------------
\section{Stereotaxic surgery, drug delivery and head holder implantation}



\end{document}

Let me know if you need more from the main.tex however its very very looong

  • Can you please provide a minimal working example? – Johannes_B May 16 '19 at 5:17
  • It has been done @Johannes_B – Thomasblindhardt May 16 '19 at 5:31
  • 1
    Your \addcontentsline command is at the wrong place. Better use commands like \addchap provided by KOMA. Don't use \center inside a chapter command and better don't use tocloft and tocbibind together with a KOMA-class, KOMA has its own tools. – Ulrike Fischer May 16 '19 at 8:20
1

In your code the \addcontentsline is placed after the subfile with the contents of the appendix chapter. So it appears below its section entries with a wrong page number. Because of \numberline{} the entry is indented in TOC. Last but not least \chapter* does not change the chapter number. So the section numbers still contain the last chapter number, in your example the chapter number of the bibliography.

You should remove package tocbibind and set class options listof=totoc, bibliography=numbered and maybe index=totoc.

Do not use package tocloft together with a KOMA-Script class. With KOMA-Script class option toc=chapterentrywithdots you will get dots for the chapter entries.

The title of the TOC can be changed by \renewcaptionname{english}{\contentsname}{Table of Content}.

Here is also one possible suggestion for your appendix chapters:

\documentclass[
  12pt,
  %a4paper,% default
  toc=chapterentrywithdots,% dots between the chapter entry and its page number in TOC
  listof=totoc,% TOC entries for LOF, LOT etc.
  index=totoc,% TOC entry for index
  bibliography=numbered,% numbered with entry in TOC
  numbers=noenddot% no dot at the end of sectioning numbers etc.
]{scrreprt} 
\usepackage[english]{babel}
\usepackage{enumitem}
\usepackage[utf8]{inputenc}
\usepackage[automark,headsepline]{scrlayer-scrpage}% sets pagestyle scrheadings automatically
  \clearpairofpagestyles 
   \ofoot*{\pagemark} % short version of \ofoot[\pagemark]{\pagemark}

\renewcaptionname{english}{\contentsname}{Table of Content}% change the TOC title

\DeclareNewSectionCommand[
  style=part,
  level=\chapternumdepth,
  tocstyle=chapter,
  tocindent=0pt,
  tocnumwidth=1.5em,
  tocdynnumwidth,
  tocentryformat=\usekomafont{chapterentry},
  tocentrynumberformat=\appendixname~
]{appchap}
\makeatletter
\let\c@appchap\c@chapter% use the same counter for both chapter and appchap
\def\theappchap{\thechapter}
\def\cl@appchap{\cl@chapter}% use the same reset list
\makeatother
\renewcommand*{\appchapformat}{{\large\appendixname}~\theappchap}
\newcommand*\appendixchapter{\appchap{\mbox{}}}

\usepackage{blindtext}% only for dummy text in the MWE
\begin{document}
\tableofcontents
\blinddocument

\appendix
\appendixchapter
\section{Stereotaxic surgery, drug delivery and head holder implantation}
\Blindtext[2]
\section{Next Section}
\Blindtext
\appendixchapter
\section{Section in the second appendix chapter}
\Blindtext
\end{document}

Result:

appendix chapters in TOC

appendix pages


With package subfiles you have to ensure that command \appendix is excuted only once! Therefore you can use the \onlyinsubfile trick.

Example:

File document.tex:

\providecommand\main{.}
\documentclass[
  12pt,
  toc=chapterentrywithdots,
  listof=totoc,
  index=totoc,
  bibliography=numbered,
  numbers=noenddot
]{scrreprt}
\usepackage[english]{babel}
\usepackage{enumitem}
%\usepackage[utf8]{inputenc}% only needed for older TeX distributions
\usepackage{subfiles}
\newcommand{\onlyinsubfile}[1]{#1}% <- added
\usepackage[automark,headsepline]{scrlayer-scrpage}
  \clearpairofpagestyles
  \ofoot*{\pagemark}

\renewcaptionname{english}{\contentsname}{Table of Content}

\DeclareNewSectionCommand[
  style=part,
  level=\chapternumdepth,
  tocstyle=chapter,
  tocindent=0pt,
  tocnumwidth=1.5em,
  tocdynnumwidth,
  tocentryformat=\usekomafont{chapterentry},
  tocentrynumberformat=\appendixname~
]{appchap}
\makeatletter
\let\c@appchap\c@chapter
\def\theappchap{\thechapter}
\def\cl@appchap{\cl@chapter}
\makeatother
\renewcommand*{\appchapformat}{{\large\appendixname}~\theappchap}
\newcommand*\appendixchapter{\appchap{\mbox{}}}

\usepackage{blindtext}
\begin{document}
\renewcommand\onlyinsubfile[1]{}% <- added
\tableofcontents
\blinddocument

\appendix
\subfile{\main/app/app1}
\subfile{\main/app/app2}
\end{document}

File app1.tex in folder app:

\providecommand\main{..}
\documentclass[\main/document.tex]{subfiles}
\begin{document}
\onlyinsubfile{\appendix}% <- ensures that this does not go to the main file
\appendixchapter
\section{Stereotaxic surgery, drug delivery and head holder implantation}
\Blindtext[2]
\section{Next Section}
\Blindtext
\end{document}

File app2.tex in folder app:

\providecommand\main{..}
\documentclass[\main/document.tex]{subfiles}
\begin{document}
\onlyinsubfile{\appendix}% <- ensures that this does not go to the main file
\appendixchapter
\section{Section in the second appendix chapter}
\Blindtext
\end{document}

The result of the main file document.tex is the same as above.

  • I know this is stupid, but how do you change the name of the Appendix using your given code, right now both are named appendix A in the TOC.. – Thomasblindhardt May 17 '19 at 2:35
  • bear in mind im using subfiles.. So writing \appendix \appendixchapter is written in the seperate subfile. I guess that confuses the counter – Thomasblindhardt May 17 '19 at 3:02
  • You have to ensure that \appendix is used only once. See my updated answer. – esdd May 17 '19 at 14:00

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.