\ifdef{\mainmatter}{}{\listofexample
\listofexercise
\listoftheorem}

\section{This is the first section}\label{this-is-the-first-section}

\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {1}{\ignorespaces {}}}{}\phantomsection\label{exercise:1}{\textbf{Exercise
1}}

This is the first exercise. Have also a look at the
\hyperref[theorem:first]{{Theorem 1.1 (Needed for the
\hyperref[exercise:second]{second exercise})}}, the
\hyperref[exercise:second]{{exercise 2}} and the
\hyperref[exercise:last]{{exercise 3}}.

\begin{quote}
\phantomsection\addcontentsline{theorem}{theorem}{\protect\numberline {1.1}{\ignorespaces {Needed for the \hyperref[exercise:second]{second exercise}}}}\phantomsection\label{theorem:this-is-the-first-section.needed-for-the-second-exercise}{}\phantomsection\label{theorem:first}{\emph{Theorem
1.1: Needed for the \hyperref[exercise:second]{second exercise}}}

This is a the first theorem. Look at the
\hyperref[exercise:second]{exercise}.
\end{quote}

\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {2}{\ignorespaces {}}}\phantomsection\label{exercise:this-is-the-second-exercise}{}\phantomsection\label{exercise:second}{\textbf{Exercise
2} \emph{(This is the second exercise)}}

Use \hyperref[theorem:first]{\emph{theorem 1.1} page
\pageref{theorem:first}}

\begin{description}
\tightlist
\item[\phantomsection\addcontentsline{example}{example}{\protect\numberline {1.1}{\ignorespaces {Example}}}\phantomsection\label{example:this-is-the-first-section.1}{}\phantomsection\label{example:1.1}{\textbf{Example
1}}]
This is the first example of the first section
\item[\phantomsection\addcontentsline{example}{example}{\protect\numberline {1.2}{\ignorespaces {Example}}}\phantomsection\label{example:this-is-the-first-section.2}{}\phantomsection\label{example:1.2}{\textbf{Example
2}}]
This is the second example of the first section
\end{description}

\section{This is the second section}\label{this-is-the-second-section}

\begin{description}
\tightlist
\item[\phantomsection\addcontentsline{example}{example}{\protect\numberline {2.1}{\ignorespaces {Example}}}\phantomsection\label{example:this-is-the-second-section.1}{}\phantomsection\label{example:2.1}{\textbf{Example
1}}]
This is the first example of the second section
\end{description}

\begin{quote}
\phantomsection\addcontentsline{theorem}{theorem}{\protect\numberline {2.1}{\ignorespaces {\(a=b\)}}}\phantomsection\label{theorem:this-is-the-second-section.a-b}{}\phantomsection\label{theorem:2.1}{\emph{Theorem
2.1: \(a=b\)}}

Another theorem. Can be useful in \hyperref[exercise:1]{}
\end{quote}

\begin{quote}
\phantomsection\addcontentsline{theorem}{theorem}{\protect\numberline {2.2}{\ignorespaces {Theorem}}}\phantomsection\label{theorem:this-is-the-second-section.2}{}\phantomsection\label{theorem:2.2}{\emph{Theorem
2.2}}

A last theorem.
\end{quote}

\begin{description}
\tightlist
\item[\phantomsection\addcontentsline{example}{example}{\protect\numberline {2.2}{\ignorespaces {Example}}}\phantomsection\label{example:this-is-the-second-section.2}{}\phantomsection\label{example:2.2}{\textbf{Example
2}}]
This is the second example of the second section
\end{description}

\phantomsection\addcontentsline{exercise}{exercise}{\protect\numberline {3}{\ignorespaces {}}}\phantomsection\label{exercise:3}{}\phantomsection\label{exercise:last}{\textbf{Exercise
3}}

This is the third exercise.

Unnumbered \#
