Page LayoutAgain: appendix headers

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
mina
Posts: 12
Joined: Sun Jul 12, 2009 4:48 pm

Again: appendix headers

Post by mina »

Hi all,

I am using the report class and wish to add an appendix to my document. The problem is that I want to see the following in my pdf.
In the table of contents:
Appendix A: First appendix
Appendix B: Second appendix
At the appendices themselves:
Appendix A
First appendix
[some text...]
etc.

Is there a straightforward way of doing this? I have been googling for a long time...
Right now, I use the appendix package but this does not do what I want.

Thanx,
Mina

Code: Select all

\documentclass[a4paper,10pt]{report}

\usepackage{natbib}
\bibpunct{[}{]}{,}{s}{,}{,}
\usepackage[]{titlesec}
	\titleformat{\chapter}[display]
			{\normalfont\Large\bfseries}{\thechapter}{11pt}{\Large}
	\titleformat{\section}
			{\normalfont\large\bfseries}{\thesection}{11pt}{\large}
	\titlespacing*{\chapter}{0pt}{0pt}{15pt} %left, beforesep, aftersep, right
	\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\usepackage[title,titletoc]{appendix}

\begin{document}

\tableofcontents

\chapter{Introduction}

\section{Project}
\input{Sections/project}

\bibliographystyle{unsrtnat}
\bibliography{Bibliography/report}
\addcontentsline{toc}{chapter}{\bibname}

\begin{appendices}
  \chapter{First appendix}
[some text...]
  \chapter{Second appendix}
[some more text...]
\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.

User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Again: appendix headers

Post by frabjous »

I think the reason that the title option to the appendix package isn't working is that you've given control over the chapter titles to titlesec.

You could just reissue \titleformat{\chapter}{...} when you get to the Appendices to fine tune how they look, and changing \thechapter after the appendices start should take care of the period in the toc too.

What about this?

Code: Select all

\documentclass[a4paper,10pt]{report}

\usepackage{natbib}
\bibpunct{[}{]}{,}{s}{,}{,}
\usepackage[]{titlesec}
   \titleformat{\chapter}[display]
         {\normalfont\Large\bfseries}{\thechapter}{11pt}{\Large}
   \titleformat{\section}
         {\normalfont\large\bfseries}{\thesection}{11pt}{\large}
   \titlespacing*{\chapter}{0pt}{0pt}{15pt} %left, beforesep, aftersep, right
   \titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\usepackage[titletoc]{appendix}

\begin{document}

\tableofcontents

\chapter{Introduction}

A chapter intro.

\section{Project}

A section here.

\bibliographystyle{unsrtnat}
\bibliography{mybibfile}
\addcontentsline{toc}{chapter}{\bibname}


\titleformat{\chapter}[display]
       {\normalfont\Large\bfseries}{Appendix~\Alph{chapter}}{11pt}{\Large}

\begin{appendices}
\renewcommand{\thechapter}{\Alph{chapter}.}

  \chapter{First appendix}

some text...

  \chapter{Second appendix}

some more text

\end{appendices}

\end{document}
For more fine grained control over the toc, look at titletoc or tocloft packages.
mina
Posts: 12
Joined: Sun Jul 12, 2009 4:48 pm

Again: appendix headers

Post by mina »

Wooooow this is a long time ago. Sorry! The answer provided by frabjous solved the problem. Here a mwe that shows exactly how I had things in mind: both in the TOC and at the appendix page itself the chapter is shown as 'Appendix X'.

Thank you!

*Edit*
I can't seem to edit my first post, no edit button, so I can't add the checkmark to mark it solved :|

Code: Select all

\documentclass[a4paper,10pt]{report}

\usepackage[]{titlesec}
	\titleformat{\chapter}[display]
			{\normalfont\Large\bfseries}{\thechapter}{11pt}{\Large}
	\titleformat{\section}
			{\normalfont\large\bfseries}{\thesection}{11pt}{\large}
	\titlespacing*{\chapter}{0pt}{0pt}{15pt} %left, beforesep, aftersep, right
	\titlespacing*{\section}{0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\usepackage[title,titletoc]{appendix}

\begin{document}

\tableofcontents

\chapter{Introduction}

\section{Project}
[some text \ldots]

\titleformat{\chapter}[display]
			{\normalfont\Large\bfseries}{Appendix \thechapter}{11pt}{\Large}
\begin{appendices}
  \chapter{First appendix}
[some text...]
  \chapter{Second appendix}
[some more text...]
\end{appendices}

\end{document}

Post Reply