扩展(针对 PDF ToC)biblatex 的引用命令

扩展(针对 PDF ToC)biblatex 的引用命令

对于研究报告,我想将一些引用的论文嵌入为 PDF(带有\includepdf)。由于所有相关元数据都可以在 bibtex 数据库中找到,并且 PDF 文件名也可以从 bibtex 键中计算出来。因此,我希望有一个\IncludePaper{<bibtex key>}命令,它 (a) 在目录中创建一个包含论文标题的条目,并且 (b) 包含 PDF:

\documentclass{book}

\usepackage{filecontents}
\usepackage[defernums=true, hyperref, backref, refsegment=chapter]{biblatex}
\usepackage{hyperref}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {The Alpha Paper},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {The Bravo Paper},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {The Charlie Paper},
}
\end{filecontents}

% The bibtex database to use (\bibliography{bibliotest} in your case)
\bibliography{\jobname}

\newcommand{\IncludePaper}[1]{%
  \phantomsection{}
  \addcontentsline{toc}{section}{\citeyear{#1}: \citetitle{#1}}
% \includepdf[pages=-,pagecommand={}]{#1.pdf}
}

\begin{document}


\tableofcontents

\nocite{*}
\printbibliography

\chapter{Papers}
  \IncludePaper{A01}
  \IncludePaper{B02}
\end{document}

这种方法效果相对较好,包括目录中的精彩条目。在PDF 目录 (PDF 查看器左侧的树视图),但是,只出现引用键。

在此处输入图片描述

我猜测这是因为\citeyear\citetitle是受保护的命令,在创建 PDF ToC 时不会展开。

有没有办法只获取这些命令的纯文本结果并\addcontentsline以某种方式传递它,以便 PDF ToC 包含论文的年份和标题?

答案1

除了使用\newcommand定义之外\IncludePaper,还可以使用biblatex工具创建一个新的引用命令,以便可以访问所有biblatex功能,例如:

\DeclareCiteCommand{\IncludePaper}{}{
  \phantomsection{}
  \addcontentsline{toc}{section}{\thefield{year}\addcolon\addspace\thefield{title}}
}{}{}

答案2

usebib包可以做到:

\documentclass{book}

\usepackage{filecontents}
\usepackage[defernums=true, hyperref, backref, refsegment=chapter]{biblatex}
\usepackage{hyperref}
\usepackage{usebib}

\begin{filecontents}{\jobname.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {The Alpha Paper},
}
@misc{B02,
  author = {Buthor, B.},
  year = {2002},
  title = {The Bravo Paper},
}
@misc{C03,
  author = {Cuthor, C.},
  year = {2003},
  title = {The Charlie Paper},
}
\end{filecontents}

% The bibtex database to use (\bibliography{bibliotest} in your case)
\bibliography{\jobname}
\bibinput{\jobname}

\newcommand{\IncludePaper}[1]{%
  \phantomsection{}
  \addcontentsline{toc}{section}{\usebibentry{#1}{year}: \usebibentry{#1}{title}}
% \includepdf[pages=-,pagecommand={}]{#1.pdf}
}

\begin{document}


\tableofcontents

\nocite{*}
\printbibliography

\chapter{Papers}
  \IncludePaper{A01}
  \IncludePaper{B02}
\end{document}

在此处输入图片描述

相关内容