9

I have a bib file that contains entries without a field named fjournal and other entries that contain both an fjournal and a journal field. I'd like to use a bibliography exactly as in style "plain" but with the contents of field journal replaced by the field fjournal whenever such a field exists. Is this possible?

Many thanks!!

Requested example: Here a shortened example. The field usually appears in the bibtex format of http://www.ams.org/mref .

@article{x,
AUTHOR = {Jacod, J. and Protter, P. and xx, y.},
TITLE = {Semimartingales and {M}arkov processes},
JOURNAL = {Z. Wahrsch. Verw. Gebiete},
FJOURNAL = {Zeitschrift f\"ur Wahrscheinlichkeitstheorie und Verwandte Gebiete},
VOLUME = {54},
YEAR = {1980},
NUMBER = {2},
MRCLASS = {60G44 (60J25)},
MRNUMBER = {597337 (82h:60084)}
}
Mico
  • 506,678
  • Thanks! I edited the question. Sorry for the formatting. @Mico – User1234 Oct 11 '15 at 10:04
  • Just a guess, but it looks as though fjournal is being used as a key for the full journal name, while journal is being used for abbreviated names. Since abbreviations should be done separately, I guess I would manually change all the journal entries to ajournal or something and then change your fjournal to journal. – Alan Munn Oct 11 '15 at 17:00
  • @AlanMunn - I was able to come up with a solution that checks automatically if a field named fjournal is present (and, if so, uses it instead of the field named journal) in entries of type @article. – Mico Oct 11 '15 at 18:02
  • @Mico yes that's a simple solution. This would also be something that biblatex should be able to do in a much more general way. – Alan Munn Oct 11 '15 at 18:05
  • @AlanMunn - Let's see if one or more of the biblatex experts that frequent this site can come up with biblatex-based solution. It's always good to have more than one solution method. – Mico Oct 11 '15 at 18:10
  • 1
    @Mico This is a great solution, many thanks!! – User1234 Oct 11 '15 at 18:10
  • @User1234 - You're most welcome! :-) – Mico Oct 11 '15 at 18:10

2 Answers2

6

With biblatex and Biber you can use the source mapping feature

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=fjournal]
      \step[fieldset=journal, origfieldval]
    }
  }
}

Which will copy the contents of the fjournal field to the journal field.

While numeric is similar to plain, there are styles that emulate plain in all details. How to emulate the traditional BibTeX styles (plain, abbrv, unsrt, alpha) as closely as possible with biblatex?

MWE

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{x,
  AUTHOR   = {{\c C}inlar, E. and Jacod, J. and Protter, P. and Sharpe, M. J.},
  TITLE    = {Semimartingales and {M}arkov processes},
  JOURNAL  = {Z. Wahrsch. Verw. Gebiete},
  FJOURNAL = {Zeitschrift f\"ur Wahrscheinlichkeitstheorie und Verwandte Gebiete},
  VOLUME   = {54},  
  YEAR     = {1980},
  NUMBER   = {2},
  pages    = {161-219},
  MRCLASS  = {60G44 (60J25)},
  MRNUMBER = {597337 (82h:60084)},
}
@article{y,
  AUTHOR   = {{\c C}inlar, E. and Jacod, J. and Protter, P. and Sharpe, M. J.},
  TITLE    = {Semimartingales and {M}arkov processes},
  JOURNAL  = {Z. Wahrsch. Verw. Gebiete},
  VOLUME   = {54},  
  YEAR     = {1980},
  NUMBER   = {2},
  pages    = {161-219},
  MRCLASS  = {60G44 (60J25)},
  MRNUMBER = {597337 (82h:60084)},
}
\end{filecontents}

\documentclass{article}
\usepackage[style=trad-plain, backend=biber]{biblatex}% (or style=numeric)

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite=true]{
      \step[fieldsource=fjournal]
      \step[fieldset=journal, origfieldval]
    }
  }
}

\renewbibmacro*{journal}{%
  \printfield{journaltitle}%
  \setunit{\subtitlepunct}%
  \printfield{journalsubtitle}}

\addbibresource{\jobname.bib}

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

example output


But you don't even have to use biblatex to use that feature. You can let Biber pre-process your .bib file.

Create a file called biber.conf with the following content

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <sourcemap>
    <maps datatype="bibtex" level="user">
      <map map_overwrite="1">
        <map_step map_field_source="fjournal"/>
        <map_step map_field_set="journal" map_origfieldval="1"/>
      </map>
    </maps>
  </sourcemap>
</config>

Then run Biber in its tool mode on your .bib file, if it is called fjourn.bib you would run

biber --tool fjourn.bib

you get a new file fjourn_bibertool.bib where the fjournal field is copied to the journal field. You can then use fjourn_bibertool.bib in your document.

moewe
  • 175,683
5

It turns out that the adjustments to the bibliography style file that are needed to achieve your objective aren't that difficult to implement. I suggest you proceed as follows:

  • Find the file plain.bst in your TeX distribution. Make a copy of this file, and name the copy, say, plainfj.bst. Do not edit an original file of the TeX distribution directly.

  • Open the file plainfj.bst in the text editor of your choice; the program you use to edit your tex files will do fine.

  • In the open file, locate the list named ENTRY; it starts on line 11 in my copy of the file. The items in the list are all the field names that the bibliography style recognizes. I suggest you (a) create a new line between the fields named editor and howpublished and (b) insert the word fjournal on the new line.

    Clearly, we first need to tell BibTeX about the existence of a field named fjournal if BibTeX is supposed to do something with it later on.

  • This "later on" happens to be in the function named article. Thus, locate the function named article in the file plainfj.bst. If you created a new line in the preceding step, the article function should start on line 539 of the file.

  • In the article function, locate the line that looks like this:

        { journal emphasize "journal" output.check
    

    Replace this line with the following four [4] lines:

        { fjournal missing$
          { journal emphasize "journal" output.check }
          { fjournal emphasize "fjournal" output.check }
          if$
    

    Even if you're not familiar with BibTeX's infix syntax, you can probably guess what's going on: In the original version, the field named journal is passed to the emphasize function, followed by a call to the output.check function. (I think you can guess what the emphasize function does; the output.check function issues a warning if the field -- here: journal-- is present but is either empty or present in duplicate.) In the modified version, we first run a test to check if a field named fjournal is missing. If it is missing, the old code is run; if it's not missing, the contents of fjournal are passed to the emphasize and output.check functions.

  • Save the file plainfj.bst, either in the directory where your main tex file is located or in a directory that's searched by BibTeX. If you choose the latter option, be sure to update the filename database of your TeX distribution appropriately.

  • Start using the new bibliography file by replacing the instruction \bibliographystyle{plain} with \bibliographystyle{plainfj}. Be sure to rerun LaTeX, BibTEX, and LaTeX twice more to fully propagate all changes.

Happy BibTeXing!

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@article{x,
  AUTHOR   = {{\c C}inlar, E. and Jacod, J. and Protter, P. and Sharpe, M. J.},
  TITLE    = {Semimartingales and {M}arkov processes},
  JOURNAL  = {Z. Wahrsch. Verw. Gebiete},
  FJOURNAL = {Zeitschrift f\"ur Wahrscheinlichkeitstheorie und Verwandte Gebiete},
  VOLUME   = {54},  
  YEAR     = {1980},
  NUMBER   = {2},
  pages    = {161-219},
  MRCLASS  = {60G44 (60J25)},
  MRNUMBER = {597337 (82h:60084)},
}
@article{y,
  AUTHOR   = {{\c C}inlar, E. and Jacod, J. and Protter, P. and Sharpe, M. J.},
  TITLE    = {Semimartingales and {M}arkov processes},
  JOURNAL  = {Z. Wahrsch. Verw. Gebiete},
  VOLUME   = {54},  
  YEAR     = {1980},
  NUMBER   = {2},
  pages    = {161-219},
  MRCLASS  = {60G44 (60J25)},
  MRNUMBER = {597337 (82h:60084)},
}
\end{filecontents}

\documentclass{article}
\bibliographystyle{plainfj}

\begin{document}
\nocite{*}
\bibliography{mybib}
\end{document}
Mico
  • 506,678