Customize appendix entries in ToC and pdf bookmarks [duplicate]

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!

\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}
-

marked as duplicate by pluton, Gonzalo Medina, lockstep, Marco Daniel, percusseJul 26 '12 at 22:23

–  pluton Jul 25 '12 at 13:06

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
\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).

-
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
show 1 more comment