I found this answer when looking up how to make \cite work. I copied and pasted the code directly from the answer to my Texmaker and it still didn't work. I then tried the same code in Overleaf and it worked there. What is wrong with my Texmaker that would cause an error in the \cite command?
\begin{filecontents*}{\jobname.bib}
@article{AAA,
author = {A. Uthor},
title = {TTTitle},
year = {2017},
}
\end{filecontents*}
\documentclass[10pt, a4paper]{elsarticle}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
%\usepackage{natbib}
\usepackage{graphicx}
\begin{document}
\citet{AAA}
\section*{References}
\bibliographystyle{elsarticle-num-names}
\bibliography{\jobname}
\end{document}
Code and error after code ran.
'?' citation in resultant PDF

latex Error, thenbibtex Error, and thenlatex Errorat least twice more. One of the advantages of Overleaf is that it takes care of all of this behind the scenes for you. With TeXMaker, you will probably need to find a menu option that specifies what compilation you want; you'll then need to choose appropriately. – Teepeemm Sep 24 '18 at 17:54filecontentsto generate the.bibfile. Usually one would just generate the.bibfile as a separate stand-alone file.filecontentsis usually only used to make MWEs self-contained. – moewe Sep 24 '18 at 20:24\cite, so something else must be going on. Ask a new question with code that reproduces the undesired behaviour (double check in an empty folder) and add a screenshot of the output. – moewe Sep 25 '18 at 19:50