0

I have been trying to reference an image URL using BibTex. Please find below minimum working example(MWE).

I have the following entry in my main.tex file:

\documentclass{report}
\usepackage{url}
\begin{document}
\nocite{*}
\input{background}
\bibliographystyle{abbrv}
\bibliography{main}
\end{document}

Following is the separate background.tex file. I have cited the image url as shown below:

% !TEX root =  main.tex

\chapter{Background}
\label{chap:backround}

 About clusters in Apache Spark:

\begin{figure}[h]
    \includegraphics[width=0.7\textwidth]{cluster_overview}
    \centering
    \caption{Spark stack (\cite{clustermodeoverview})}
 \end{figure}

Below is a snippet of main.bib file:

@article{afrati2001generating,
  title={Generating efficient plans for queries using views},
  author={Afrati, Foto N and Li, Chen and Ullman, Jeffrey D},
  journal={ACM SIGMOD Record},
  volume={30},
  number={2},
  pages={319--330},
  year={2001},
  publisher={ACM New York, NY, USA}
}
@inproceedings{herodotou2011query,
  title={Query optimization techniques for partitioned tables},
  author={Herodotou, Herodotos and Borisov, Nedyalko and Babu, Shivnath},
  booktitle={Proceedings of the 2011 ACM SIGMOD International Conference on Management of data},
  pages={49--60},
  year={2011}
}


@misc{clustermodeoverview,
    author  = {Spark 2.4.5 documentation},
    title   = {Cluster mode overview},
    year    = {2019},
    url     = {https://spark.apache.org/docs/latest/img/cluster-overview.png}
    }

I always get a warning "Citation 'clustermodeoverview' on page 5 undefined". There are no errors on compilation. Also, I observed that there is no entry for URL citation in my "Bibliography" page. All other citations of research papers are showing up properly.

I have included url package in main.tex. I have tried to search for the reason of this warning but could not fix it. Can anyone please help me with it?

A Beginner
  • 101
  • 1
  • Add a \protect before \cite{}. –  May 22 '20 at 00:03
  • @Roboticist Still getting the same problem with it :( – A Beginner May 22 '20 at 00:09
  • Why don't you present a compilable snippet? –  May 22 '20 at 00:10
  • Delete .bbl and recompile? – algae May 22 '20 at 03:56
  • Citations in \captions can be tricky, but if things there go wrong, they usually go wrong in a way that causes a real error message, not just Citation 'clustermodeoverview' on page 5 undefined. Are there any other errors or warnings in your .log file? Did you run LaTeX, LaTeX, BibTeX, LaTeX, LaTeX on your document after you added the citation? Unfortunately, it is hard to give any further advice, because so far the question only contains code snippets and not a full example document. The snippets leave to much room for guessing. We need an MWE: https://tex.meta.stackexchange.com/q/228/ – moewe May 22 '20 at 06:45
  • Some older BibTeX styles don't support a url field, which could explain why the URL is not shown in the bibliography at the end. We can only say if that is the problem, though, if you tell us what bibliography style you are using (this is best done in an MWE, see my comment above). – moewe May 22 '20 at 06:47
  • @moewe I have added MWE as suggested. Hope that helps to reproduce the issue. – A Beginner May 22 '20 at 08:27
  • @Roboticist I have now added a MWE. – A Beginner May 22 '20 at 08:32
  • Please test the MWE and make sure that it produces exactly the behaviour you are asking about. When I run the MWE I get an error about \includegraphics because the example doesn't load graphicx. – moewe May 22 '20 at 08:34
  • When I add the missing \usepackage{graphicx} I get a citation in the caption and no warning about undefined citations. As suspected you are using one of the standard BibTeX styles, which can not deal with URLs in the url field. You can either switch to a more modern style (for example abbrvnat with \usepackage{natbib}) or put the URL into the howpublished field. – moewe May 22 '20 at 08:36
  • 1
    In the bibliography that I get author = {Spark 2.4.5 documentation}, looks very odd. If you write stuff into the author field that is not a person's name, you need to protect it with braces author = {{Spark 2.4.5 documentation}},. But Spark 2.4.5 documentation doesn't appear to be an author anyway. (Cf. https://tex.stackexchange.com/q/10808/35864) – moewe May 22 '20 at 08:40
  • @moewe thank you :) I have modified the .bib entry as suggested. Now it displays the correct references. But in the Bibliography page it doesn't display the URL. Do you know why this could happen? – A Beginner May 22 '20 at 09:07
  • 1
    As I wrote above: The style you use abbrv dates back to the eighties, when URLs weren't a big thing yet. abbrv simply does not support a url field. You could use the standard workaround howpublished = {\url{https://spark.apache.org/docs/latest/img/cluster-overview.png}}, or use a different style that supports the url field. (There are many such styles, for example urlbst's abbrvurl, but I would probably start looking at natbib: load \usepackage{natbib} and use \bibliographystyle{abbrvnat}.) – moewe May 22 '20 at 09:10

0 Answers0