2

I'm using biber and BibLaTeX on a .bib file exported from Bookends. This mostly works really well. I have a few journal articles though that end up, for various reasons, with the journal and shortjournal fields identical. I want to do a map which checks to see if journal and shortjournal are identical and omits the shortjournal field if so.

Here is an example entry:

@Article{Larsen1977,
author = {Larsen, Mogens Trolle}, 
title = {Partnerships in the Old Assyrian Trade}, 
journal = {Iraq}, 
shortjournal = {Iraq}, 
volume = {39}, 
number = {1}, 
pages = {119--145}, 
year = {1977}}

1 Answer 1

3

Ideally this should be fixed on the .bib export side. Depending on your actual use case for shortjournal it may not be necessary to get rid of these cases at all.

Here is a sourcemap that should do it, though,

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{csquotes}

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

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=journal, fieldtarget=journaltitle]
    }
    \map{
      \step[fieldsource=journaltitle, match=\regexp{\A(.*)\Z}, final]
      \step[fieldsource=shortjournal, match=\regexp{\A$1\Z}, final]
      \step[fieldset=shortjournal, null]
    }
  }
}

\begin{filecontents}{\jobname.bib}
@article{Larsen1977,
  author       = {Larsen, Mogens Trolle}, 
  title        = {Partnerships in the Old Assyrian Trade}, 
  journal      = {Iraq}, 
  shortjournal = {Iraq}, 
  volume       = {39}, 
  number       = {1}, 
  pages        = {119--145}, 
  year         = {1977},
}
@article{test2,
  author       = {John Tumble},
  title        = {A Tremendously Interesting Idea},
  journal      = {Journal of Tremendously Interesting Ideas},
  shortjournal = {JTII},
  volume       = {1},
  number       = {1},
  year         = {1946},
}
\end{filecontents}
\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
Lorem \autocite{sigfridsson,Larsen1977,test2}

\printbiblist{shortjournal}

\printbibliography
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .