0

I am trying to create a link in a subsection of the main report to redirect to a subsection of the Appendix in an .Rnw file in Studio. Here is what I have tried. Although I do not get an error, and it produces a PDF file, there does not seem to be the intended link:

\documentclass{article}
\usepackage{float, hyperref}
\usepackage[margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{hyperref}

\begin{document}
\SweaveOpts{concordance=TRUE}

\title{The Title}

\maketitle

<<options, echo=FALSE>>=
library(knitr)
  opts_chunk$set(cache=TRUE)
@

\section*{Introduction}

I have my introduction here.

\subsection*{Subsection}

I have my subsection here. I would like to link to the subsection of the appendix at the end of this sentence; how can I do that See ~\ref{subsec:firstPoint}.

\section*{Conclusion}

I have my conclusion here.

\section*{Appendix}

\subsection*{First Point}
\label{subsec:firstPoint}

Here is where I want my link above to point to.

\end{document}

Any advice on how to achieve this link would be greatly appreciated!

1 Answers1

0

You are trying to create a link to an unnumbered section, which fails to give you the number of the section, because there is none.

If you change your Appendix, it works:

\section*{Appendix}
\subsection{First Point}
\label{subsec:firstPoint}

Screenshot

Is there a reason, you are using \subsection*{First Point} instead of \subsection{First Point}?

Thomas K
  • 3,242
  • 15
  • 29
  • Thank you Thomas K. I am still getting an error when I remove the last three lines of my code above and substitute them with your three lines. (" Reference `subsec:firstPoint` on page 1 undefined on input line 25.") Did I understand your suggestion correctly? Also, there is not a reason I know for using the asterisk after \subsection - it is my lack of skills I think. I am sorry, and thanks for your help. –  Apr 27 '15 at 03:40
  • @LanneR No need to be sorry. If you remove all the asterisks, you will get proper numbering of the sections throughout the document - that's the standard LaTeX behaviour. Asterisks, as you saw, are for cases, where you don't want your section numbered. – Thomas K Apr 27 '15 at 07:51
  • About the error: Are you using RStudio, or are you knitting and compiling your document manually? In the latter case, compiling the document twice should make the reference show up and the error disappear. – Thomas K Apr 27 '15 at 07:51
  • Thank you for the explanation, Thomas K! Yes, I am just using RStudio, so I guess I will not need to compile twice. Thanks again... –  Apr 28 '15 at 03:46