1

I'm not as familiar with LaTeX as I'd like to be, and I'm having some trouble using a document template that I inherited for writing a thesis.

Using the book class, and the titlesec and appendix packages (as shown below), I'm trying to remove the 'Chapter', for the the chapters, but preserve the word "Appendix' for the Appendices. The TOC should just include chapter numbers and the appendix letter.

This code chunk gets rid of the word "Chapters"...but naturally, the Appendix page is not spared.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[titletoc, title]{appendix}
\usepackage{lipsum}t
\titleformat{\chapter}[block]{\normalfont\bfseries\Large}{\thechapter}{15pt}{}  % Not allowed to use the word 'chapter'.

\begin{document}  
\tableofcontents
\chapter{Chapters are cool.}
\lipsum[1-2]
\chapter{Books rock.}
\lipsum[1-3] 
\appendix
\chapter{Appendectomy info.}
It's good to have an appendix.
\end{document}

Reading around on postings here, I tried the following, but it seems not to work.

\makeatletter
\newcommand{\setchapter}{\thechapter.~}
\newcommand{\setappendix}{Appendix~\thechapter:~}

\titleformat{\chapter}[display]{\normalfont\bfseries}{%
  \ifnum\pdfstrcmp{\@currenvir}{appendices}=0
    \setappendix
  \else
    \setchapter
  \fi}{2em}{\LARGE}
\makeatother

Some pages that I've read for insight, but without much luck:

Appreciate any insight!

1

Just repeat the \titleformat command before starting the appendices with the new format.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage{titlesec}
\usepackage[titletoc, title]{appendix}
\usepackage{lipsum}
\titleformat{\chapter}[block]{\normalfont\bfseries\Large}{\thechapter.}{0.5em}{}  % Not allowed to use the word 'chapter'.

\begin{document}  
\tableofcontents
\chapter{Chapters are cool.}
\lipsum[1-2]
\chapter{Books rock.}
\lipsum[1-3] 
\titleformat{\chapter}[block]{\normalfont\bfseries\Large}{Appendix~\thechapter:}{0.5em}{}  \appendix
\chapter{Appendectomy info.}
It's good to have an appendix.
\end{document}

enter image description here

enter image description here

enter image description here

enter image description here

  • Thanks @gernot. Who would have thought it would be that straightforward! – Steve'sConnect Jan 7 '17 at 18:20
  • 1
    @Steve'sConnect if this answer is satisfying, please accept it as correct answer! – Skillmon Jan 7 '17 at 18:24

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.