65

I use Mendeley for article management and export the related items to a bib file for referencing in LaTeX documents. I use IEEEtran style and see that the bibliography items include URLs which I don't want to include. The URLs may have URLs like this:

Available: http://www.mendeley.com/research/improved-adaptive-background-mixture-model-realtime-tracking-shadow-detection-6/

As a solution, I can delete the URL in Mendeley and export it again but I want the URLs remain. I only want them to be hidden in the references. Is there a command to disable URLs in bibliography?

P.S.: I'm not interested in typesetting the URLS as given in this question.

Additional information: I've used the following code for the bibliography:

\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,references}

There's a file named references.bib in the working folder.

2
  • Very useful topic. Could you also think of a solution, which allows to have the url in bibliography entry or not depending on the entry type. I. e. remove the url from the bibliography for article-type entries, but keep it for manual- or techreport-type entries? Thanks a lot in advance!
    – Neb
    Commented Feb 15, 2012 at 18:29
  • 1
    @Neb Welcome to TeX.sx! Your question won't be seen by many people here, so it would be best to repost it as a fresh question. Follow-up questions like this are more than welcome! Please use the "Ask Question" link for your new question; there you can link to this question to provide the background.
    – Werner
    Commented Feb 15, 2012 at 18:46

14 Answers 14

17

I guess you use the IEEEtran bibliography style coming along with the IEEEtran document class. You can easily adapt this style to ignore any url fields in your bibliographic database. To this end, copy the file IEEEtran.bst to your working directory (if it isn't already there) and apply the following patch:

--- IEEEtran.bst.orig
+++ IEEEtran.bst
@@ -403,7 +403,6 @@
   default.ALTinterwordstretchfactor 'ALTinterwordstretchfactor :=
   default.name.format.string 'name.format.string :=
   default.name.latex.cmd 'name.latex.cmd :=
-  default.name.url.prefix 'name.url.prefix :=
 }


@@ -1080,7 +1079,7 @@
   if$
   "\begin{thebibliography}{"  longest.label  * "}" *
   write$ newline$
-  "\providecommand{\url}[1]{#1}"
+  "\def\url#1{}"
   write$ newline$
   "\csname url@samestyle\endcsname"
   write$ newline$
10
  • 1
    @daleif: Yes, but you will probably also want to get rid of the Available: field which precedes every url in the bibliography. This is achieved by the first part of the patch.
    – mhp
    Commented Aug 23, 2011 at 14:53
  • 1
    @mhp what I mean is, why don't they add it with a macro instead and add say \providecommand\mymacro{...} in the bibliography preamble. Then users can define that macro them self to do nothing or to translate it into a different language. Thesee hardwired names often end up giving loads of problems when users use them for documents that style is not suppose to be used for.
    – daleif
    Commented Aug 24, 2011 at 8:52
  • 2
    I am newbie. What does it mean "apply the patch"? How can I do that?
    – freude
    Commented Jun 16, 2013 at 12:25
  • 2
    @freude In the Linux world, you would normally use the patch utility for that purpose. Save the patch in the current working directory as IEEEtran.bst.patch, then enter the command patch -i IEEEtran.bst.patch.
    – mhp
    Commented Jun 16, 2013 at 15:31
  • 1
    @LWZ Unfortunately (or fortunately ;-)), I don’t know anything about Windows.
    – mhp
    Commented Aug 8, 2013 at 18:46
36

If you use biblatex, there's an option called url which can be set to url = false. There are also isbn, doi etc., similar options. If you are not using biblatex. I don't think there's an easy way get what you want. The traditional bibtex uses a very different language to define the bib style.

1
  • 1
    I'll second the biblatex + biber recommendation. I'm using it for my thesis and don't want ugly URLs in my reference section. The DOI option is much better looking and provides the same funtionality.
    – Darling
    Commented Aug 23, 2011 at 10:28
17

I have a cheeky solution to this. I grep "url" in my bibtex file with the invert switch -v -- in effect, it gives me a new bibtex file without any url data. In other words,

grep -v "url =" file.bib > newfile.bib
7
  • 4
    Your regular expression may need a little more attention. Depending on the bibliography contents, you don't want to remove any other fields containing the string url (perhaps a last name of an author).
    – Werner
    Commented Feb 8, 2012 at 0:45
  • Also, if the URL is the last item in a bibtex entry, you'll have a comma problem, and maybe a closing brace problem. BibTool would be a good way to accomplish your idea. Commented Feb 8, 2012 at 5:18
  • Thanks, Werner, I've made the regular expression more accurate. Nathan, while your comment is true in general, it is found that the bib file generated by Mendeley puts each field on a new line, and the url field is always before the "year" field, hence one would never face the problem of a comma or closing brace.
    – U K
    Commented Feb 8, 2012 at 17:52
  • 3
    @UK Actually, the grep thing didn't work for me (maybe because I didn't apply it quite right). But this did: cat mybibfile.ib | sed -e '/url /d' > mybibfile2.bib. I provided one solution here
    – dearN
    Commented Apr 6, 2012 at 22:07
  • 6
    Might be better to use a regex like "^\s*url\s*=", which will ensure the url is at the start, and allow flexible whitespace.
    – naught101
    Commented Sep 17, 2013 at 3:59
12

The IEEEtran.bst v1.14 introduces a new option to disable URLs. Now you can create a bib file containing the following:

@IEEEtranBSTCTL{MyBSTcontrol,
    CTLuse_url = "no",
}

Include this bib file along with other bib files, and invoke it via bstctlcite

\begin{document}
\bstctlcite{MyBSTcontrol}
.
.

All URLs in the references will be gone.

4
  • 2
    +1 Documented by IEEEtran_bst_HOWTO.pdf (cf. textdoc IEEEtran_bst_HOWTO.pdf or texdoc.net/texmf-dist/doc/latex/IEEEtran/IEEEtran_bst_HOWTO.pdf) Commented Mar 19, 2017 at 16:29
  • 1
    Strangely, if I put \bstctlcite just before \bibliographystyle{IEEEtran}\bibliograph{...} instead of just after \begin{document}, it does not work. Commented Mar 20, 2018 at 16:03
  • It is explained in the documentation why it should be place right after \begin{document}, it is an expected behavior.
    – duburcqa
    Commented Nov 15, 2021 at 14:07
  • But it also removes all genuine url refs for online content. It should have something that removes all url except for e.g. the electronic class.
    – rfabbri
    Commented Jul 19, 2022 at 19:49
8

You can remove URLs from a bibliography by opening Mendeley Desktop and clicking View >Citation Style >More Styles, and set Include URLs and Date Accessed in Bibliographies to Only for Webpages.

Reference: http://support.mendeley.com/customer/portal/articles/170063-removing-urls-from-bibliographies-using-the-word-plugin

(This removes URLs from bibliographies created using the plugins and not from the .bib files!)

5
  • 1
    This was what I was looking for! However, my Mendelay desktop seems to ignore this setting when I export the .bib... and still adds the url's for journal articles...
    – JHBonarius
    Commented Feb 27, 2018 at 12:36
  • @JHBonarius Any solution to the first comment? I am finding that Mendeley desktop annoyingly ignore this setting as the bibtex file has URLs in it.
    – rnoodle
    Commented Jun 20, 2018 at 15:54
  • @rnoodle I spend a lot of time in contact with Mendelay first-line support. After endless "have you tried restarting your computer?" and "have you tried reinstalling mendeley desktop?" they finally figured our there is a serious problem, and they forwarded it to second line support. They never got back to me...
    – JHBonarius
    Commented Jun 20, 2018 at 19:37
  • 1
    @JHBonarius My solution was to just use \bibliographystyle{apalike}
    – rnoodle
    Commented Jun 21, 2018 at 11:14
  • thanks for the hint that this solution only applies to the Word plugin, not to working with latex based on the .bib file!
    – Agile Bean
    Commented Apr 11, 2021 at 4:33
7

I happen to have the IEEEtran.bst version 1.11 which is quite old actually.

%% BibTeX Bibliography Style file for IEEE Journals and Conferences (unsorted)
%% Version 1.11 (2003/04/02)

What worked for me really is following

1) Edit the "IEEEtran.bst" file to remove the url prefix by changing

FUNCTION {bbl.urlprefix}{ "[Online]. Available:" }

to

FUNCTION {bbl.urlprefix}{ "" }

2) Add this line

\def\url#1{}

before the bibliography

\bibliographystyle{IEEEtran}
\bibliography{IEEEabrv,library}
2
  • Welcome to TeX.SE! You may want to elaborate a bit on how your answer differs in substance from the earlier one given by @mhp. E.g., you could explain that by providing the instruction \def\url#1{} in your .tex file immediately before loading the .bst file, it's not necessary anymore to delete the line "\providecommand{\url}[1]{#1}" from the .bst file.
    – Mico
    Commented Mar 2, 2014 at 10:56
  • This works well. Most IEEE conferences on control systems keep using this old version, as downloaded from css.paperplaza.net/conferences/support/tex.php.
    – oracleyue
    Commented Mar 16, 2018 at 14:52
6

In IEEEtran.bst Version 1.14 (2015/08/26), there is defaults variables for controling the BST style.

At line 87, you find :

% #0 turns off the display of urls
% #1 enables
FUNCTION {default.is.use.url} { #1 }

Just replace the #1 with #0.

5

Another easy way to remove the URLs without modifying the .bst files is to open your bibliography (.bib) file and do a find/replace all on instances of "url". Replace them with "%url". When you build your document, the bibliography interprets all the url's as comments and leaves them out.

It's not exactly a permanent fix, but it's an easy one to repeat any time you update your references.

1
  • The syntax for comments in a .bib file is a bit different, I suspect that bibtex instead interprets the url's as part of a different field, named %url. The end result is probably the same though.
    – T. Verron
    Commented Sep 24, 2014 at 12:52
5

You can remove fields if you use biblatex, use this in your preamble (remove \bibliographystyle{IEEEtran})

\usepackage[style=ieee]{biblatex}
\AtEveryBibitem{%
  \clearfield{issn} % Remove issn
  \clearfield{doi} % Remove doi

  \ifentrytype{online}{}{% Remove url except for @online
    \clearfield{url}
  }
}
1
  • Thanks. I also needed to add \clearfield{urldate}. Commented Oct 19, 2023 at 15:21
3

How is the url typeset in the bbl file? If it is using \url then you could locally redefine \url inside the bibliography to do nothing, or perhaps redefine it to take two args and do nothing, then it will eat the url and a following period. you can add a @preamble string to add the redefinition into the bibfile, and from there into the bbl file via bibtex.

3

That may be helpful. Consider the following entry in IEEEtran.bst file. Delete the line format.url output.

FUNCTION {article} { 
  std.status.using.comma
  start.entry
  if.url.alt.interword.spacing
  format.authors "author" output.warn
  name.or.dash
  format.article.title "title" output.warn
  format.journal "journal" bibinfo.check "journal" output.warn
  format.volume output
  format.number.if.use.for.article output
  format.pages output
  format.date "year" output.warn
  format.note output
  %format.url output
  fin.entry
  if.url.std.interword.spacing
}
2
  • Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Commented May 13, 2014 at 11:48
  • This method also works for the Springer LNCS format.
    – metakermit
    Commented Jun 26, 2014 at 14:46
1

Editors like TexWorks allow the replacement of regular expressions. You can open the .bib file and search and replace the following expression with nothing.

(url|doi) = \{[^\{]+\},\n*

Works fine for me.

1

I had the same problem, and I solve it with the following R code using the "bibtex" package.

library(bibtex)
bib.list <- read.bib("./data/sample.bib")
bib.list[1:length(bib.list)]$url <- NULL
write.bib(bib.list, "./data/sample_no_url.bib", append = FALSE, verbose = TRUE)
0

For those who use "Template article for Elsevier's document class `elsarticle'", here is a solution for hiding the url links in the reference part in the pdf file:

  1. in the ENTRY object located at the beginning of the .bst file, comment the "url" entry.

  2. edit the .bst file related with your .tex file: in the .bst file, comment out every write.url command that is inside different functions of different types of articles.

The above procedures should also apply to other feilds such as "doi", "isbn", etc..

You must log in to answer this question.

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