# Overleaf natbib \cite{website} error [closed]

I've recently moved my work from texmaker to Overleaf. I linked my Mendeley library to Overleaf.

Now, when I try to compile the document everything works just fine, except for website citations. Any thought on how this can be fixed? Since it's a Mendeley import I can't manually change them. See working example below (note that I input chapters into the main.tex file using \input thus there is no preamble) and I use a .sty file that loads packages, which contains natbib:

Some text ... see figure \ref{fig:ecommerceGrowth}.

\begin{figure}[htb]
...
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/ecommerceGrowth}
\caption{Worldwide e-commerce growth 2015-2020. Adapted from \cite{EMarketer2016}}\label{fig:ecommerceGrowth}
\end{minipage}
\end{figure}


And a copy of the .bib entry:

@misc{EMarketer2016,
title = {{Worldwide Retail Ecommerce Sales Will Reach {\$}1.915 Trillion This Year - eMarketer}}, year = {2016}, author = {{eMarketer}}, url = {https://www.emarketer.com/Article/Worldwide-Retail-Ecommerce-Sales-Will-Reach-1915-Trillion-This-Year/1014369} }  And ofcourse the Overleaf error (identical for all 3 inputs): /main.tex: Package natbib warning: There are undefined citations. /main.lof:8: Package natbib warning: citation 'EMarketer2016' on page \textlatin {v} undefined on input line 8.  In have the idea it's triggered by the @misc since all other entries are working (bib file is 200 entries), of which 3 @misc which are not working. Is this an overleaf issue or am I missing some package? And btw: when I type \cite{} the entrance does pop up in the dropdown list. Recompiling or the recompile from scratch option doesn't solve the problem, Neither does deleting the entry and re-adding it. Worked fine before for another project I have on Overleaf which has Mendeley library and website inputs as @misc. Edit: when I export it and compile it using texmaker it runs without any problems... Edit2: The MWE you requested does work. As such I guess it must be somewhere within the underlying Overleaf system - everything is copy pasted into the MWE. \documentclass[a4paper,11pt,twoside]{report} \usepackage{filecontents} \begin{filecontents}{libtest.bib} @misc{EMarketer2016, title = {{Worldwide Retail Ecommerce Sales Will Reach {\$}1.915 Trillion This Year - eMarketer}},
year = {2016},
author = {{eMarketer}},
url = {https://www.emarketer.com/Article/Worldwide-Retail-Ecommerce-Sales-Will-Reach-1915-Trillion-This-Year/1014369}
}

@misc{Corcoran2002,
author = {Corcoran, Jem N},
booktitle = {Journal of the American Statistical Association},
isbn = {3540609318},
issn = {0162-1459},
pages = {360--360},
pmid = {36621914},
title = {{Modelling Extremal Events for Insurance and Finance}},
volume = {97},
year = {2002}
}
\end{filecontents}

\usepackage{natbib}
\usepackage{hyperref}

\begin{document}
\bibliographystyle{apalike}

\section*{A section}
This does not work in actual code \cite{EMarketer2016}. \newline
This does work in actual code \cite{Corcoran2002}. \newline

\bibliography{libtest}
\end{document}


Edit 3: I've been narrowing down the problem and now know that: 1) citations work just fine outside the figure environment; 2) when I include \cite{sourceA} in the \caption{} it crashes.

This works:

\cite{EMarketer2016}

\begin{figure}[htb]
...
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/ecommerceGrowth}
\caption{Worldwide e-commerce growth 2015-2020. Adapted from XX }\label{fig:ecommerceGrowth}
\end{minipage}
\end{figure}


And this doesn't:

\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=\textwidth]{figures/ecommerceGrowth}
\caption{Worldwide e-commerce growth 2015-2020. Adapted from \cite{EMarketer2016}}\label{fig:ecommerceGrowth}
\end{minipage}
\end{figure}


Again, this same code works in any other project I have on Overleaf (or texmaker), thus knowing for sure the code is OK.

Found it! The problem occured when I tried to compile a \listoffigures and \listoftables, which apparently crashes when using \cite within the curly brackets of \caption{}. Solution was easy (credits go to this stackexchange post). Simply use the options brackets of \caption as such:

Wrong: \caption{Worldwide e-commerce growth 2015-2020. Adapted from \cite{EMarketer2016}}

Correct: \caption[Worldwide e-commerce growth 2015-2020.]{Worldwide e-commerce growth 2015-2020. Adapted from \cite{EMarketer2016}}

Thanks for all your help guys, much appreciated. Hope this helps others who encounter the same problem ;)

## closed as off-topic by user36296, Mensch, Bobyandbob, Mike, TroyNov 19 '17 at 15:25

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Sorry, typo while copying the error message (overleaf doesn't let you copy paste it...) – Mr. N Jun 27 '17 at 8:45
• Check the log-file and check the .blg-file for errors/messages. – Ulrike Fischer Jun 27 '17 at 8:52
• \cite is a "fragile" command (in LaTeX jargon), which causes issues if it's encountered inside a "moving argument" (more LaTeX jargon, sorry) such as \caption{...}. Change the instruction to \caption{... Adapted from \protect{\cite{EMarketer2016}}} to fix the issue. – Mico Jun 27 '17 at 8:55
• Can you please make a minimal working example with bibliography (MWEB)? – user36296 Jun 27 '17 at 9:02
• I'm voting to close this question as off-topic because solved according to edit – user36296 Nov 19 '17 at 13:46