2

Currently, in my .bst file using BibTex, if an entry has both a Journal and an arXiv link, both are used in the citation. What I would like to do is use an "if" statement saying that if a Journal is defined, don't print the arXiv reference.

Any ideas?

I've uploaded the style file here if that helps.

  • You can make it much easier for people to help you if you also show a few example .bib entries that we can experiment with as well as the expected output for those entries. I spent quite a bit of time figuring out how your eprint setup works in the first place, that time could have been massively reduced had I actually seen a few entries in action. So even for questions like this an MWE or MWEB (in this case) has its uses. – moewe Sep 11 '18 at 15:21
  • Aha, sorry about that. I could have definitely added a working example. Thanks! – jwsmithers Sep 11 '18 at 15:49
2

In your .bst replace the function for article with

FUNCTION {article}
{ output.bibitem
  format.collaboration output
  format.authors "author" output.check
  format.title "title" output.check
  blank.sep
  crossref missing$
  { journal missing$   
    {}
    { format.journal add.doi "journal" output.check }
    if$
  }
  { format.article.crossref output.nonnull
    format.pages output
  }
  if$
  journal missing$
    { format.eprint output
      format.url output }
    'skip$
  if$
  note output
  new.sentence
  format.SLACcitation output
  fin.entry
}

The new bit is

  journal missing$
    { format.eprint output
      format.url output }
    'skip$
  if$

instead of

  format.eprint output
  format.url output

That means that now the eprint and url information is only printed if the journal field is absent.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{hyperref}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{appleby,
  author  = {Humphrey Appleby},
  title   = {On the Importance of the Civil Service},
  year    = {1980},
  journal = {Civil Service Review},
  volume  = {138},
  number  = {3},
  pages   = {234-289},
  archive = arXiv,
  archivePrefix = {arXiv},
  eprint  = {1234.5689},
}
@article{elk,
  author  = {Anne Elk},
  title   = {On Brontosauruses},
  year    = {1972},
  archive = arXiv,
  archivePrefix = {arXiv},
  eprint  = {2234.5689},
}
@article{sigfridsson,
  author  = {Sigfridsson, Emma and Ryde, Ulf},
  title   = {Comparison of methods for deriving atomic charges from the
             electrostatic potential and moments},
  journal = {Journal of Computational Chemistry},
  year    = 1998,
  volume  = 19,
  number  = 4,
  pages   = {377-395},
  doi     = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}
\end{filecontents}


\begin{document}
\cite{sigfridsson,appleby,elk}
\bibliographystyle{jwsmith}
\bibliography{\jobname}
\end{document}

produces

1 E. Sigfridsson and U. Ryde, Comparison of methods for deriving atomic charges from the electrostatic potential and moments, Journal of Computational Chemistry 19 (1998) 377–395.//H. Appleby, On the Importance of the Civil Service, Civil Service Review 138 (1980) 234–289.//A. Elk, On Brontosauruses, arXiv:2234.5689.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.