文本内的交叉引用

文本内的交叉引用

有没有办法使用 来引用文本中的某个位置\hyperref,而不是使用\nameref来引用该部分文本所属的部分?

也许 WME 可以帮助我表达我的观点:

\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}

答案1

\phantomsection在标记 之前发出\label\phantomsection为后续 s 设置 PDF 标记\label,随附内容\ref将跳转到该标记(向前或向后)。请参阅章节4 附加用户宏hyperref文档

这是显示位置的最小示例:

\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}

在上面的例子中,您会注意到使用\texorpdfstring{<tex>}{<pdf>}它可以消除hyperref有关书签的警告。

答案2

您可以定义您自己的引用块。查看此示例,看看它是否适合您。

\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}

相关内容