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.

Following this question BibLaTeX/BibTeX custom field to show file link and Notes after bibliography entry with Biber and biblatex I get it to work (well, more or less). In the code below I defined a field file and mynote. It is working for file but not for mynote. I don't understand why!

\documentclass[%
    a4paper,
    english,
    11pt,
]{article}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{Padial:2010,
    title={The integrative future of taxonomy},
    author={José M.~Padial and Aurélien Miralles and Ignacio De la Riva and Miguel Vences},
    journal={Frontiers in Zoology},
    year=2010,
    month=may,
    volume=7,
    number=16,
    pages={1--14},
    doi={10.1186/1742-9994-7-16},
    issn={1742-9994},
    mynote={Very good book!},
    file={./article/2010_Wang.pdf},
    keywords={biology, taxonomy},
}
\end{filecontents*}

\usepackage{fixltx2e}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{type1ec}
%\usepackage{lmodern}
\usepackage{microtype}

\usepackage[%
    left=5cm,
    right=2cm,
    %showframe,
    ]{geometry}

\usepackage[color,notref,notcite]{showkeys}

\usepackage[strict,autostyle]{csquotes}

\usepackage[%
    backend=biber,
    style=ieee,
]{biblatex}
\DeclareRangeChars{~,;-+/{}} % add '{}' as page range delimiter
\addbibresource{\jobname.bib}

\DeclareFieldFormat{mynote}{\textbf{#1}}
\DeclareFieldFormat{file}{\href{file:#1}{\textbf{Open file}}}
\AtEveryBibitem{%
    \csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
        \iffieldundef{file}{\space \textbf{No file!}}{%
        \space \printfield{file}}
        \iffieldundef{mynote}{\space \textbf{No annotation!}}{\space\printfield{mynote}}
    }
}

\usepackage[%
    colorlinks,
    unicode,
    breaklinks,
]{hyperref}

\begin{document}

\nocite{*} % list all entries

\printbibliography
%\printbibliography[keyword=taxonomy]

\end{document}
share|improve this question

2 Answers 2

up vote 7 down vote accepted

This is because file is already a field to biblatex, although one not used by the standard styles, while mynote isn't. You must remap (via DeclareSourcemap) the mynote field to one of the user[a-f] fields before you can use them.

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{Padial:2010,
    title={The integrative future of taxonomy},
    author={José M.~Padial and Aurélien Miralles and Ignacio De la Riva and Miguel Vences},
    journal={Frontiers in Zoology},
    year=2010,
    month=may,
    volume=7,
    number=16,
    pages={1--14},
    doi={10.1186/1742-9994-7-16},
    issn={1742-9994},
    mynote={Very good book!},
    file={./article/2010_Wang.pdf},
    keywords={biology, taxonomy},
}
\end{filecontents*}

\usepackage[utf8]{inputenc}
\usepackage[color,notref,notcite]{showkeys}

\usepackage[%
    backend=biber,
    style=ieee,
]{biblatex}

\DeclareRangeChars{~,;-+/{}} % add '{}' as page range delimiter

\addbibresource{\jobname.bib}

\DeclareFieldFormat{file}{\href{file:#1}{\textbf{Open file}}}

\AtEveryBibitem{%
    \csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
        \iffieldundef{file}{\space \textbf{No file!}}{%
        \space \printfield{file}
      }
    }
  }

\DeclareSourcemap{
    \maps[datatype=bibtex]{
      \map{
        \step[fieldsource=mynote]
        \step[fieldset=usera,origfieldval]
    }
  }
}

\DeclareFieldFormat{usera}{\textbf{#1}}

\AtEveryBibitem{%
    \csappto{blx@bbx@\thefield{entrytype}}{% put at end of entry
        \iffieldundef{usera}{%
          \space \textbf{No annotation!}}{%
          \space\printfield{usera}
        }
    }
}

\usepackage[%
    colorlinks,
    unicode,
    breaklinks,
]{hyperref}

\begin{document}

\nocite{*} % list all entries

\printbibliography

\end{document}

enter image description here

share|improve this answer
    
Very good answer. In the end I used the field annotation (as it is already defined in BibLaTeX) and did as I had done for file. –  cacamailg May 2 '13 at 14:53
    
If so, you should consider changing your database to reflect this (specially since your use of mynote seems to fall into the purpose of annotation). I must say that IMHO, while this answer works fine and is a good approach to single files, Guido's answer seems to me to be the "right" one to choose, since it approaches the subject in a more generalized way. –  henrique May 2 '13 at 19:46

Biblatex offers builtin support for the file field (even if it is not a standard one). Users can extend the data model by creating new fields, but they have to be declared in configuration files According to the manual (page 175) they are ordered as follows:

blx-dm.def→
‘datamodel option’.dbx →
‘style option’.dbx →
‘citestyle option’.dbx and ‘bibstyle option’.dbx →
biblatex-dm.cfg

Thus, you can create a biblatex-dm.cfg file in the working directory and use

\DeclareDatamodelFields[type=field, datatype=literal, skipout=false]{mynote}

The creation of file can be done within your file using filecontents package and

\begin{filecontents}{biblatex-dm.cfg}
    \DeclareDatamodelFields[type=filed, datatype=literal, skipout=false]{mynote}
\end{filecontents}
share|improve this answer
    
Just a couple of comments - you can omit skipout=false as this is the default. Also, you need \DeclareDatamodelEntryfields{mynote} too. This declares "mynote" as valid for all entrytypes and the macro you mentioned defines its type. –  PLK May 2 '13 at 7:09
    
Indeed skipout=false can be omitted. For \DeclareDatamodelEntryfields apparently it is not needed. –  Guido May 2 '13 at 7:35

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.