# Cross-referencing within text

Is there a way to reference a place in the text using \hyperref, instead of using \nameref to reference the section that portion of text belongs to?

Probably a WME will help in getting my point across:

\documentclass[onecolumn,twoside]{revtex4}

\usepackage{xpatch}% http://ctan.org/pkg/xpatch
\makeatletter
\xpatchcmd{\@ssect@ltx}{\@xsect}{\protected@edef\@currentlabelname{#8}\@xsect}{}{}%    Patch \<section>*
\xpatchcmd{\@sect@ltx}{\@xsect}{\protected@edef\@currentlabelname{#8}\@xsect}{}{}% Patch \<section>
\makeatother
\usepackage{hyperref}% http://ctan.org/pkg/hyperref

hypersetup{pdfstartview=FitH,pdfpagemode=UseNone}

\begin{document}

\title{Title}
\author{Author}
\affiliation{Affiliation}

\maketitle

\section*{FirstSection--$E \times H$ vs.$\ \textbf{E} \times \textbf{H}$}
text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text   text text text text
\bf I want to return here, not at the beginning of FirstSection \rm    \label{sec:marker1} \nameref{sec:marker2}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\section*{SecondSection} \label{sec:marker2}
You can also see in \nameref{sec:marker1} that \ldots
\end{document}

-
Are you interested in obtaining the section title or just the section number? Also, add some more detail around the use of revtex and why previous questions answered in this respect didn't answer your question. –  Werner Feb 19 '12 at 3:14
I believe the OP thought referencing for PDF shortcut, am I wrong? –  yo' Feb 19 '12 at 3:17
Werener, previous questions did give an answer when you need to go back to the beginning of a section. But, suppose, you have a large amount of text that belongs to the section, say several pages long, and the point you're referencing is buried somewhere in the third page. You don't want to go back to the beginning of the section and go through all three pages to get back to that particular sentence. Hope I explained it clearly why I need that kind of cross-referencing. –  ganzewoort Feb 19 '12 at 3:22
@ganzewoort: You need to tell us why REVTeX is so important, and why you are refusing to use revtex4-1. I don't know about anyone else, but I'm inclined to ignore your questions until you begin using a maintained document class. As I've said before, there was about 10 years between 4 and 4.1, so this makes a huge difference. –  qubyte Feb 19 '12 at 6:21

Issue a \phantomsection just before marking the \label. \phantomsection sets a PDF mark for subsequent \labels that the accompanying \ref will jump to (forward or backward). See section 4 Additional user macros of the hyperref documentation.

Here is your minimal example showing the location:

\documentclass[onecolumn,twoside]{revtex4}

\usepackage{xpatch}% http://ctan.org/pkg/xpatch
\makeatletter
\xpatchcmd{\@ssect@ltx}{\@xsect}{\protected@edef\@currentlabelname{#8}\@xsect}{}{}%    Patch \<section>*
\xpatchcmd{\@sect@ltx}{\@xsect}{\protected@edef\@currentlabelname{#8}\@xsect}{}{}% Patch \<section>
\makeatother
\usepackage{hyperref}% http://ctan.org/pkg/hyperref

\hypersetup{pdfstartview=FitH,pdfpagemode=UseNone}

\begin{document}

\title{Title}
\author{Author}
\affiliation{Affiliation}

\maketitle

\section*{\texorpdfstring{FirstSection--$E \times H$ vs.$\ \textbf{E} \times \textbf{H}$}{FirstSection-E x H vs. E x H}}
text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text text text   text text text text text text text text text text text text text text text text   text text text text
\bf I want to return here, not at the beginning of FirstSection \rm \phantomsection   \label{sec:marker1} \nameref{sec:marker2}
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text

\section*{SecondSection} \label{sec:marker2}
You can also see in \nameref{sec:marker1} that \ldots
\end{document}


In the above example, you'll notice the use of \texorpdfstring{<tex>}{<pdf>} which eliminates your hyperref warnings regarding bookmarks.

-
Thanks @Werner. Works great. I didn't even need to add \texorpdfstring{<tex>}{<pdf>}. –  ganzewoort Feb 19 '12 at 3:49
@ganzewoort: Thanks means nothing without an upvote! That's how SE works. –  qubyte Feb 19 '12 at 6:22
@ganzewoort: And you can (please) accept an answer by clicking at the check-mark located below the down-vote-arrow. –  Stephen Feb 19 '12 at 17:13
Sorry about that. Just checked it. Hope I did it right. –  ganzewoort Feb 19 '12 at 20:38

You can define your own block which you refer to. Take a look at this example and see if it works for you.

\documentclass{article}
\usepackage{lipsum}
\usepackage{hyperref}

\newcommand{\placeref}[1]{%
\newcounter{foo}%
\refstepcounter{foo}\label{#1}}

\begin{document}
Some text here: this is where we \placeref{goplace} go.

\lipsum[30]

\newpage
Take a look at page \ref{goplace} for details.

\end{document}

-
this seems to be referencing the page, not the particular place in the text of that page which you want referenced. –  ganzewoort Feb 19 '12 at 3:26
Hnn. Maybe I didn't understand your requirement fully but if you want to reference the "place", what's wrong with simply using \ref with the section's label? –  recluze Feb 19 '12 at 3:32
Sorry, @recluze, I take that back. This is exactly what I want. I checked it in my text. How do you replace the '1' as a reference, with text? –  ganzewoort Feb 19 '12 at 3:32
Never mind. Just saw your explanation on the question in the comment and I know what you mean. My answer wouldn't be valid (unless you use it in conjunction with the section label like, "See Section X (page Y) for details"). –  recluze Feb 19 '12 at 3:34
Hehe. Not sure about that though. Maybe you can use nameref somehow. Try posting a follow up question or update to this question to see if someone else can improve it. –  recluze Feb 19 '12 at 3:35