Page Layouttoc indent reset for appendices

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
robbjunk
Posts: 2
Joined: Thu Dec 27, 2012 6:07 pm

toc indent reset for appendices

Post by robbjunk »

I am fairly new to LaTex but pieced together this code to format my dissertation. Everything in my table is set the way it is required except for my appendices. There is a space due to the cftchapnumwidth option that is needed so that the Chapters are formatted correctly. How can I reset this option back to default for the appednices?

Code: Select all

\documentclass[12pt]{report}

%title edits
\usepackage{tocloft, titlesec, sectsty }
\usepackage[titletoc]{appendix}

%others
\usepackage{setspace}
\usepackage{times}
\usepackage[T1]{fontenc}

%chapter and title formatting
\renewcommand{\contentsname}{\begin{center}TABLE OF CONTENTS\end{center}}

\renewcommand{\appendixname}{APPENDIX}

\titlespacing*{\chapter}{0pt}{-50pt}{20pt}

\renewcommand\chaptername{CHAPTER}
\titleformat{\chapter}[hang]{\fontfamily{ptm}\large\bfseries\centering}{\chaptertitlename\ \thechapter}{1em}{} 
\titleformat*{\section}{\Large\bfseries}


%table of contents
\newcommand{\newchapter}[1]
{   \renewcommand{\thechapter}{\Roman{chapter}}
    \chapter{#1}
    \renewcommand{\thechapter}{\arabic{chapter}}
}
\setlength{\cftsecindent}{1.5cm}
\renewcommand{\cftchapdotsep}{4.5}   % same spacing as for sections

\renewcommand{\cftchapfont}{\bfseries}
\renewcommand{\cftchapleader}{\bfseries\cftdotfill{\cftchapdotsep}}
\renewcommand{\cftchappagefont}{\bfseries}
\renewcommand{\cftchappresnum}{CHAPTER }
\renewcommand{\cftchapnumwidth}{2.8cm}

%test command
\newcommand*\updatechaptername{%
        \addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{\@\ }}
}
\makeatother

\begin{document}

\newpage
\normalsize
\tableofcontents{}
\chapter{First chapter}
\section{first section}

\pagebreak
\begin{appendices}
\updatechaptername
\chapter{SYMBOL LIST}
\end{appendices}

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

toc indent reset for appendices

Post by Stefan Kottwitz »

Hi,

welcome to the board!

It would work if you would not use the appendix package, this way: change this macro:

Code: Select all

\newcommand*\updatechaptername{%
  \addtocontents{toc}{\protect\renewcommand*\protect\cftchappresnum{APPENDIX\ }}
}
and in the document write:

Code: Select all

\pagebreak
\appendix
\updatechaptername
\chapter{SYMBOL LIST}
By the way, I would not use an all-caps style (CHAPTER, APPENDIX), which reminds of times of typewriters where this and underlining was the only possibility of emphasis. Furthermore, bold and big and completely capitalized looks too heavy, just my opinion.

Stefan
LaTeX.org admin
robbjunk
Posts: 2
Joined: Thu Dec 27, 2012 6:07 pm

Re: toc indent reset for appendices

Post by robbjunk »

Thank you Stefan, that worked great.

I agree with you about the all-caps style, but this is the form my school requires for its dissertations.
Post Reply