1

I am writing a thesis and i would like the appendices, which are declared as \chapter to be grouped under one chapter "Appendices" in the bookmarks, and then each appendix to appear as a section. The answer to this question was provided here. The idea was to use xpatch to change the TOC entries from \chapter to \section.

I am now trying to change the \section entries in my appendices into \subsection in the bookmarks. And that's where I run into problems.

My code below runs with no error, but treats all the bookmarks in my appendices as sections.

Note that I am using a style file (dissertation.sty, see code below the .tex file). This style file defines the command \appendices which is why I do not use the appendix package.

\documentclass[12pt]{report}

\usepackage{dissertation}

\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{amsmath,amssymb,amsfonts,dsfont}
\usepackage{xpatch}
\usepackage[dvipdfm,hypertexnames=false,colorlinks,linktoc=page]{hyperref}

\begin{document}

\chapter{Chapter 1}

\section{Section 1}

\section{Section 2}

\chapter{Chapter 2}


\appendices

\chapter{Appendix 1} 

\chapter{Appendix 2}

\section{Sub-appendix 1}

\section{Sub-appendix 2}

\end{document}

And the minimum style file needed for this code to compile is:

\newlength{\regular@textheight}
\setlength{\regular@textheight}{\textheight}
%
\addtolength{\regular@textheight}{-\footskip}
\newlength{\short@textheight}
\setlength{\short@textheight}{\textheight}
\addtolength{\short@textheight}{-\footskip}

\def\short@page{%
    \setlength{\textheight}{\short@textheight}
    \global \pagestyle{plain}
    \global \@colht\textheight
    \global \@colroom\textheight
    \global \vsize\textheight}

\def\regular@page{%
    \setlength{\textheight}{\regular@textheight}
    \global \pagestyle{plain}
    \global \@colht\textheight
    \global \@colroom\textheight
    \global \vsize\textheight}

\newcounter{regular@short}


\def\doublespacing{%
    \def\default@spacing{\baselineskip=23.5pt plus .5pt minus .2pt}}



\newlength{\one@num}\setlength{\one@num}{18pt}
\newlength{\two@num}\settowidth{\two@num}{9.9...}
\newlength{\three@num}\settowidth{\three@num}{9.9.9...}
\newlength{\four@num}\settowidth{\four@num}{9.9.9.9...}
\newlength{\five@num}\settowidth{\five@num}{9.9.9.9.9...}
\newlength{\six@num}\settowidth{\six@num}{9.9.9.9.9.9...}

\def\longtocentry{%
\settowidth{\two@num}{99.99...}
\settowidth{\three@num}{99.99.99...}
\settowidth{\four@num}{99.99.99.99...}
\settowidth{\five@num}{99.99.99.99.99...}
\settowidth{\six@num}{99.99.99.99.99.99...}}

\newlength{\c@onenum}
    \setlength{\c@onenum}{\one@num}
\newlength{\c@twonum}
    \setlength{\c@twonum}{\c@onenum}\addtolength{\c@twonum}{\two@num}
\newlength{\c@threenum}
    \setlength{\c@threenum}{\c@twonum}\addtolength{\c@threenum}{\three@num}
\newlength{\c@fournum}
    \setlength{\c@fournum}{\c@threenum}\addtolength{\c@fournum}{\four@num}
\newlength{\c@fivenum}
    \setlength{\c@fivenum}{\c@fournum}\addtolength{\c@fivenum}{\five@num}

\def\l@section{\@dottedtocline{1}{\c@onenum}{\two@num}}
\def\l@subsection{\@dottedtocline{2}{\c@twonum}{\three@num}}
\def\l@subsubsection{\@dottedtocline{2}{\c@threenum}{\four@num}}
\def\l@paragraph{\@dottedtocline{4}{\c@fournum}{\five@num}}
\def\l@subparagraph{\@dottedtocline{5}{\c@fivenum}{\six@num}}


\def\nopage@addcontentsline#1#2#3{\addtocontents{#1}%
{\protect \contentsline {#2}{#3}{}}}

\newlength{\toc@chap@indent}
\settowidth{\toc@chap@indent}{\bf\@chapapp\space\thechapter.\hspace*{1em}}
\def\l@chapter#1#2{\addpenalty{-\@highpenalty}
    \vskip 1.0em plus 1pt
    \@tempdima=\toc@chap@indent
    \begingroup
    \parindent \z@
    \rightskip \@pnumwidth
    \parfillskip -\@pnumwidth
    \bf \leavevmode
    \advance\leftskip\@tempdima \hskip -\leftskip #1\nobreak\hfil
    \nobreak\hbox to\@pnumwidth{\hss #2}\par
    \penalty\@highpenalty \endgroup}

\def\@makechapterhead#1{ \vspace*{0pt} {\parindent 0pt \centering
    \ifnum \c@secnumdepth >\m@ne \Large\bf \@chapapp{} \thechapter
    \par \vskip 15pt \fi \Large \bf #1\par \nobreak \vskip 35pt}}

\def\@makeschapterhead#1{\vspace*{0pt} {\parindent 0pt \centering
    \Large \bf #1\par \nobreak \vskip 30pt}}

\def\chapter{%
    \clearpage
    \short@page \setcounter{regular@short}{0}
    \default@spacing
    \global\@topnum\z@ \@afterindenttrue
    \secdef\@chapter\@schapter}

\def\shortchapter{%
    \clearpage
    \short@page \setcounter{regular@short}{1}
    \default@spacing

    \global\@topnum\z@ \@afterindenttrue
    \secdef\@chapter\@schapter}

\newcount\chap@or@app\chap@or@app=1

\def\appendixname{Appendix}

\def\appendices{\clearpage\phantomsection
    \typeout{Appendices.}
    \short@page \setcounter{regular@short}{1}
        \markboth{}{}\pagestyle{myheadings}
        \thispagestyle{plain}
    \vspace*{\fill}
    \centerline{\large\bf Appendices}
    \vspace*{\fill}

    \addcontentsline{toc}{chapter}{Appendices}

    \setcounter{chapter}{0}
    \setcounter{section}{0}
    \def\@chapapp{\appendixname}
    \chap@or@app=2
    \def\thechapter{\Alph{chapter}}

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


\newcount\with@parts\with@parts=0
\def\@part[#1]#2{%
    \short@page
    \ifnum \c@secnumdepth >-2 \relax
      \refstepcounter{part}
      \addcontentsline{toc}{part}{\partname~\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}
    \fi
    \markboth{}{}
    {\centering
     \interlinepenalty \@M
     \reset@font
     \ifnum \c@secnumdepth >-2 \relax
       \huge\bfseries \partname~\thepart
       \par
       \vskip 20\p@
     \fi
     \Huge \bfseries #2\par}
     \ifnum\value{part}=1 \pagenumbering{arabic}
     \with@parts=1 \fi
    \@endpart}


\newcounter{no@chapters}
\setcounter{no@chapters}{0}


\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}
    \typeout{\@chapapp\space\thechapter.}
    \addcontentsline{toc}{chapter}{\@chapapp\space\thechapter.\hspace*{1em}#1}\else
    \addcontentsline{toc}{chapter}{#1}\fi
    \addtocontents{lof}{\protect\addvspace{10pt}}
    \addtocontents{lot}{\protect\addvspace{10pt}}
    \@makechapterhead{#2} \@afterheading
    \ifnum\chap@or@app=1 \ifnum\value{chapter}=1
        \markboth{}{}\pagestyle{myheadings}
        \ifnum\with@parts=0 \pagenumbering{arabic}\fi
                                           \fi\fi
        \thispagestyle{plain}}

\def\@schapter#1{\thispagestyle{plain}
        \@makeschapterhead{#1} \@afterheading}
\def\section{%
     \ifnum\value{no@chapters}=1 \fpage \fi%
     \@startsection{section}{1}{\z@}%
    {4.6ex plus -1ex minus -.2ex}{.3ex plus .2ex}{\large\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}%
    {3.9ex plus -1ex minus -.2ex}{.2ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{2}{\z@}%
    {3.9ex plus -1ex minus -.2ex}{.2ex plus .2ex}{\normalsize\bf}}

\doublespacing
Jerome
  • 51
  • Could you please add your compilation routine? The code does not compile for me. Tried LaTeX => DVI => PDF. – LaRiFaRi Apr 17 '14 at 06:55
  • 1
    I use LaTex => DVI => PDF. I modified the code above for it to compile (I did not realize that I needed more of the style file than I included in my previous post) – Jerome Apr 17 '14 at 15:23

0 Answers0