5

Solution!

Big thank you to CFR! Bibtex is not the best way for a lot of online material. Bibtex was developed before web while Biber particularly for content during the time of web. More about this here.

I cannot spot the error: urls are not appearing with bibtex, why?

enter image description here

MWE

MyFile.tex

\documentclass[11pt]{article}

\usepackage{cite}

\begin{document} The Nord Stream \cite{NordStream}. Vessels \cite{PohjoinenLaivasto}. Gas to the TAP \cite{CIAnaturalGas, EnergyPoliciesReviewEU, TAPoverNabuccoDefeatEU}.

\bibliographystyle{plain} \bibliography{references_henri}{} \end{document}

references_henri.bib file in Bibtex format(?)

@webpage{TAPoverNabuccoDefeatEU,
    Date-Added = {2014-11-09 19:59:57 +0000},
    Date-Modified = {2014-11-09 20:01:28 +0000},
    Lastchecked = {September 21th, 2014},
    Month = {July},
    Title = {TAP Wins on Nabucco: A Total Defeat for the EU},
    Url = {http://eastbook.eu/en/2013/07/material-en/news-en/tap-wins-on-nabucco-a-total-defeat-for-the-eu/},
    Year = {2013}}

@electronic{NordStream, Date-Added = {2014-11-09 17:47:19 +0000}, Date-Modified = {2014-11-09 18:23:12 +0000}, Lastchecked = {Nov 11th, 2014}, Title = {NordStream's official website}, Url = {http://www.nord-stream.com/}, Bdsk-Url-1 = {http://www.nord-stream.com/}}

@url{CIAnaturalGas, Author = {CIA}, Date-Added = {2014-11-09 19:31:20 +0000}, Date-Modified = {2014-11-09 19:32:46 +0000}, Lastchecked = {September 13th, 2014}, Title = {Country Comparison: Proved Natural Gas Reserves}, Url = {https://www.cia.gov/library/publications/the-world-factbook/rankorder/2253rank.html}, Year = {2014}}

@article{EnergyPoliciesReviewEU, Author = {International Energy Agency}, Date-Added = {2014-11-09 20:42:47 +0000}, Date-Modified = {2014-11-09 20:44:55 +0000}, Lastchecked = {November 21th, 2014}, Pages = {62}, Title = {Energy Policies Review: The European Union}, Url = {http://www.iea.org/publications/freepublications/publication/eu2008.pdf}, Year = {2008}}

@url{PohjoinenLaivasto, Date-Added = {2014-11-09 17:53:07 +0000}, Date-Modified = {2014-11-09 17:54:33 +0000}, Lastchecked = {November 5th, 2014}, Title = {Pohjoinen laivasto saa yli 40 alusta}, Url = {http://finnish.ruvr.ru/news/2014_04_08/Pohjoinen-laivasto-saa-yli-40-alusta-6885/}, Bdsk-Url-1 = {http://finnish.ruvr.ru/news/2014_04_08/Pohjoinen-laivasto-saa-yli-40-alusta-6885/}}

Compilation having no urls

enter image description here

Updates

I. Comment to CFR's answer: using the above MWE and output very bad looking, why?

enter image description here

II. Comment to CFR's example 2: again looking bad, why with my LaTex?

enter image description here

hhh
  • 8,743
  • 1
    With bibtex, don't you need to use a style which explicitly supports urls? (As opposed to if you were using biblatex, for example.) In any case, please make your code compilable so that it can be used to reproduce the issue. (I do not have references_mine.bib and, if I did, it might not include an entry with the key someReference. Take a look at urlbst which provides url-ready versions of the standard bibtex styles. – cfr Nov 09 '14 at 21:15
  • 1
    Judging from the screenshot you've posted, you have entries with types such as @url, @webpage, and @electronic. None of these entry types is recognized by the standard BibTeX bibliography styles. This strongly suggests that you should be using the biblatex package (likely with biber as the backend) instead of the plain bibliography style (with bibtex as the backend). – Mico Nov 09 '14 at 21:28

2 Answers2

6

The standard BibTeX styles do not support the field url or similar. If you need to include urls, you need to use a style which supports them. The urlbst package provides a way of converting a BibTeX style file into one which supports such fields. In particular, it provides pre-converted versions of the standard BibTeX styles. For example, \bibliographystyle{plainurl} or plainnat should give you a version of plain with the addition of support for fields like webpage, url etc.

As Mico noted, you may need to use biblatex given the entries in your .bib file. A simple example using the sample database provided with the package would be as follows:

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
  \cite{ctan}
  \printbibliography
\end{document}

In this case, the compilation sequence is (pdf)LaTeX -> biber -> (pdf)LaTeX.

simple bibliography with urls courtesy of <code>biblatex</code>

How to modify your MWE

This takes your code and demonstrates how to modify it to use biblatex. Some of the entry types you are using are actually unknown even to biblatex. (Perhaps they are intended for a specific style?) @electronic is known. I've declared @webpage and @url to be aliases of @online, which matches the way @electronic entries are handled. This will avoid the need to modify your .bib file while hopefully getting the entries handled in an acceptable way.

\documentclass[11pt]{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@webpage{TAPoverNabuccoDefeatEU,
    Date-Added = {2014-11-09 19:59:57 +0000},
    Date-Modified = {2014-11-09 20:01:28 +0000},
    Lastchecked = {September 21th, 2014},
    Month = {July},
    Title = {TAP Wins on Nabucco: A Total Defeat for the EU},
    Url = {http://eastbook.eu/en/2013/07/material-en/news-en/tap-wins-on-nabucco-a-total-defeat-for-the-eu/},
    Year = {2013}}

@electronic{NordStream,
    Date-Added = {2014-11-09 17:47:19 +0000},
    Date-Modified = {2014-11-09 18:23:12 +0000},
    Lastchecked = {Nov 11th, 2014},
    Title = {NordStream's official website},
    Url = {http://www.nord-stream.com/},
    Bdsk-Url-1 = {http://www.nord-stream.com/}}

@url{CIAnaturalGas,
    Author = {CIA},
    Date-Added = {2014-11-09 19:31:20 +0000},
    Date-Modified = {2014-11-09 19:32:46 +0000},
    Lastchecked = {September 13th, 2014},
    Title = {Country Comparison: Proved Natural Gas Reserves},
    Url = {https://www.cia.gov/library/publications/the-world-factbook/rankorder/2253rank.html},
    Year = {2014}}

@article{EnergyPoliciesReviewEU,
    Author = {International Energy Agency},
    Date-Added = {2014-11-09 20:42:47 +0000},
    Date-Modified = {2014-11-09 20:44:55 +0000},
    Lastchecked = {November 21th, 2014},
    Pages = {62},
    Title = {Energy Policies Review: The European Union},
    Url = {http://www.iea.org/publications/freepublications/publication/eu2008.pdf},
    Year = {2008}}

@url{PohjoinenLaivasto,
    Date-Added = {2014-11-09 17:53:07 +0000},
    Date-Modified = {2014-11-09 17:54:33 +0000},
    Lastchecked = {November 5th, 2014},
    Title = {Pohjoinen laivasto saa yli 40 alusta},
    Url = {http://finnish.ruvr.ru/news/2014_04_08/Pohjoinen-laivasto-saa-yli-40-alusta-6885/},
    Bdsk-Url-1 = {http://finnish.ruvr.ru/news/2014_04_08/Pohjoinen-laivasto-saa-yli-40-alusta-6885/}}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{\jobname.bib}
\DeclareBibliographyAlias{url}{online}
\DeclareBibliographyAlias{webpage}{online}

\begin{document}
The Nord Stream \cite{NordStream}.
Vessels \cite{PohjoinenLaivasto}.
Gas to the TAP \cite{CIAnaturalGas, EnergyPoliciesReviewEU, TAPoverNabuccoDefeatEU}.

\printbibliography
\end{document}

MWE with <code>biblatex</code>

cfr
  • 198,882
  • 3
    the standard bibtex styles are older than the web – David Carlisle Nov 09 '14 at 21:22
  • 1
    Another variant of the plain bibliography style that's programmed to know what to do with url fields is plainnat. It can be used with or without the natbib package. – Mico Nov 09 '14 at 21:23
  • @Mico thanks for reminding me of that. plainnat may well be a better choice so I've added that. (I really just picked an example to illustrate the idea.) – cfr Nov 09 '14 at 21:25
  • @cfr - In the meantime, I've examined the screenshot the OP posted in more detail, and am starting to suspect that the OP shouldn't be using BibTeX at all, since the bib file appears to contain entries of type @url, @electronic, and @webpage. I suspect he/she really should be using biblatex (which does define these entry types). – Mico Nov 09 '14 at 21:33
  • I cannot understand: which packages do I need to import and which lines to add? \usepackage{urlbst}; \usepacakge{cite} and \bibliographystyle{plainurl}? – hhh Nov 09 '14 at 21:36
  • @Mico Good catch. I did not look at the detail of the screen shot and the MWE was not really an MWE... – cfr Nov 09 '14 at 21:36
  • @hhh Either \bibliographystyle{plainurl} or \bibliographystyle{plainnat} but if Mico is right, you need to use biblatex rather than standard bibtex. – cfr Nov 09 '14 at 21:37
  • Just let me know which packages to import: I don't really know the differences between electronic, url and webpage (I use Texpad that does this automatically). I have a lot of websites, articles and their urls as references where I need to specify accessed date and published date. Is biblatex meant for this? – hhh Nov 09 '14 at 21:39
  • 1
    @hhh biblatex supports these entry types, as well as the url field in entries such as article. biblatex is much newer than bibtex (the web had been invented in the meanwhile) and offers a lot of flexibility. To use it, you load the biblatex package in your preamble. (Don't load cite.) Then you add your bibliography, also in the preamble e.g. \addbibresource{references_mine.bib}. Then in your document, you write \printbibliography to generate the bibliography. – cfr Nov 09 '14 at 21:42
  • 1
    @hhh If you would provide an MWE, somebody could demonstrate how to do it. – cfr Nov 09 '14 at 21:43
  • @cfr provided :) – hhh Nov 09 '14 at 22:00
  • 1
    @hhh See my edit ;). – cfr Nov 09 '14 at 22:06
  • @Mico My version of biblatex doesn't know about @webpage or @url. Do you think declaring them as aliases of @online is the appropriate way to handle these? (That's what I've done but you'd indicated biblatex knew about them so I'm wondering if you are using a style which might provide the OP with a better solution?) – cfr Nov 09 '14 at 22:08
  • I used BibDesk in OSX to generate the references_henri.bib, it does not have online style thing -- I have no idea which entry online/electronic/etc is the proper way for a reference that is primaly web-based thing, ideas? – hhh Nov 09 '14 at 22:08
  • 1
    @hhh It is doing some odd things. I just realised that it is using fields biblatex doesn't know about by default. Let's see what Mico says. I'm not sure I've offered you a good solution. Normally, for example, you'd use urldate for the date of access to a URL. I can modify the code so this is handled correctly but I'm wondering if there's a style which would handle this stuff better out-of-the-box and so offer you a better solution here. [I guess Lastchecked is the date you accessed the urls?] – cfr Nov 09 '14 at 22:11
  • I think your example code compiles fine even if you omit the two \DeclareBibliographyAlias directives. At least, it does compile on my system -- MacTeX2014, all the latest updates installed -- without these two instructions. Maybe biblatex is smart enough to let an unknown entry type default to the catch-all type @misc? – Mico Nov 09 '14 at 22:15
  • I want to keep the question unedr control and moved the general question about reference tools for web-based material here: http://tex.stackexchange.com/questions/211364/which-reference-entry-for-web-based-material-online-electronic-webpage-url, I hope this makes answering easier. – hhh Nov 09 '14 at 22:16
  • 2
    Incidentally, it's necessary to add an extra pair of curly braces around {International Energy Agency}, lest biber (or bibtex) think it's an auther with first name "International", middle name "Energy", and surname "Agency". Since it's a corporate author, it should be sorted under I (for International) rather than A (for Agency), right? :-) – Mico Nov 09 '14 at 22:16
  • 2
    @Mico Yes, biblatex treats unknown types as aliases for @misc. However, I wasn't sure if that was as good as treating them as aliases of @online. – cfr Nov 09 '14 at 22:19
  • I tested your newest example and it looks as bad as earlier, see the update. Any idea why with biblatex? I use TexPad in compiling in OSX. – hhh Nov 09 '14 at 22:27
  • @hhh You seem not to have run biber? What you are seeing is the bibkeys which biblatex shows if it cannot resolve the references. Run biber yourfile (without the .tex extension) and then rerun (pdf)LaTeX. – cfr Nov 09 '14 at 22:45
  • @cfr ERROR - Cannot find control file 'Henri_part.bcf'! - did you pass the "backend=biber" option to BibLaTeX? – hhh Nov 09 '14 at 22:51
  • @hhh Are you using MacTeX 2014? Recent versions of biblatex do not need backend=biber. Did you pdflatex Henri_part.tex before biber Henri_part? Could you try compiling precisely the MWE I posted rather than your original file? – cfr Nov 09 '14 at 23:07
  • @cfr I see, I have TexLive2013 -- now downloading this. – hhh Nov 09 '14 at 23:38
  • @hhh TL 2013 should be fine. biblatex has used biber by default for a long time. Although updating to TL 2014 is not at all a bad idea in general. Did you try compiling my example? – cfr Nov 09 '14 at 23:53
  • @cfr I got it compiled after updating to TL 2014! It did not work with TL 2013. I also got it working in TexPad/BibDesk OS X which is super cool, thank you a lot for your help :D – hhh Nov 10 '14 at 01:37
  • Looks as if some of this "discussion comments" could be deleted. To me it seems howpublished in @misc may contain an URL, but url inside @article or @manual (just for example) are ignored. Still howpublished doesn't feel right. – U. Windl Nov 12 '19 at 00:16
  • @U.Windl That's style-dependent. If you use Biblatex, url is ignored only if you specifically ask for it to be ignored. – cfr Nov 12 '19 at 01:21
1

If you're using the \bibliographystyle{plain}, then use the below format in your .bib file:

@inproceedings{vqa-url,
    note = {\url{https://visualqa.org}},
}

and then, to cite the URL in the LaTeX document, simply do:

\cite{vqa-url}

which will then give the plain URL as the result in your references section:

https://visualqa.org

and a corresponding number in the actual text section.

Note: Also, there is no need to use \usepackage{url} in the header section. But, if you want the URL in the references section to be clickable then you MUST use \usepackage{hyperref} in the header section of your LaTeX document.

kmario23
  • 259
  • 1
    Please note that if you give an identical answer to multiple questions they all get automatically flagged for moderator attention by the system. It would be better you pick the best suitable question for it and stick with it next time. – Martin Scharrer Dec 06 '19 at 07:13
  • I didn't know about this, thank you for mentioning this Martin :) will keep it in mind. – kmario23 Dec 06 '19 at 08:28
  • I get a "undefined control sequence" for the \url – Joe Aug 26 '21 at 12:32