1

My question is roughly dual to this one. How do I force bibtex to format the word “DOI” below in uppercase?

enter image description here

\documentclass{article}

\begin{filecontents*}{bib.bib}
@article{milner92,
 author = {Robin Milner and Joachim Parrow and David Walker},
 title = {A Calculus of Mobile Processes, {I} and {II}},
 journal = {Inf. Comput.},
 volume = {100},
 number = {1},
 pages = {1--77},
 year = {1992},
 doi = {10.1016/0890-5401(92)90009-5},
}
\end{filecontents*}

\begin{document}
\cite{milner92}

\bibliographystyle{plainnat}
\bibliography{bib.bib}

\end{document}

The DeclareFieldFormat solution mentioned in the earlier question doesn't seem relevant here (presumably it's specific to biblatex).

2
\documentclass{article}

\begin{filecontents*}{bib.bib}
@article{milner92,
 author = {Robin Milner and Joachim Parrow and David Walker},
 title = {A Calculus of Mobile Processes, {I} and {II}},
 journal = {Inf. Comput.},
 volume = {100},
 number = {1},
 pages = {1--77},
 year = {1992},
 doi = {10.1016/0890-5401(92)90009-5},
}
\end{filecontents*}

\expandafter\ifcsname urlstyle\endcsname
  \providecommand{\doi}{DOI: \begingroup \urlstyle{rm}\Url}\else
  \providecommand{\doi}[1]{DOI: #1}%
  \fi

\begin{document}
\cite{milner92}

\bibliographystyle{plainnat}
\bibliography{bib}

\end{document}
| improve this answer | |
  • Works for me - I’ll see what other answers materialise before accepting, in case there’s a simpler one. Thanks. – Roly Dec 2 '19 at 20:04
  • I accepted this initially but I’m afraid I had to change my mind - it doesn’t seem to work with the doi package (which I also need to turn my DOIs into hyperlinks). Back-patched my question accordingly. – Roly Dec 2 '19 at 20:21
  • 1
    If you have a new question ask a new question. Making answers invalid by adding new info to a question is not nice. – Ulrike Fischer Dec 2 '19 at 20:31
  • Fair enough. I’ll undo my change to this question and ask a new one. – Roly Dec 2 '19 at 20:32
1

plainnat uses the macro \doi to typeset the DOI. If the macro is not defined, it will use the following replacement definitions

\providecommand{\url}[1]{\texttt{#1}}
\expandafter\ifx\csname urlstyle\endcsname\relax
  \providecommand{\doi}[1]{doi: #1}\else
  \providecommand{\doi}{doi: \begingroup \urlstyle{rm}\Url}\fi

Assuming you load url or hyperref, you could take that branch of the definition and go for

\documentclass{article}

\usepackage{natbib}

\usepackage{url}
\newcommand{\doi}{\textsc{doi}: \begingroup \urlstyle{rm}\Url}

\begin{filecontents*}{\jobname.bib}
@article{milner92,
 author  = {Robin Milner and Joachim Parrow and David Walker},
 title   = {A Calculus of Mobile Processes, {I} and {II}},
 journal = {Inf. Comput.},
 volume  = {100},
 number  = {1},
 pages   = {1--77},
 year    = {1992},
 doi     = {10.1016/0890-5401(92)90009-5},
}
\end{filecontents*}

\begin{document}
\cite{milner92}

\bibliographystyle{plainnat}
\bibliography{\jobname}
\end{document}

Robin Milner, Joachim Parrow, and David Walker. A calculus of mobile processes, I and II. Inf. Comput., 100(1):1–77, 1992. DOI: 10.1016/0890-5401(92)90009-5.

I used small caps instead of ALL CAPS, but of course that can easily be changed.

| improve this answer | |
  • Thanks - I happen to be using url but I think I prefer the solution without the dependency. How do I switch to all caps? – Roly Dec 2 '19 at 20:07
  • 1
    @Roly Write DOI instead of \textsc{doi}. – moewe Dec 2 '19 at 20:09
  • Thanks. Accepted this in the end because it works with the doi package too, which I would also like to use. Means using \renewcommand rather than \newcommand for \doi. – Roly Dec 2 '19 at 20:22
  • Oops, I messed up there - actually it doesn’t work with the doi package. (I guess redefining \doi isn’t a good idea - my bad.) Any idea how to make this work with doi? – Roly Dec 2 '19 at 20:30

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.