TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a large set of references and I in most cases do have either

  • ISBN
  • DOI
  • DOI and ISBN

I'd like to setup a filter that prints the ISBN only when the DOI does not exist.

How can I set up a filter that performs this conditional printing (I read this thread but didn't find a command to check whether an entry exists)

If necessary I could also define empty DOI entries but this would be plenty of work.

share|improve this question
up vote 11 down vote accepted

You can use biblatex source remapping features. The code checks whether the doi field is non-null and if it is it clears the isbn field so that it is not printed.

\documentclass{article}
\usepackage[backend=biber]{biblatex}
\addbibresource{t.bib}
\DeclareSourcemap{
  \maps[datatype=bibtex]{
     \map{
        \step[fieldsource=doi,final]
        \step[fieldset=isbn,null]
        }
      }
}

\begin{document}
\cite{test1,test2,test3}
\printbibliography
\end{document}

with t.bib

@Book{test1,
  author =   {Author, First},
  title =    {Title One},
  publisher =    {Publisher},
  year =     2000,
  doi =      {doi:field},
  note =     {doi only}
}

@Book{test2,
  author =   {Author, Gareth},
  title =    {Title Two},
  publisher =    {Publisher},
  year =     2005,
  isbn =     {isbn number},
  note =     {isbn only}
}

@Book{test3,
  author =   {Author, Last},
  title =    {Title Three},
  publisher =    {Publisher},
  year =     2007,
  isbn =     {isbn number},
  doi =      {doi:field},
  note =     {isbn and doi}
}

gives

Sample output

share|improve this answer
    
Works like a charm and is much more elegant than the solution suggested in the other thread (which I didn't find; sorry). Thanks a lot. – louis cypher Oct 14 '12 at 14:37
    
Andrew, do you know the same feature in BibTeX? Have my own .bst file. BR Tobias. – TobiasDK Jun 4 '15 at 17:43
    
@TobiasDK In bibtex it would involve writing appropriate functions in the .bst file to do this. It is most certainly possible,cf. tex.stackexchange.com/q/137345/15925, but depends on the rest of that file. Post a new question if you can't make it work. I would in fact be tempted to use something like bibtool to preprocess the bib file instead. – Andrew Swann Jun 5 '15 at 8:44
    
@AndrewSwann, thank you for the answer. I have posted a new question to deal with my problem. Maybe you have time to look at it: [tex.stackexchange.com/questions/248732/…. Thanks in advance. – TobiasDK Jun 5 '15 at 9:37

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.
http://tex.stackexchange.com/questions/76534/biblatex-print-isbn-only-if-doi-is-not-defined
tex.stackexchange.com
crawl=CC-MAIN-2016-30
80079
application/http; msgtype=response
sha1:SKIPSGI4XCUQ5RXBMGH6RJFN54KTMLWS
<urn:uuid:8cf3853b-b933-414a-b3e3-ad5d0507045f>
2016-07-28T16:39:44Z
151.101.1.69
sha1:TMRVMPWMCXIKG34WILW5YJM2PFPI4MSM
<urn:uuid:cb0d90ff-a93f-494b-b0a5-cca8480e7cf3>
http://tex.stackexchange.com/questions/76534/biblatex-print-isbn-only-if-doi-is-not-defined
response
<urn:uuid:660b1fd9-8675-4c03-977c-53624a533e0c>
robots: classic
hostname: ip-10-185-27-174.ec2.internal
software: Nutch 1.6 (CC)/CC WarcExport 1.0
isPartOf: CC-MAIN-2016-30
operator: CommonCrawl Admin
description: Wide crawl of the web for July 2016
publisher: CommonCrawl
format: WARC File Format 1.0
conformsTo: http://bibnum.bnf.fr/WARC/WARC_ISO_28500_version1_latestdraft.pdf