0


I have unnumbered sections in my appendix to which I want to refer to specifically.
As the sections are unnumbered, it always just shows the number of the chapter.

My example code:

\documentclass{scrbook}

\usepackage{xr-hyper} %for cross-referencing between documents
\usepackage[hidelinks]{hyperref} % Hyperlinks

\begin{document}

\chapter{Main Document}

Here I refer to appendix \ref{Appendix_1}, appendix \ref{Appendix_2} and appendix \ref{Appendix_3}.

\chapter{Appendix}
\section*{A.1 Appendix 1}
\label{Appendix_1}

My first Appendix.

\section*{A.2 Appendix 2}
\label{Appendix_2}

My second Appendix.

\section*{A.3 Appendix 3}
\label{Appendix_3}

My third Appendix.

\end{document}

It looks like this:

enter image description here

I already tried https://tex.stackexchange.com/a/48610/234353 but that did not work.

Would appreciate any help!

2
  • 1
    The \label/\ref always references the last stepped counter. Since starred sections are unnumbered, the \labels all refer to the chapter. Why do you use unnumbered sections if you want to reference them? – campa Feb 4 at 12:31
  • Because I don't want the appendix to be numbered in the toc. Is there a way to adjust the counter? – Matthias Feb 4 at 12:42
1

A \label always points to the last stepped reference counter, so using unnumbered sections cannot work. If you only have one appendix I would use the following dirty trick

\documentclass[paper=a5,openany]{scrbook}% a5,openany only for smaller snapshot

\usepackage{hyperref}

\begin{document}

\tableofcontents

\chapter{Main Document}
\section{Foo}
Here I refer to appendix \ref{Appendix_1},
appendix \ref{Appendix_2} and appendix \ref{Appendix_3}.
\section{Baz}

\addtocontents{toc}{\setcounter{tocdepth}{0}} % remove sections from ToC
\addchap{Appendix} % unnumbered but printed in ToC
\refstepcounter{chapter} % necessary for working bookmarks
\renewcommand{\thesection}{A.\arabic{section}}
\section{Appendix 1}
\label{Appendix_1}
My first Appendix.

\section{Appendix 2}
\label{Appendix_2}
My second Appendix.

\section{Appendix 3}
\label{Appendix_3}
My third Appendix.

\end{document}

enter image description here

1
  • Thank you! I actually found another workaround with hyperlinks – Matthias Feb 4 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.