2

Possible Duplicate:
How to make appendices behave like sections in ToC

Consider the minimal example below. How can I achieve that in the appendix part (only there!) of the ToC paragraphs are aligned with sections? Paragraphs should also figure as sections in the pdf bookmarks!

EDIT: Added hyperref.

\documentclass[10pt, a4paper]{report}

\usepackage[titletoc]{appendix}
\usepackage{hyperref}

\begin{document}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}   
\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\paragraph{tzu}
\paragraph{rfv}
\begin{appendices}
\makeatletter
\def\chaptermark#1{\markboth{\MakeUppercase{\@chapapp. \  #1}}{}}
\def\thechapter{}
\makeatother
\chapter{AAA}
\paragraph{abc}
\paragraph{def}
\paragraph{ghi}
\end{appendices}

\end{document}
lpdbw
  • 8,330
  • see http://tex.stackexchange.com/questions/64403/how-to-make-appendices-behave-like-sections-in-toc – pluton Jul 25 '12 at 13:06

1 Answers1

1

Here is a solution.

\documentclass[10pt, a4paper]{report}

\usepackage[titletoc]{appendix}
\usepackage{hyperref} 
\usepackage{bookmark}

\begin{document}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}   
\tableofcontents

\chapter{XXX}
\section{YYY}
\subsection{WER}
\subsubsection{ABC}
\subsubsection{DEF}
\subsection{ZTR}
\subsubsection{OIU}
\subsubsection{OIZ}
\subsubsection{POI}
\paragraph{tzu}
\paragraph{rfv}

\makeatletter
\addtocontents{toc}{\let\protect\l@paragraph\protect\l@section}
\makeatother

\begin{appendices}
\makeatletter
\def\chaptermark#1{\markboth{\MakeUppercase{\@chapapp. \  #1}}{}}
\def\thechapter{}
\makeatother
\chapter{AAA}
\paragraph{abc}
\paragraph{def}
\paragraph{ghi}
\end{appendices}

\end{document}   

Note that to ensure pdf bookmarks in the appendix also behave like sections it seems to be necessary to use the bookmark package (but don't ask me why).

lpdbw
  • 8,330
  • This is not a correct solution; the ToC won't be as expected and you get warnings. – Gonzalo Medina Jul 25 '12 at 13:47
  • @Gonzalo Medina: Where has your enhanced solution gone? Has it been deleted? If yes why??? – lpdbw Jul 25 '12 at 16:53
  • I deleted my answer since it was not complete. – Gonzalo Medina Jul 25 '12 at 16:54
  • @Gonzalo Medina: But you said that mine was suboptimal. If you are still of this opinion, I think your answer should be displayed since otherwise people coming acroos this thread might be mislead and use my suboptimal solution. And in how far was it not complete? – lpdbw Jul 25 '12 at 16:59
  • You're right. If a have time I will review my answer and once it's complete I'll undelete it. – Gonzalo Medina Jul 25 '12 at 17:01
  • @Gonzalo Medina: I have implemented your solution into my main file now and I am a bit confused over whether there are still hidden issues? Moreover, I wanted to ask how I can prevent that section=paragraph titles are indented? In your code there already was a {0pt} but still there is an indent!? – lpdbw Jul 25 '12 at 17:13