Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I use the BIB list generated by Mendeley, with contains an item called "file" with the path to the PDF of each entry.

I need to generate a compilation of papers and I would like to do it automatically in the following manner.

\usepackage{biblatex}
\usepackage{pdfpages}

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

So, what I'm looking for is a function that given a bib item, it will return the path saved in the file entry of my bib file.

Example of bib entry:

@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}
}

Some other examples of the file field would be:

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},
share|improve this question
1  
I'm not quite clear on what should be included here: \include is for inputting .tex files containing chapters of a document. Do you want to include the PDF themselves or the links to the PDFs? –  Joseph Wright Sep 26 '12 at 16:27
    
Could you add an example of a .bib entry? –  egreg Sep 26 '12 at 19:25
    
I´m compiling the code with pdflatex and I have the article in PDF. My example code was oversimplified. But that can be made with \includepdf. Question is updated. –  bmasiero Sep 27 '12 at 15:39
    
@bmasiero Uh! Those pesky accents. :( –  egreg Sep 27 '12 at 22:34
    
@egreg I updated the examples with papers in English, all without the pesky nice accents. ;) –  bmasiero Oct 1 '12 at 15:34

1 Answer 1

Assuming you file field brings only the exact location of a file without spaces, a possible solution with biblatex and biber would be:

  1. Remap (following Audrey's answer to Add new field to biblatex entries) the file field into a custom field biber and biblatex can understand (e.g. usera);
  2. Create a bibmacro that calls includepdf (from the pdfpages package);
  3. Append that to cite bibmacro (or create a new cite command).

First, I created a foo.pdf file from the following .tex file (in my /tmp/ dir):

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

Then I created a 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 http://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}

And here's the output (Sorry, I don't know how to handle these images very well yet, I tried to at least crop it):

PDF from .bib file example

EDIT: Instead of patching the cite' bibmacro withxpatch`, you can also define a new citation command, say:

\DeclareCiteCommand{\fullcite}[]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}
   \usebibmacro{file}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
\DeclareMultiCiteCommand{\fullcites}{\fullcite}{\multicitedelim}
share|improve this answer
    
It depends on the format of the field. I have some ideas, if the field ends with :pdf. –  egreg Sep 27 '12 at 17:05
    
Henrique, unfortunately this workaround is not working for me. It seems my problem is on the way Mendeley saves the files, containing spaces and that :pdf at the end, as can be seen in the examplary bib entry I just edited above. –  bmasiero Sep 27 '12 at 17:05
    
@bmasiero Is the format always :<PATH>:pdf? –  egreg Sep 27 '12 at 17:09
    
@bmasiero Yes, that's why I mentioned l3regex to egreg. You might also have problems when the file location contains spaces. –  henrique Sep 27 '12 at 17:15
    
@egreg The format used by Mendeley is always file = {:<fullpath>:ext;:<fullpath>:ext} @henrique Yep, spaces are also a problem for \includepdf. –  bmasiero Sep 27 '12 at 17:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.