adapt plainnat bibtex natbib style to only show the url if no doi is available

Since the URL in a bibtex entry is typically just duplicate information when the entry has a DOI, I want to hide it.1

Here’s how:

diff -r 5b78f551d0a0 plainnatnoturl.bst
--- a/plainnatnoturl.bst    Tue Apr 04 10:45:08 2017 +0200
+++ b/plainnatnoturl.bst    Tue Apr 04 10:52:25 2017 +0200
@@ -1,5 +1,7 @@
-%% File: `plainnat.bst'
-%% A modification of `plain.bst' for use with natbib package 
+%% File: `plainnatnoturl.bst'
+%% A modification of `plain.bst' and `plainnat.bst' for use with natbib package 
+%% 
+%% From /usr/share/texmf-dist/bibtex/bst/natbib/plainnat.bst
 %%
 %% Copyright 1993-2007 Patrick W Daly
 %% Max-Planck-Institut f\"ur Sonnensystemforschung
@@ -285,7 +288,11 @@
 FUNCTION {format.url}
 { url empty$
     { "" }
-    { new.block "URL \url{" url * "}" * }
+    { doi empty$
+      { new.block "URL \url{" url * "}" * }
+      { "" }
+      if$
+    }
   if$
 }

Just put this next to your .tex file, add a header linking the doi

\newcommand*{\doi}[1]{\href{http://dx.doi.org/#1}{doi: #1}}

and use the bibliography referencing plainnatnoturl.bst

\bibliographystyle{plainnatnoturl}
\bibliography{YOURBIBFILE}

That’s it. Thanks to toliveira from tex.stackexchange!

Footnotes:

1

Also I’m scraping at my page limit and cutting a line for roughly every second entry helps a lot :)

Use Node:

⚙ Babcom is trying to load the comments ⚙

This textbox will disappear when the comments have been loaded.

If the box below shows an error-page, you need to install Freenet with the Sone-Plugin or set the node-path to your freenet node and click the Reload Comments button (or return).

If you see something like Invalid key: java.net.MalformedURLException: There is no @ in that URI! (Sone/search.html), you need to setup Sone and the Web of Trust

If you had Javascript enabled, you would see comments for this page instead of the Sone page of the sites author.

Note: To make a comment which isn’t a reply visible to others here, include a link to this site somewhere in the text of your comment. It will then show up here. To ensure that I get notified of your comment, also include my Sone-ID.

Link to this site and my Sone ID: sone://6~ZDYdvAgMoUfG6M5Kwi7SQqyS-gTcyFeaNN1Pf3FvY

This spam-resistant comment-field is made with babcom.

Inhalt abgleichen
Willkommen im Weltenwald!
((λ()'Dr.ArneBab))



Beliebte Inhalte

Draketo neu: Beiträge

Ein Würfel System

sn.1w6.org news