1

I am writing a book using the book class. In the table of contents, I want

PART 1 Whatever Chapter 1 whatever ... and then to switch, in the appendices to

APPENDICES Appendix A Whatever ...

I cannot seem to get LaTeX to recognize the \renewcommand to change from Part to blank and Chapter to Appendix. I can't seem to get rid of the PART" before APPENDICES without getting rid of it on all the other sections, or to change Chapter" to "Appendix"

I would also like to delete the page numbers on pages 1, 9 and 15. I have tried placing \thispagestyle{empty} in various places in the document, but to no avail.

Here is my code:

\documentclass[11pt]{book}
\usepackage[toc,page]{appendix}
\usepackage{tocloft}
\begin{document}
\renewcommand{\cftpartfont}{\bfseries}
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftpartpresnum}{PART~}
\renewcommand{\cftpartaftersnum}{:}
\renewcommand{\cftpartnumwidth}{6em}

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{Chapter~}
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{6em}



\frontmatter
\thispagestyle{empty}
\setcounter{tocdepth}{1}
\tableofcontents

\mainmatter
\renewcommand\partname{PART}
\part{Theory of Junk}
\input{Ch1}
\input{Ch2}
\input{Ch3}

\part{Theory of Garbage}
\input{Ch4}
\input{Ch5}


\renewcommand\partname{}
\renewcommand\thepart{\null}
\renewcommand{\cftpartpresnum}{}

\part{APPENDICES}
\appendix
\renewcommand{\cftchappresnum}{Appendix~}
\input{A1}
\input{A2}


\backmatter
\end{document}

1 Answer 1

0

You have to write the changes into the TOC using \addtocontents:

\addtocontents{toc}{%
  \protect\renewcommand{\protect\cftpartpresnum}{}%
  \protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
  \protect\renewcommand{\protect\cftchapnumwidth}{7em}%
}%

Example without package appendix:

\documentclass[11pt]{book}
\usepackage{blindtext}% only for dummy text
%\usepackage[toc,page]{appendix}% not used in the example
\usepackage{tocloft}

\renewcommand{\cftpartfont}{\bfseries}
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftpartpresnum}{PART~}
\renewcommand{\cftpartaftersnum}{:}
\renewcommand{\cftpartnumwidth}{6em}

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{Chapter~}
\renewcommand{\cftchapaftersnum}{:}
\renewcommand{\cftchapnumwidth}{6em}

\renewcommand{\partname}{PART}

\newcommand{\originalappendix}{}
\let\originalappendix\appendix
\renewcommand{\appendix}{%
  \originalappendix
  \addtocontents{toc}{%
    \protect\renewcommand{\protect\cftpartpresnum}{}%
    \protect\renewcommand{\protect\cftchappresnum}{Appendix~}%
    \protect\renewcommand{\protect\cftchapnumwidth}{7em}%
  }%
  \cleardoublepage
  \addcontentsline{toc}{part}{APPENDICES}%
  \part*{APPENDICES}%
}

\begin{document}
\frontmatter
\thispagestyle{empty}
\setcounter{tocdepth}{1}
\tableofcontents

\mainmatter
\part{Theory of Junk}
\blinddocument
\blinddocument
\blinddocument
\part{Theory of Garbage}
\blinddocument
\blinddocument

\appendix
\blinddocument
\blinddocument

%\backmatter
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .
https://tex.stackexchange.com/questions/591716/how-to-change-the-format-within-a-toc
tex.stackexchange.com
CC-MAIN-2024-18
140670
application/http; msgtype=response
sha1:3RHVT5KHRDEZGIDGC3YX6EWTKRDCWAM3
<urn:uuid:fff2a34f-ecf0-40ed-b63b-b804a3f55d57>
2024-04-13T13:09:13Z
104.18.43.226
text/html
sha1:FUQAYHORAD4HFXMFYYAB2JIP7JSGXTHD
<urn:uuid:0e651888-07e7-4c3d-baea-72ea460b26d2>
https://tex.stackexchange.com/questions/591716/how-to-change-the-format-within-a-toc
response
<urn:uuid:81a7bce4-bce0-4593-b8f3-abc66c3cb6f6>
isPartOf: CC-MAIN-2024-18
publisher: Common Crawl
description: Wide crawl of the web for April 2024
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-188
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.5-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/