In the table of content, I want to have Appendix A instead of chapter A, Appendix B instead of chapter B, and show on. I can't show this when I use \include{appendix}. Following is my code:
\documentclass{report}
\usepackage{tocloft,calc}
\renewcommand\cftchapaftersnum{}% adds dot after chapter title in ToC
\renewcommand\cftchapdotsep{\cftdotsep}% adds leader dots from chapter titles to page numbers
% chapter and chapter number rather than just number
\renewcommand{\cftchappresnum}{\chaptername\space}
\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}}
\makeatletter
\g@addto@macro\appendix{%
\addtocontents{toc}{%
\protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}%
}%
}
\makeatother
\begin{document}
\tableofcontents
\cleardoublepage
\addcontentsline{toc}{chapter}{List of Tables}
\listoftables
\include{chp1}
\include{chp2}
\appendix
\include{appendix} :
\end{document}
%chp1.txt is
\chapter{Introduction1}
%chp2.txt is
\chapter{Introduction2}
%appendix.txt is
% Appendix A
\chapter{}
\section{hello1}
In the ...
\section{hello2 }
% Appendix B
\clearpage
\newpage
\chapter{}
\section{bello1}
\section{bello2 }
%table of content output
Contents
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Chapter 1 Introduction1 . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2 Introduction2 . . . . . . . . . . . . . . . . . . . . . . . 4
Chapter A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
A.1 hello1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
A.2 hello2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Chapter B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
B.1 bello1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
B.2 bello2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
P.S. I am NOT looking for the solution with \input{appendix} for \include{appendix}. I already tried that; although it works for this example, it does not solve my real problem.
Desired table of content output:
Contents
List of Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . .2
Chapter 1 Introduction1 . . . . . . . . . . . . . . . . . . . . . . . 3
Chapter 2 Introduction2 . . . . . . . . . . . . . . . . . . . . . . . 4
Appendix A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
A.1 hello1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
A.2 hello2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
Appendix B . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
B.1 bello1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
B.2 bello2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
tocloftwhich must have some interaction with my code. Anyway, your code gives you what you want, or do I miss something? – Bernard Feb 15 '16 at 00:14tocloft. – Metrics Feb 15 '16 at 00:24include{appendix}(directly use contents in the main file). However, I do have to useinclude{appendix}and hence the question. Thanks once again. – Metrics Feb 15 '16 at 01:22include{chp1}and\include{chp2}. – Metrics Feb 15 '16 at 03:07