1

My document is using KOMA-script and unnumbered parts are added via \addpart. However, using standard \label{} following the part does create a link to the part. How can I do this?

Here is an MWE:

\documentclass{scrbook} % or scrreprt, scrartcl, etc.
\usepackage{hyperref}
\begin{document}


\addpart{Introduction}
\label{part:intro}

\section{Section}

    This is the introduction. Part~\ref{part:methods}

\part{Methods}
\label{part:methods}

\section{Section}

    These are the methods. Part~\ref{part:discussion}
    
    This is the introduction. Part~\hyperlink{part:discussion}{3}

\addpart{Discussion}
\label{part:discussion}


\end{document}
0

1 Answer 1

2

The last label is never written in your example, because the \label{part:methods} is after the output of the last page, which is already done with \addpart{Discussion}. So you would need to add some more text before \end{document} to really write the label to the aux-file and be able to refer to it. However the reference would always be a page too late (but not the link anchor, see the hyperref manual for more information about the position of the link anchor).

All your part labels should IMHO be placed inside the \part resp. \addpart argument to write them already with the part page to the aux-file.

Additionally \ref{part:discussion} would not make sense. Because you are using a not numbered “Discussion” part, the part counter, which \label would write to the aux-file and \ref would refer to, is not in increased using \refstepcounter. So still the section counter is the currently referred counter. You can see this here:

\documentclass{scrbook} % or scrreprt, scrartcl, etc.
\usepackage{hyperref}
\begin{document}


\addpart{Introduction\label{part:intro}}

\section{Section}

    This is the introduction. Part~\ref{part:methods}

\part{Methods\label{part:methods}}

\section{Section}

    These are the methods. Part~\ref{part:discussion} (the number does not
    make sense resp. is still the section, because the part is not numbered).
    
    This is the introduction. Part~\hyperlink{part:discussion}{3}

    \addpart{Discussion\label{part:discussion}}

\end{document}

enter image description here

If you really want to refer to a not numbered part do it either with page number or name:

\documentclass{scrbook} % or scrreprt, scrartcl, etc.
\usepackage{hyperref}
\begin{document}


\addpart{Introduction\label{part:intro}}

\section{Section}

    This is the introduction. Part~\ref{part:methods}

    \part{Methods\label{part:methods}}
    \label{part:methods2}% this is too late as you can see in the page
                         % reference below.

\section{Section}

    These are the methods. Part ``\nameref{part:discussion}'' starts at
    \autopageref{part:discussion}.

    \nameref{part:methods} is at \autopageref{part:methods} not \autopageref{part:methods2}.
    
\addpart{Discussion\label{part:discussion}}

\end{document}

enter image description here

1
  • Thanks a lot! I didn't even know you could put labels into the argument of part (or any other) definitions.
    – mapf
    May 15 at 13:06

You must log in to answer this question.

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