引文格式和 hyperref 包

发布于 2024-08-02 02:35:20 字数 530 浏览 7 评论 0原文

我在文档中使用 hyperref 包。 它所做的事情之一是根据目录在我的 pdf 中创建书签。 某些章节标题包含对引文的引用

\section{Some title \citep{BibTeXkey}}

书签的标签看起来像

Some title BibTeXkey

但我希望它

Some title (Author, year)

就像文本和目录中显示的那样。 所以只有书签被搞乱了。

我使用了序列 pdflatexbibtexpdflatexpdflatex 来编译文档。

如何更改书签标签以使用与目录中相同的格式?

I'm using the hyperref package in my document. One of the things that it does is create bookmarks in my pdf, based on the table of contents. Some section titles contain a reference to a citation

\section{Some title \citep{BibTeXkey}}

The label of the bookmark then looks like

Some title BibTeXkey

But I would like it to be

Some title (Author, year)

Just like it is displayed in the text and the table of contents. So only the bookmarks are messed up.

I used the sequence pdflatex, bibtex, pdflatex, pdflatex to compile the document.

How do I change the bookmark label to use the same format as in the table of contents?

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

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

发布评论

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

评论(2

在梵高的星空下 2024-08-09 02:35:20

每当我遇到 pdf 书签无法正常工作的问题时,解决方案通常是使用 \texorpdfstring。 它允许您使节标题包含一些非文本材料(如链接或一些符号),并指定 pdf 书签中应显示的内容,其中不能包含符号。 输入

\section{The section with \texorpdfstring{LaTeX symbols}{plain text version}}

生成部分标题“带有 LaTeX 符号的部分”,但该部分的 pdf 书签是“带有纯文本版本的部分”。

就您而言,最简单的事情可能是

\section{Some title \texorpdfstring{\citep{BibTeXkey}}{(Author, year)}}

不幸的是,这意味着您必须手动粘贴“(作者,年份)”,这有点烦人,但如果你的参考书目条目不会改变(这可能不应该改变),并且你不会改变你的引用约定。

如果您确实想避免手动输入“(作者,年份)”,您可以尝试使用 \show 命令尝试找出 \citep 如何生成其输出。 但我警告您,这种方法不适合胆小的人:在这种情况下,我认为您最终会查看 aux 文件,更不用说 blgbrfbbl 文件。

Whenever I'm having an issue with the pdf bookmarks not working properly, the solution is usually to use \texorpdfstring. It allows you to make a section title contain some non-text material (like a link or some symbols) and specify what should appear in the pdf bookmark, which cannot contain symbols. The input

\section{The section with \texorpdfstring{LaTeX symbols}{plain text version}}

produces the section title "The section with LaTeX symbols", but the pdf bookmark for the section is "The section with plain text version".

In your case, the easiest thing to do is probably

\section{Some title \texorpdfstring{\citep{BibTeXkey}}{(Author, year)}}

Unfortunately, this means that you have to paste "(Author, year)" in by hand, which is a little annoying, but not a big deal if your bibliography entry doesn't change (which is probably shouldn't) and you don't change your citation conventions.

If you really want to avoid having to type in "(Author, year)" by hand, you can try using the \show command to try to figure out how \citep produces it's output. But I warn you that this approach is not for the faint of heart: in this case, I think you'll end up looking through the aux file, not to mention the blg, brf, and bbl files.

苦行僧 2024-08-09 02:35:20

这可以通过包 bibentry 轻松完成。

\documentclass{article}

\usepackage[style=apa]{biblatex}
\usepackage{bibentry}

\addbibresource{\jobname.bib}

\begin{document}
\begin{filecontents}{\jobname.bib}
@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}
\end{filecontents}

\section{Some title \parencite{Labov1972}}

\end{document}

请注意,根据样式,上面的代码不一定会给出您想要的结果,即(作者,年份)。 如果您使用不同的样式,您可以使用以下命令完成相同的任务

\section{Some title (\citeauthor{Labov1972}, \citeyear{Labov1972})}

This can be done easily with the package bibentry

\documentclass{article}

\usepackage[style=apa]{biblatex}
\usepackage{bibentry}

\addbibresource{\jobname.bib}

\begin{document}
\begin{filecontents}{\jobname.bib}
@book{Labov1972,
    Address = {Philadelphia},
    Author = {William Labov},
    Publisher = {University of Pennsylvania Press},
    Title = {Sociolinguistic Patterns},
    Year = {1972}}
\end{filecontents}

\section{Some title \parencite{Labov1972}}

\end{document}

Notice that depending on the style, the above code will not necessarily give you the desired outcome, which is (Author, year). If you are using a different style, you can accomplish the same with

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