3

I had to to define a \subsubsubsection for a technical document (I know it is highly criticised). I believe I inspired myself from this alternative answer to How to add an extra level of sections with headings below \subsubsection at that time (I couldn't use the package titlesec, but I can't remember the reason).

However, the hierarchy in the PDF bookmarks is messed up: subsubsubsection is shown as level 1 instead of 4, even though I tell \@startsection it's level 4 in the definition of \subsubsubsection. I wrongly expected this to handle PDF bookmarks implicitly as well.

How do I tell the package which is handling the PDF bookmarks (I guess hyperref) that the \subsubsubsection is level 4? Or alternatively as a suboptimal workaround, how do I tell \subsubsubsection not to show up in the PDF bookmarks at all (remember, setting bookmarksdepth<4 is not working, since it is ignoring that it is level 4).

enter image description here

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{hyperref}

\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}
\hypersetup{bookmarksdepth=4}

\makeatletter
\newcounter{subsubsubsection}[subsubsection]
\renewcommand{\thesubsubsubsection}{\thesubsubsection.\arabic{subsubsubsection}}
\renewcommand{\theparagraph}{\thesubsubsubsection.\arabic{paragraph}}

\newcommand{\subsubsubsection}{\@startsection{subsubsubsection}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\it\bfseries}}
\renewcommand{\paragraph}{\@startsection{paragraph}{5}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}
\renewcommand{\subparagraph}{\@startsection{subparagraph}{6}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\normalfont\normalsize\bfseries}}

\newcommand*{\l@subsubsubsection}{\@dottedtocline{4}{11em}{5em}}  
\renewcommand*{\l@paragraph}{\@dottedtocline{5}{12em}{6em}}
\renewcommand*{\l@subparagraph}{\@dottedtocline{6}{14em}{7em}}

\newcommand{\subsubsubsectionmark}[1]{}
\makeatother

\begin{document}

\tableofcontents

\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\subsubsubsection{SubsubsubSection}


\end{document}
2
  • I don't know if it suits your needs, but maybe the bookmark package (that fixes some strange behaviors of hyperref) can be useful
    – Moriambar
    Commented Oct 21, 2015 at 14:49
  • latex provides section levels below subsubsection by default, why insert a new one in the middle of the sequence? Do you really need all 6 levels? Commented Oct 21, 2015 at 14:49

2 Answers 2

3

If this is really needed, use bookmark package, say depth=3 as option (i.e. only down to subsubsection) and (more important!!!):

You've to specify the level in which the new subsubsubsection has to be hooked to:

\newcommand{\toclevel@subsubsubsection}{4}

This way you inform hyperref (and the bookmark) package, that subsubsubsection counters are on level 4.

\documentclass{book}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{hyperref}
\usepackage[depth=3]{bookmark}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{4}
%\hypersetup{bookmarksdepth=4}



\makeatletter

\newcommand{\toclevel@subsubsubsection}{4}
\newcounter{subsubsubsection}[subsubsection]

\renewcommand{\thesubsubsubsection}{\thesubsubsection.\arabic{subsubsubsection}}


\renewcommand{\theparagraph}{\thesubsubsubsection.\arabic{paragraph}}

\newcommand{\subsubsubsection}{\@startsection{subsubsubsection}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\it\bfseries}}
\renewcommand{\paragraph}{\@startsection{paragraph}{5}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}
\renewcommand{\subparagraph}{\@startsection{subparagraph}{6}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\normalfont\normalsize\bfseries}}

\newcommand*{\l@subsubsubsection}{\@dottedtocline{4}{11em}{5em}}  
\renewcommand*{\l@paragraph}{\@dottedtocline{5}{12em}{6em}}
\renewcommand*{\l@subparagraph}{\@dottedtocline{6}{14em}{7em}}

\newcommand{\subsubsubsectionmark}[1]{}
\makeatother

\begin{document}

\tableofcontents

\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
\phantomsection
\subsubsubsection{SubsubsubSection}


\end{document}

enter image description here

0

I add this as a follow-up answer for those (like me) having a similar setup and problem. I created a subsubparagraph (level 6) that works fine in TOC but PDF bookmarks resets it to chapter (level 1) along with every header that follows it. I'm using PDFLaTex. To fix the problem, I only needed to add the previous answer's \toclevel solution modified for subsubparagraph, (\newcommand{\toclevel@subsubparagraph}{6}) to my \@startsection as in the MWE. Pic: left, the problem: subsubsection put at chapter level; right pic, as fixed.

\documentclass{book}
\usepackage[bookmarksopen]{hyperref} %,pdfview=Fit %to open bookmark to top of page
\usepackage{bookmark}
\setcounter{secnumdepth}{6} %make sure my subsects all numbered to lowest level
\setcounter{tocdepth}{6} %tell toc to include all numbered subsects as above
\makeatletter
\newcounter{subsubparagraph}[subparagraph]% counter for numbering
\renewcommand{\thesubsubparagraph}%               how to display 
{\thesubparagraph.\@arabic\c@subsubparagraph}%  numbering
\newcommand{\subsubparagraph}{\@startsection
    {subsubparagraph}%
    {6}%
    {0pt}%
    {3.25ex \@plus 1ex \@minus .2ex}% %\baselineskip
    {1.5ex plus 0.2ex}% %\0.5\baselineskip
    {\usefont{OT1}{phv}{c}{sc}\selectfont\fontsize{9}{9}}} %\scshape}}
\newcommand{\toclevel@subsubparagraph}{6} %added to fix pdf bookmark hierarchy
\newcommand*\l@subsubparagraph{\@dottedtocline{6}{10em}{5em}}% for toc
\newcommand{\subsubparagraphmark}[1]{}% for page headers
\makeatother


\begin{document}
     \part{TEST}
     \chapter{chaptest}
     kdkd
     \section{sectest}
     kdkd
     \subsection{subsectest}
     ddk
     \subsubsection{subsubsectest}
     dkdk
     \paragraph{paratest}
     dkdk
     \subparagraph{subpartest}
     dkdk
     \subsubparagraph{subsubpartest}
     dkdkd
     \paragraph{postssptest}
     dkdk
     \subsubsection{postssstest}
     kdkd
     \chapter{postchaptest}
     kdkd
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .