引用长文特定部分的好方法?

引用长文特定部分的好方法?

下面的示例编译并生成一个可点击的链接,但在打印版本中,不清楚链接指向何处。

我想解决这个问题,我可以用类似的方式实现某种反向链接,但我觉得有更优雅的方法(也许是专门的包?)来解决这个问题,特别是如果涉及许多此类链接。

至于这些参考文献在文档中的具体显示方式,我持开放态度。可能是行号、某种彩色标记或其他完全不同的东西。最好的情况是参考文献在数字和印刷版中来回转换。有什么建议吗?

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage{lipsum}
\begin{document}
The most important thing to understand in this course is
that dogs don't like cats \hyperref[ref:DogsCats]{(see here)}.

% rest of the document
\lipsum[1-10]

% in appendix:
Some wall of text that explains how animals
don't always like each other. This text is really long
so a reference to the section isn't precise enough,
and it can't be changed or reformatted in any way.
For example, monkeys don't like bats,
crocodiles don't like pangolins,
50 other animals also don't like each other,
dogs don't like cats \phantomsection\label{ref:DogsCats},
mice don't like rabbits, and a good 30 more examples.
\end{document}

答案1

您可以使用\hypertarget{label#1}{sentence in appendix}

要引用此内容,请使用\hyperlink{label#1}{sentence that refers to appendix}

注意标签是相同的。

两种情况下的后一个括号都会显示在文本中

答案2

lineno这是我使用本网站上的其他一些答案拼凑起来的。它不能满足我的所有要求,但它相对简单,对我来说已经足够好了。

\documentclass{article}
\usepackage[colorlinks]{hyperref}
\usepackage[pagewise,right]{lineno}
\usepackage{lipsum}

\newcommand{\llabel}[1]{%
\hypertarget{llineno:#1}{\linelabel{#1}}}

\newcommand{\linepageref}[1]{%
page~\hyperlink{llineno:#1}{\pageref*{#1}}\ %
line~\hyperlink{llineno:#1}{\ref*{#1}}}

\begin{document}
\section{Document}
The most important thing to understand in this course is
that dogs don't like cats [\linepageref{ref:DogsCats}].
\section{Appendix}
\begin{linenumbers}
Some wall of text that explains how animals
don't always like each other. This text is really long
so a reference to the section isn't precise enough,
and it can't be changed or reformatted in any way.
For example, monkeys don't like bats,
crocodiles don't like pangolins,
50 other animals also don't like each other,
dogs don't like cats \llabel{ref:DogsCats},
mice don't like rabbits, and a good 30 more examples.
\end{linenumbers}
\end{document}

截屏

相关内容