while writing my thesis I became aware of a problem related to the algorithm2e package regarding the label referencing of subsubsections following an algorithm. Here is a simple example:
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[linesnumbered,ruled,commentsnumbered]{algorithm2e}
\usepackage[hidelinks]{hyperref}
\begin{document}
\section{Test}\label{section:test}
This is a test.
\subsection{Test Subsection}\label{subsection:test}
We ref \ref{subsection:test}
Now follows in Alg. \ref{alg:testalgo}:
\newline
\SetAlFnt{\small\sffamily}
\newcommand\mycommfont[1]{\footnotesize\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
\begin{algorithm}[H]
\caption{test}
\label{alg:testalgo}
\DontPrintSemicolon
\SetNoFillComment
i = 1\;
i = i + 1\;
i = 2\;
\end{algorithm}
\subsubsection{Subsubsection Test}\label{subsubsection}
Lets ref the subsubsection \ref{subsubsection}
\end{document}
As you can see, instead of the chapter number, the last linenumber of the algorithm is displayed. If I add more lines, this number changes too. If you remove the algorithm, the cross referencing works without problems, see here:
\documentclass[headsepline,footsepline,footinclude=false,oneside,fontsize=11pt,paper=a4,listof=totoc,bibliography=totoc]{scrbook}
\usepackage[utf8]{inputenc}
\usepackage[linesnumbered,ruled,commentsnumbered]{algorithm2e}
\usepackage[hidelinks]{hyperref}
\begin{document}
\section{Test}\label{section:test}
This is a test.
\subsection{Test Subsection}\label{subsection:test}
We ref \ref{subsection:test}
\subsubsection{Subsubsection Test}\label{subsubsection}
Lets ref the subsubsection \ref{subsubsection}
\end{document}
Does anyone have a solution or fix for this?
EDIT: If an algoritm is followed by a chapter, a section, or a subsection, this does not happen in the above example. Only with a subsubsection that follows the algorithm