如何在 LaTeX 中发出参考文献的文本内容?

发布于 2024-07-13 03:38:31 字数 367 浏览 2 评论 0原文

我有一个部分:

\section{Introduction} \label{sec:introduction}

我想要一个指向该部分的链接,其中链接文本是该部分的名称。 我可以使用 hyperref

The \hyperrf[sec:introduction]{Introduction} introduces the paper.

但这需要重复部分标题(“简介”)。 有办法抓住吗? ref 产生节号,这是不正确的。 autoref 产生“section”,然后是节号,这也是不正确的。

I have a section:

\section{Introduction} \label{sec:introduction}

I'd like a link to the section where the link text is the name of the section. I can use hyperref:

The \hyperrf[sec:introduction]{Introduction} introduces the paper.

But that requires repeating the section title ("Introduction"). Is there a way to grab that? ref yields the section number, which isn't right. autoref yields "section " and then the section number, which isn't right, either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

橙幽之幻 2024-07-20 03:38:31

有几个软件包可以为您提供此服务。 nameref 作为 hyperref 的一部分进行分发以实现此目的:
https://ctan.org/pkg/nameref

基本上有一个更通用的交叉引用包任何东西,称为 zref:
https://ctan.org/pkg/zref

与 hyperref 为同一作者 Heiko Oberdiek; 这是我会选择的。 这是一个示例:

\documentclass[oneside,12pt]{article}
\usepackage[user,titleref]{zref}
\begin{document}
\section{Introduction of sorts.}\zlabel{sec:intro}
Hello
\subsection{Structure}
We begin in `\ztitleref{sec:intro}'.
\end{document}

请注意,它甚至删除了部分标题中的尾随句点。

There are a couple of packages that provide this for you. nameref is distributed as part of hyperref to do this:
https://ctan.org/pkg/nameref

There is a more general package for cross-referencing basically anything, called zref:
https://ctan.org/pkg/zref

It's by the same author as hyperref, Heiko Oberdiek; it's the one that I would choose. Here's an example:

\documentclass[oneside,12pt]{article}
\usepackage[user,titleref]{zref}
\begin{document}
\section{Introduction of sorts.}\zlabel{sec:intro}
Hello
\subsection{Structure}
We begin in `\ztitleref{sec:intro}'.
\end{document}

Note that it even removes the trailing period in the section title.

陌路黄昏 2024-07-20 03:38:31

据我所知,没有标准方法可以做到这一点。 简而言之,分段命令不会将节的名称存储在可以轻松检索的任何地方。 是的,它们被插入到目录(以及相关的辅助文件)中并设置了标记,但是对这些内容的访问充其量是不可靠的,并且如果没有额外的上下文通常是不可能的,而当您需要返回时,这些上下文几乎总是不可用的到该部分。

您发布的代码示例看起来像我会写的。 可能有一个包可以自动执行此操作,但如果存在的话,它可能是相当复杂的代码,因为这实际上不是一个特别常见的用例。 事实上,要对你进行所有语法纳粹攻击,你创建的最终文本是不正确的; 句子中的“introduction”一词应该是小写的,并且(通常)通过反向引用实际的章节标题无法实现这一点。

我只是把它吸干,然后手动写出这样的参考文献。 它们的数量不足以证明自动化的合理性。 当然,如果您正在做的事情比您的示例建议的更复杂(许多自动生成的部分或其他内容),那么情况可能会有所不同,但如果是这种情况,那确实是一个完全不同的问题。

As far as I know, there's no standard way to do this. Simply put, the sectioning commands don't store the names of the sections anywhere they can be easily retrieved. Yes, they're inserted into the Table of Contents (and associated auxiliary file) and marks are set, but access to those is unreliable at best and usually impossible without additional context, which is almost always unavailable by the time you need to refer back to the section.

The code sample you posted looks like what I would write. There might be a package to automate this, but if one exists it's probably pretty hairy code since this is really not a particularly common use case. Actually, to go all grammar nazi on you the final text you're creating is incorrect; the word "introduction" should be lowercase inside the sentence, and this can't be achieved (in general) with backreferences to the actual section titles.

I'd just suck it up and write out references like this manually. There won't be enough of them to justify automation. Of course, if you're doing something more involved than your example suggests (many auto-generated sections or something) things might be different, but if that's the case it's really a different question entirely.

瘫痪情歌 2024-07-20 03:38:31

您可以尝试使用

  • \newsavebox
  • \savebox
  • \usebox

它不会为您节省任何输入,但将为您提供每个标题的单一权威来源


你可以搜索ctan.org,我怀疑这已经完成了。

You could try using

  • \newsavebox
  • \savebox
  • \usebox

which won't save you any typeing but will give you a single authoritative source for each title


And you might search ctan.org, I suspect this has been done already.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文