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 have added a price attribute to my bibliography as such:

@book{1578203120,
  Author = {Janice Reynolds},
  Title = {The Complete E-Commerce Book: Design, Build \& Maintain a Successful Web-based Business},
  Publisher = {CRC Press},
  Year = {2004},
  ISBN = {1578203120},
  URL = {http://www.amazon.com/dp/1578203120},
  price = {USD 30.55}
}

When I re-run my latexmk (which runs bibtex and xelatex the required number of times), I don't see the price show up in my bibliography. I don't get any errors or warnings either.

I'm using the following biblatex options:

\usepackage[backend=bibtex,url=true]{biblatex}

UPDATE: I ultimately got this looking how I wanted as follows:

\begin{filecontents*}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal]{price}
\DeclareDatamodelEntryfields{price}
\end{filecontents*}

\NewBibliographyString{price}
\DefineBibliographyStrings{english}{price = {price}}

\renewbibmacro*{addendum+pubstate}{%
  \iffieldundef{price}
    {}
    % {\textsc{\bibstring{price}}\addcolon\space\printfield{price}}
    {\addperiod\space\textsc{price}\addcolon\space\printfield{price}}
  \printfield{addendum}%
  \newunit\newblock
  \printfield{pubstate}}

screenshot

share|improve this question
    
I think you have to use/define proper bibliography style. –  Pouya Dec 17 '13 at 16:02
    
@Pouya okay...how? –  Mark Richman Dec 17 '13 at 16:07
    
Have you tried using the note for this purpose (rather than creating an entirely new field and then having to instruct biblatex what to do with this field)? By the way, you need to prefix a backslash to the $ symbol. –  Mico Dec 17 '13 at 16:09
    
note has no effect. –  Mark Richman Dec 17 '13 at 16:14
    
One advantage of the BibTeX format is you can use any number or arbitrary fields, and BibTeX (and Biber) will happily ignore them if they don't know what they are for. (I often have a field for the call number of library books that I often (re-)check out.) To make them be used in the output, you need a style (a .bst with BibTeX, a .bbx with biblatex/biber) that does something with these fields. if you don't want to do that, for biblatex, usually the addendum field is the last thing printed, and you could put the price information there. –  jon Dec 17 '13 at 16:42

1 Answer 1

up vote 8 down vote accepted

You could just add the information to the addendum field.

See this MWE

\documentclass{article}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=bibtex,url=true]{biblatex}
\usepackage{filecontents}
\addbibresource{\jobname.bib}
\begin{filecontents*}{\jobname.bib}
@book{1578203120,
  Author = {Janice Reynolds},
  Title = {The Complete E-Commerce Book: Design, Build \& Maintain a Successful Web-based Business},
  Publisher = {CRC Press},
  Year = {2004},
  ISBN = {1578203120},
  URL = {http://www.amazon.com/dp/1578203120},
  addendum = {USD 30.55},
}
\end{filecontents*}

\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

You could also map the price field to the addendum via biber's sourcemapping features. This will note overwrite the addendum, but append the price information to it (preceded by a space). Since all standard styles seem to employ addendum this method is quite likely to make the price appear in the bibliography.

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=price, final]
      \step[fieldset=addendum, fieldvalue={~}, append]
      \step[fieldset=addendum, origfieldval, append]
    }
  }
}

You might like to replace the second \step by \step[fieldset=addendum, fieldvalue={~\textsc{Price}:~}, append].

See this MWE

\documentclass{article}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,url=true]{biblatex}
\usepackage{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}
\begin{filecontents*}{\jobname.bib}
@book{1578203120,
  Author = {Janice Reynolds},
  Title = {The Complete E-Commerce Book: Design, Build \& Maintain a Successful Web-based Business},
  Publisher = {CRC Press},
  Year = {2004},
  ISBN = {1578203120},
  URL = {http://www.amazon.com/dp/1578203120},
  price = {USD 30.55},
  addendum = {A nice book, for less than fifty dollar.},
}
\end{filecontents*}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=price, final]
      \step[fieldset=addendum, fieldvalue={~\textsc{Price}:~}, append]
      \step[fieldset=addendum, origfieldval, append]
    }
  }
}

\begin{document}
  \nocite{1578203120,wilde}
  \printbibliography
\end{document}

enter image description here


But with biber there is a much cooler way.

We define a new field price via a datamodel file (we use biblatex-dm.cfg; the file should be put somewhere LaTeX can find it; in the MWE the file is automatically created via the filecontents environment).

\DeclareDatamodelFields[type=field, datatype=literal]{price}
\DeclareDatamodelEntryfields{price}

To make use of the fancy localisation features, we also define

\NewBibliographyString{price}
\DefineBibliographyStrings{english}{%
  price = {price},
}
\DefineBibliographyStrings{ngerman}{%
  price = {Preis},
}
\DeclareFieldFormat{price}{\bibstring{price}\addcolon\space#1}

Or, if you prefer "Price" to be in small caps, try

\DeclareFieldFormat{price}{\bibstring[\textsc]{price}\addcolon\space#1}

Then, we also have biblatex print the price information. The most stable idea would probably be to add it to the driver manually, but that is very tiresome, so we can use either of the following ways.

Add the information to the finentry hook.

\renewbibmacro*{finentry}{%
  \printfield{price}%
  \newunit\newblock
  \finentry}

Or, print the information just before the addendum field.

\renewbibmacro*{addendum+pubstate}{%
  \printfield{price}%
  \newunit\newblock
  \printfield{addendum}%
  \newunit\newblock
  \printfield{pubstate}}

The MWE uses the latter method

\documentclass{article}
\usepackage[british]{babel}
\usepackage{csquotes}
\usepackage[backend=biber,url=true]{biblatex}
\usepackage{filecontents}
\addbibresource{\jobname.bib}
\begin{filecontents*}{\jobname.bib}
@book{1578203120,
  Author = {Janice Reynolds},
  Title = {The Complete E-Commerce Book: Design, Build \& Maintain a Successful Web-based Business},
  Publisher = {CRC Press},
  Year = {2004},
  ISBN = {1578203120},
  URL = {http://www.amazon.com/dp/1578203120},
  price = {USD 30.55},
}
\end{filecontents*}

\begin{filecontents*}{biblatex-dm.cfg}
\DeclareDatamodelFields[type=field,datatype=literal]{price}
\DeclareDatamodelEntryfields{price}
\end{filecontents*}

\NewBibliographyString{price}
\DefineBibliographyStrings{english}{%
  price = {price},
}
\DefineBibliographyStrings{ngerman}{%
  price = {Preis},
}

\DeclareFieldFormat{price}{\bibstring[\textsc]{price}\addcolon\space#1}

\renewbibmacro*{addendum+pubstate}{%
  \printfield{price}%
  \newunit\newblock
  \printfield{addendum}%
  \newunit\newblock
  \printfield{pubstate}}

\begin{document}
  \nocite{*}
  \printbibliography
\end{document}

enter image description here

share|improve this answer
1  
That's an incredible amount of work. I finally got what I wanted using Addendum = {Price: USD 30.55}. I just had to run xelatex, bibtex, xelatex, xelatex. –  Mark Richman Dec 17 '13 at 18:08
1  
@MarkRichman -- The advantage of this solution is that if you re-use the bibliography file in another document that uses biblatex, and don't want to print the price information, you won't need to subsequently delete all these addendum fields that mentions the price. The solution therefore increases the portability and therefore long-term viability of employing a single .bib file. (So: if the issue of a single .bib file is irrelevant, it is overkill -- albeit one with a 'cool' factor, as moewe says.) –  jon Dec 17 '13 at 21:03
    
@jon I see your point! One last question - how to get "Price" in small caps to match ISBN and URL? Assuming that is stylistically accurate of course. –  Mark Richman Dec 17 '13 at 21:09
    
@jon Just the word "Price" in small caps. "USD 30.55" should be in the default font. –  Mark Richman Dec 17 '13 at 21:23
2  
using biber as backend, you could also just remap the price field to addendum with \DeclareSourcemap (with something like \DeclareSourcemap{\maps[datatype=bibtex]{\map{\step[fieldsource=price,fieldset=‌​addendum,origfieldval]}}}) –  henrique Dec 17 '13 at 21:57

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.