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'm using biblatex + biber with a bib file containing entries like this:

@article{pm2006,
  author={Pritsker, Matthew},
  title={The hidden dangers of historical simulation},
  journal={Journal of Banking \& Finance},
  year={2006},
  volume={30},
  number={2},
  pages={561-582},
  month={February},
  file={xpto.pdf}
}

I want to show the file field. How can I do that?

share|improve this question
1  
Check this answer –  henrique Nov 10 '12 at 2:15
1  
@henrique The field file is already defined in BibLaTeX, but it is not used in the vast majority of existing styles. Indeed it is possible to use the map facilities of biber to map it to something used by an existing style. –  Guido Nov 10 '12 at 7:57
    
@Guido Yes, but that seems too much of a hack, your approach is way better (I learned a lot with it!) –  henrique Nov 10 '12 at 11:10

1 Answer 1

The BibTeX field file is not support by the standard BibLaTeX styles. A style supporting it is the reading one.

To use it in other styles, the first thing is to provide formatting instructions for it:

\DeclareFieldFormat{file}{\bibstring{file}\addcolon\space \url{#1}}

The second thing to do is to give instructions to print the field (and at the right position), this means to redefine some existing bib macro to include the field in it. To print it at the end of an entry a possibility is to redefine the finentry bib macro.

\renewbibmacro{finentry}{%
  \finentry\addspace
  \printfield{file}%
  }

Another possibility would be to include the information in the block to print URL or DOI.

\newbibmacro*{doi+eprint+url}{%
  \iftoggle{bbx:doi}
    {\printfield{doi}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:eprint}
    {\usebibmacro{eprint}}
    {}%
  \newunit\newblock
  \iftoggle{bbx:url}
    {\usebibmacro{url+urldate}}
    {}
  \newunit\newblock
  \printfield{file}
}

The code above could be refined to include a option (file) in the same way as the option for doi, url and eprint, namely:

\newbool{bbx:file}

to be activated by \usepackage[file,...]{biblatex}, and the last line of the code above can be replaced by

\iftoggle{bbx:file}
  {\printfield{file}}
  {}

EDIT Solution using \AtEveryBibitem:

\AtEveryBibitem executes the code in its argument immediately after the item code. Thus using \printfield{file} would result that the file name will be printed before the content of the entry. However, one can append it at the end of the content of the driver. The content of the driver is available with the control sequence blx@bbx@<entry type>. The command \thefield{entry type} will give us the string needed. Thus, to print the file name at the end of a bib item, we can use the following instruction:

\AtEveryBibitem{\csappto{blx@bbx@\thefield{entrytype}}{\addspace\printfield{file}}}
share|improve this answer
    
Guido, I used your first possibility. It worked as I needed. My best guess was with \AtEveryBibitem which printed the file field as the first one. And that was not what I needed. Thank you so much! jbs –  jbs Nov 10 '12 at 13:30
    
@jbs Glad it helped. You might consider to accept the answer, see How do you accept an answer? –  Guido Nov 10 '12 at 21:15
    
I tried to accept your answer, I read the post you sugested about accepting an answer, but I couldn't manage to accept it. I don't know if this is because I post the question without being registered to stackexchange. I register to accept your answer but the accept icon simply doesn't appear –  jbs Nov 12 '12 at 9:32

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.