如何自动包含 bib 文件中的 PDF

如何自动包含 bib 文件中的 PDF

我使用 Mendeley 生成的 BIB 列表,其中包含一个名为“文件”的项目,其中包含每个条目的 PDF 路径。

我需要生成一份论文汇编,并且我想按照以下方式自动完成。

\usepackage{biblatex}
\usepackage{pdfpages}

\fullcite{foo}
\includepdf{\readfilefrom{foo}}.

因此,我正在寻找一个函数,给定一个 bib 项,它将返回保存在file我的 bib 文件条目中的路径。

号码布输入示例:

@inproceedings{foo,
address = {Aachen, Germany},
author = {Masiero, Bruno },
booktitle = {DAGA},
file = {:D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Fels_2011_Equalization for Binaural Synthesis with Headphone.pdf:pdf},
month = mar,
title = {Equalization for Binaural Synthesis with Headphone},
year = {2011}
}

文件字段的其他一些示例包括:

file = {:D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Pelzer\_2010\_Study of Phase Reconstruction Methods Employed at Room Acoustic Simulation.pdf:pdf},

file = {:D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Pollow\_2010\_A review of the compressive sampling framework in the lights of spherical harmonics applications to distributed spherical arrays.pdf:pdf},

file = {::D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Pollow, Fels\_2011\_Design of a Fast Broadband Individual Head-Related Transfer Function Measurement System.pdf:pdf},

file = {:D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Qiu\_2009\_Two Listeners Crosstalk Cancellation System Modelled by Four Point Sources and Two Rigid Spheres.pdf:pdf},

file = {:D\:/Users/masiero/Documents/My Dropbox/Literature/pdf/Masiero, Ribeiro, Nascimento\_2008\_Transducer Placement Strategy for Active Noise Control of Power Transformers\_Fortschritte der Akustik -- DAGA.pdf:pdf},

答案1

假设你的file领域只带来文件的准确位置(无空格),可能的解决方案是biblatexbiber将会:

  1. 重新映射(以下奥黛丽的回答向 biblatex 条目添加新字段) 该file字段转换为 biber 和 biblatex 可以理解的自定义字段(例如usera);
  2. 创建一个bibmacro调用includepdf(从pdfpages包裹);
  3. 将其附加到citebibmacro(或创建一个新的 cite 命令)。

首先,我foo.pdf从以下.tex文件(在我的/tmp/目录中)创建了一个文件:

\documentclass{standalone}
\begin{document}
Foooooooooo!
\end{document}

然后我创建了一个 MWE:

\documentclass{article}

% This is to create our dummy bib file
\begin{filecontents}{\jobname.bib}
  @article{foo,
    author = {A. Author},
    title = {Title},
    journal = {A Journal},
    volume = {x},
    year = {2012},
    file = {/tmp/foo.pdf}
    }
\end{filecontents}% end bib file
                  % (change the pdf location accordingly)

\usepackage[style=verbose,backend=biber]{biblatex}% I'm used to verbose style;
                                                  % with numeric, the result is weird.
  \addbibresource{\jobname.bib}% Loads the bib file created with filecontents (above)

% This changes a 'file' field into a 'usera' field which biber\biblatex can understand:
\DeclareSourcemap{% I took this from https://tex.stackexchange.com/a/65403/5872
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=file,fieldtarget=usera]
      }
    }
  }

\usepackage{pdfpages}% This package allows us to include pdf files (or pages)

% We create a bibmacro to include the pdf...
\newbibmacro{file}{%
  \iffieldundef{usera}{}{%
    \includepdf{\thefield{usera}}
  }}

\usepackage{xpatch}% This package allows us to patch (bib)macros

% ... and then we tell the 'cite' bibmacro to call it:
\xapptobibmacro{cite}%
  {\usebibmacro{file}}{}{}

\begin{document}

\cite{foo}

\end{document}

以下是输出(抱歉,我还不知道如何很好地处理这些图像,我至少尝试过裁剪它):

.bib 文件示例的 PDF

编辑:除了修补 xpatch` cite' bibmacro with,您还可以定义一个新的引用命令,例如:

\DeclareCiteCommand{\fullcite}[]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}
   \usebibmacro{file}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\DeclareMultiCiteCommand{\fullcites}{\fullcite}{\multicitedelim}

相关内容