I have:

\chapter{My first chapter}
\chapter{My second chapter}
\phantomsection
\appendix
\makeatletter
\def\toclevel@chapter{1}\def\toclevel@section{2}
\makeatother
\chapter{My first appendix}
\chapter{My second appendix}


So my hyperref table of contents looks like:

- My first chapter
- My second chapter
+ Appendixes
- My first appendix
- My second appendix


But my \tableofcontents still looks like:

1 My first chapter
2 My second chapter
Appendixes
A My first appendix
B My second appendix


And what I want is that the appendixes look like sections:

1 My first chapter
2 My second chapter
Appendixes
A My first appendix
B My second appendix


I can figure out, that there is a really small trick to do the job, but I can't find it...

-
how about \addcontentsline{toc}{section}{Appendixes}?  –  cmhughes Jun 16 '12 at 2:00
Which document class are you using? –  Gonzalo Medina Jun 16 '12 at 3:22

set \l@chapter to l@section

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
\appendix
\def\toclevel@chapter{1}\def\toclevel@section{2}
\chapter{My first appendix}
\chapter{My second appendix}

\end{document}

-
Unfortunately this MWE does not work for me. The appendix chapters appear on the same line of the toc and the strings pop up, here is what I copied out of the pdf generated: @section lA My rst appendix7 lB My second appendix9. Any suggestions? –  ted Aug 10 '13 at 12:26

You can redefine \@chapter (as implemented in the document class used) to use \addcontentsline{toc}{section}{...} instead of \addcontentsline{toc}{chapter}{...}. Here's an example of such redefinition for book.cls:

\documentclass{book}
\usepackage{hyperref}

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
\appendix
\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
{\protect\numberline{\thechapter}#1}%
\else
\fi
\else
\fi
\chaptermark{#1}%
\if@twocolumn
\else
\fi}
\makeatother

\chapter{My first appendix}
\chapter{My second appendix}

\end{document}


Here's the resulting ToC:

and the bookmarks pabel:

-
I want it class independant (like Herbert's answer) –  Kyle_the_hacker Jun 18 '12 at 0:04

The following is a condensed version of Gonzalo's answer, using regexpatch. It patches the first appearance of {toc}{chapter} in \Hy@org@chapter with {toc}{section}, yielding the same result:

\documentclass{book}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\usepackage{regexpatch}% http://ctan.org/pkg/regexpatch

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\phantomsection
\appendix
\makeatletter
\xpatchcmd{\Hy@org@chapter}{{toc}{chapter}}{{toc}{section}}{}{}%
\makeatother

\chapter{My first appendix}
\chapter{My second appendix}

\end{document}


If you wish to not only print the \chapters at section level, but push the entire hierarchy down a level, things get a little more messy. Specifically because the sectional units are all governed by a single macro (perhaps since they're common to all basic document classes) called \@startsection. So, one could redefine or patch the "type" or "level" of the macro for each sectional unit. This has no effect on hyperref. For example:

\xpatchcmd{\section}{section}{subsection}{}{}
\xpatchcmd{\subsection}{subsection}{subsubsection}{}{}
\xpatchcmd{\subsubsection}{subsubsection}{paragraph}{}{}
\xpatchcmd{\paragraph}{paragraph}{subparagraph}{}{}


Of course, there's no level to demote \subparagraph, but hopefully that level of detail is not included in your ToC.

If all of the above should be localized so you can easily revert back to the default layout when needed, then I would suggest making a copy of any of the macros before patching them:

\let\storedchapter\Hy@org@chapter
\let\storedsection\section
\let\storedsubsection\subsection
\let\storedsubsubsection\subsubsection
\let\storedparagraph\paragraph


This way you can revert the process later, if needed.

-
how do I extend this for lower hierarchy levels (section, subsection, subsubsection,...). Especially what do I do with the lowest hierarchy level to push it one level down? (fortunately the last part is pure curiosity since I dont use it in my toc). Also: can I reverse this effect if I would like to add a chapter with the default hierarchy to the toc afterwards? –  ted Aug 10 '13 at 12:52
@ted: I've added some detail. –  Werner Aug 11 '13 at 4:08
While one should refrain from tahnk you notes, I have to use one here, since I have already upvoted there is no other way to let you know the effort has not gone unnoticed and is appreciated. –  ted Aug 11 '13 at 7:46

Here is another solution. It uses the addcontentsline to insert the chapter on the level you choose, and useses the starred variant to typeset the title with the chapter formatting without adding anything to the table of contents. letltxmacro is used since I get a circular reference otherwise.

\documentclass{book}
\usepackage{hyperref}
\usepackage{letltxmacro}

\begin{document}

\tableofcontents
\chapter{My first chapter}
\chapter{My second chapter}

\LetLtxMacro{\chapNoToc}{\chapter*}
\renewcommand{\chapter}[1]{%
\chapNoToc*{#1}
\phantomsection
\markboth{#1}{#1}
}

\chapter{My first appendix}
\chapter{My second appendix}

\end{document}


This solution could be exteneded to support chapters optional argument, however I do not know how to insert the first argument or an otpional argument depending on the presence of the later of the top of my head.

It might be a good idea to save \chapter with \LetLtxMacro so it can be restored later. Add \LetLtxMacro{\oldChapter}{\chapter} before you redfine \chapter and use \LetLtxMacro{\chapter}{\oldChapter}` to restore the default chapter behaviour.

-
@lockstep: did I get it right now? (You commented that I was missing the title markings). However my knowledge is from google, so I am unsure if this covers all cases now. –  ted Aug 10 '13 at 13:53