I am trying to make my document such that when you click on section or subsection titles in the main body, it will take you back to the TOC. I have implemented this as such:
\makeatletter
\let\oldcontentsline\contentsline%
\renewcommand\contentsline[4]{%
\oldcontentsline{#1}{\smash{\raisebox{1em}{\hypertarget{toc#4}{}}}#2}{#3}{#4}}%
\let\oldsection\section%
\renewcommand\section[1]{%
\oldsection[#1]{\protect\hyperlink{tocsection.\thesection}{#1}}}%
\let\oldsubsection\subsection%
\renewcommand\subsection[1]{%
\oldsubsection[#1]{\protect\hyperlink{tocsubsection.\thesubsection}{#1}}}%
\let\oldsubsubsection\subsubsection%
\renewcommand\subsubsection[1]{%
\oldsubsubsection[#1]{\protect\hyperlink{tocsubsection.\thesubsection}{#1}}}%
\makeatother
Although it works, at the top of my TOC I get this:
I know it has something specific to do with the \renewcommand\section, because if I change that then it works fine.
How can I go about fixing this?
