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


