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.

petrichor
  • 1,869
  • 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 Feb 15 '12 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 Feb 15 '12 at 18:46

14 Answers14

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.

Max
  • 197
Yan Zhou
  • 9,032
  • 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 Aug 23 '11 at 10:28
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$
mhp
  • 8,692
  • Isn't just easier to add @preamble{"\def\url#1{}"} to the bib file? – daleif Aug 23 '11 at 11:20
  • 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 Aug 23 '11 at 14:53
  • Is mendeley a bibtex data handling program? if so @pramble is just another type of bibtex input added to the .bib file. @mhp I didn't know IEEE was that anoing, why are they hardcoded? – daleif Aug 23 '11 at 16:32
  • @daleif: Whenever a bibliography entry includes an url field the url is printed preceded by the aforementioned "prefix". The prefix is defined in IEEEtran.bst by the function default.name.url.prefix. I don't think you can control it other than directly in IEEEtran.bst. – mhp Aug 23 '11 at 17:09
  • 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 Aug 24 '11 at 08:52
  • @daleif: This is definitely true. But, apparently, the author(s) of the IEEEtran document class and bibliography style didn't believe that there will be many people who would like to use their work besides submitting papers to IEEE journals. – mhp Aug 24 '11 at 10:38
  • 2
    I am newbie. What does it mean "apply the patch"? How can I do that? – freude Jun 16 '13 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 Jun 16 '13 at 15:31
  • @mhp How about Windows then? – LWZ Jul 29 '13 at 09:36
  • 1
    @LWZ Unfortunately (or fortunately ;-)), I don’t know anything about Windows. – mhp Aug 08 '13 at 18:46
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
U K
  • 171
  • 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 Feb 08 '12 at 00: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. – Nathan Grigg Feb 08 '12 at 05: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 Feb 08 '12 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 Apr 06 '12 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 Sep 17 '13 at 03:59
  • What if the url spans multiple lines? – a06e May 24 '17 at 12:20
  • @U K your grep answer worked with a .bib file exported from Mendeley. The \url line was removed and the citation format in my publication is correct. Thanks. – SurfProc Feb 25 '21 at 07:17
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.

  • 2
    +1 Documented by IEEEtran_bst_HOWTO.pdf (cf. textdoc IEEEtran_bst_HOWTO.pdf or http://texdoc.net/texmf-dist/doc/latex/IEEEtran/IEEEtran_bst_HOWTO.pdf) – Paul Gaborit Mar 19 '17 at 16:29
  • 1
    Strangely, if I put \bstctlcite just before \bibliographystyle{IEEEtran}\bibliograph{...} instead of just after \begin{document}, it does not work. – Benoît Legat Mar 20 '18 at 16:03
  • It is explained in the documentation why it should be place right after \begin{document}, it is an expected behavior. – duburcqa Nov 15 '21 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 Jul 19 '22 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!)

esperluette
  • 309
  • 5
  • 9
  • 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 Feb 27 '18 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 Jun 20 '18 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 Jun 20 '18 at 19:37
  • 1
    @JHBonarius My solution was to just use \bibliographystyle{apalike} – rnoodle Jun 21 '18 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 Apr 11 '21 at 04: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}
Khoa
  • 71
  • 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 Mar 02 '14 at 10:56
  • This works well. Most IEEE conferences on control systems keep using this old version, as downloaded from http://css.paperplaza.net/conferences/support/tex.php. – oracleyue Mar 16 '18 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.

dswiss
  • 51
  • 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 Sep 24 '14 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}
  }
}
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
}
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.

daleif
  • 54,450
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.

yuitert
  • 11
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)
Bordaigorl
  • 15,135
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..

Jeivier
  • 1
  • 1