1

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. Code and error after code ran. '?' citation in resultant PDF

'?' citation in resultant PDF

  • 3
    what error message did you get from TeXmaker? – naphaneal Sep 19 '18 at 15:29
  • The code works fine for me, so what's the error? – dexteritas Sep 19 '18 at 15:40
  • 4
    Did you run bibtex in texmaker? – samcarter_is_at_topanswers.xyz Sep 19 '18 at 15:42
  • The code works for me as well (oddly it produces two "References" headings). What exactly does not work in TeXmaker? Do you get errors? Warning? Just "wrong" output? Please add relevant snippets of log files and a screenshot of the result. Did you run BibTeX (Overleaf does that automatically for you), see Question mark or bold citation key instead of citation number? – moewe Sep 19 '18 at 15:49
  • @moewe I added two pictures that may clarify my issue. The first is a screenshot of the code and the three errors I get after I run it. The second is a screenshot of the resultant PDF that shows '?]'. I'm not sure what you mean by 'run bibtex' I imagine that's my issue. – Taylor Wright Sep 24 '18 at 17:19
  • @samcarter I'm not sure what you mean by 'run bibtex' I imagine that's my issue. – Taylor Wright Sep 24 '18 at 17:20
  • @dexteritas I added screenshots of the issue – Taylor Wright Sep 24 '18 at 17:21
  • @naphaneal I added screenshots of the issue – Taylor Wright Sep 24 '18 at 17:21
  • "run bibtex": LaTeX (in general) needs multiple compilations in order to get all of the cross references correct. With bibtex, you end up needing: latex Error, then bibtex Error, and then latex Error at 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:54
  • 1
    The link Question mark or bold citation key instead of citation number from my comment should explain what it means to run BibTeX. TeXmaker will have a menu item for that: Tools > BibTeX, or F11 on my machine. – moewe Sep 24 '18 at 18:46
  • 1
    @moewe That fixed it! Thank you. Running BibTex also showed me that I needed 'elsarticle-num.bst'. It still has this error though "File `Error.bib' (title of the document) already exists on the system." Is that a problem? – Taylor Wright Sep 24 '18 at 19:08
  • 1
    That is not an error. It is a warning. The warning is caused by the fact that you use filecontents to generate the .bib file. Usually one would just generate the .bib file as a separate stand-alone file. filecontents is usually only used to make MWEs self-contained. – moewe Sep 24 '18 at 20:24
  • @moewe What command would I use to do that? I've only ever used the filecontents command. – Taylor Wright Sep 25 '18 at 18:21
  • @moewe I figured it out from looking at your answer on the other page. However, I do have another question. Currently, I'm using the command '\cite{xxx}' with 'elsarticle-num.bst', but the output is '<1>'. I've done variations of cite, but I can't get the output to be '[1]' like Elsevier wants. Do you have any suggestions? – Taylor Wright Sep 25 '18 at 18:49
  • I get "[1]" from your MWE if I use \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

0 Answers0