3

for the structure of my work I need an unnumbered chapter in my document. I found out to solve that with a

\chapter*{chapter1} %or with
\addchap{chapter1}

But now I need to refer to a text and a image of this chapter from another one. The hyperlink works perfectly, but therefore that I dont have a numeration, the number of the chapter before is used for it (even in my list of figures).

To make it more clear what my problem is I have a minimal example here:

\documentclass{scrreprt}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Something}
\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment. See here: \ref{my_reference}.
\chapter{Chapter 2}
\section{\ldots}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\addchap{Attachment}
\section*{First Attachment}
\addcontentsline{toc}{section}{First Attachment}
\subsection*{This is very important stuff}
\addcontentsline{toc}{subsection}{This is very important stuff}
\label{my_reference}
Yeah this stuff is so important, that i definitly want to refer this text in
the first chapter.
\end{document}

I get as result: "See here: 5." But I want a

"See here: 6.1.1."

But I don't my "Attachment" chapter to have a number in TOC. Is that even possible? I thought about numbering it by myself with a custom "label" command. But the problem stays, because of my "list of figures" problem.

Thanks in advance

  • 3
    If your section/chapter is unnumbered, why should any reference to it get a clue like 6.1.1 ? ;-) Welcome to TeX.SX! The result of the reference is 5 because it is some last counter being \refstepcountered before, in this case Chapter 5, so the cause must be the chapter counter – user31729 Nov 16 '14 at 18:25
  • 2
    if the item being referred to has no assigned number, then perhaps it would be better to refer to it by page number -- \pageref{labelanem}. – barbara beeton Nov 16 '14 at 18:29
  • yeah i do understand why the result is the way it is ;-) but I want the counter being incremented without having this number in my toc. I would be okay with the subsection getting a number in the toc. So my "Attachment" chapter is unnumbered (in toc) but the subsection can still have a number (if there is no other way). – Tom Mekken Nov 16 '14 at 18:41
  • Why not using something like \nameref to refer to the section? – Johannes_B Nov 16 '14 at 21:48
  • 1
    Why are you using addchap but not addsec? – Johannes_B Nov 16 '14 at 21:58
4
\documentclass{scrreprt}
\begin{document}
\tableofcontents
\chapter{Chapter 1}
\section{Something}
\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment. See here: \ref{my_reference}.
\chapter{Chapter 2}
\section{\ldots}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\addchap{Attachment}\refstepcounter{chapter}
\section*{First Attachment}\refstepcounter{section}
\addcontentsline{toc}{section}{First Attachment}
\subsection*{This is very important stuff}\refstepcounter{subsection}
\addcontentsline{toc}{subsection}{This is very important stuff}
\label{my_reference}
Yeah this stuff is so important, that i definitly want to refer this text in
the first chapter.
\end{document}
  • you sir deserve a medal :-) this was exactly what I was looking for. thank you very very much – Tom Mekken Nov 16 '14 at 18:53
  • Why are you using section* and later do the \addcontentsline? You can use addsec and issue the refstepcounter nontheless. Doing the latter won't break some internal features. – Johannes_B Nov 16 '14 at 21:45
  • @Johannes_B It's the OP's document, I just added \refstepcounter (apart from the fact I've never heard of \addsec, I don't really know the koma classes that well:-) – David Carlisle Nov 16 '14 at 21:51
1

I suspect that many readers will be quite confused when they encounter a cross-reference to an object numbered "6.1.1" even though no single object in the document is actually numbered "6.1.1". Is it reasonable to assume that your readers will figure out that the object being cross-referenced is an unnumbered subsection?

I understand that hyperref will be loaded (although that's not currently the case in your example code). If this assumption is correct, a solution is available that doesn't depend on creating dummy section and subsection numbers that don't actually show up anywhere. I suggest you (a) insert a "\hypertarget" at the start of the unnumbered subsection, say via

\addchap{Attachment}
\section*{First Attachment}
\addcontentsline{toc}{section}{First Attachment}
\hypertarget{my_ref}{}  %% <- this is the crucial addition
\subsection*{This is very important stuff}
\addcontentsline{toc}{subsection}{This is very important stuff} 

and (b) insert a \hyperlink instruction in some other place in the document from where the reader is encouraged to "jump" to the attachment:

\subsection{Subsection 1}
At this point I'd like to refer to an Image and a short text in the
attachment: \hyperlink{my_ref}{See here}.

With this setup, the string "See here" is clickable, and if a reader clicks on this string, he/she will be taken straight to the attachment of interest.

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.