0

I'm writing a report for which I need to add citations from the literature. When I add more than one citation in the entire body of the text, only one appears as it should and the others turn into (?,?).

Here are my Overleaf packages

\documentclass[12pt, oneside]{article} 
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{array}
\usepackage{amssymb}
\usepackage[font=small,skip=-10pt]{caption}
\usepackage{subcaption}
\usepackage[a4paper, inner=1.5cm, outer=1.5cm, top=2.3cm, bottom=2.3cm]{geometry} 
\usepackage{newtxtext,newtxmath,amsmath}
\usepackage{apacite}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{setspace}
\usepackage[table,xcdraw]{xcolor}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{ulem}

Here's how I cite papers in the body of the text

This is a cool citation \cite{sirin_socioeconomic_2005} and this is another cool citation \cite{angrist_perils_2014}

Here's how the citations look in the .bib file

@article{angrist_perils_2014,
    title = {The {Perils} of {Peer} {Effects}},
    volume = {30},
    url = {https://www.researchgate.net/publication/263319266_The_Perils_of_Peer_Effects},
    doi = {10.1016/j.labeco.2014.05.008},
    urldate = {2021-02-10},
    journal = {Labour Economics},
    author = {Angrist, Joshua},
    year = {2014},
    file = {Full Text:C\:\\Users\\User\\Zotero\\storage\\4UIR33RD\\Angrist - 2014 - The Perils of Peer Effects.pdf:application/pdf},
}

@article{sirin_socioeconomic_2005,
    title = {Socioeconomic {Status} and {Academic} {Achievement}: {A} {Meta}-{Analytic} {Review} of {Research}},
    volume = {75},
    issn = {0034-6543},
    shorttitle = {Socioeconomic {Status} and {Academic} {Achievement}},
    url = {https://doi.org/10.3102/00346543075003417},
    doi = {10.3102/00346543075003417},
    language = {en},
    number = {3},
    urldate = {2022-05-23},
    journal = {Review of Educational Research},
    author = {Sirin, Selcuk R.},
    month = sep,
    year = {2005},
    note = {Publisher: American Educational Research Association},
    keywords = {achievement, meta-analysis, SES, social class, socioeconomic status},
    pages = {417--453},
}

Here's how I call the bibliography at the end of my main.tex

\bibliographystyle{apacite}
\bibliography{Thesis.bib}

I made sure that the .bib file is indeed named Thesis.bib, in fact I know it is correct because when I add only one citation it appears correctly both in the body of the text where I call it but also at the bottom of the document.

Additionally, I have two error messages that show up. One next to where I cite the reference, which says:

Citation '...' undefined on line N

And one next to the \bibliography{Thesis.bib} that says:

runaway argument ?

I've done that dozens of times and never encountered such a problem.

MWE as asked in the comments:

\documentclass[12pt, oneside]{article} 
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{array}
\usepackage{amssymb}
\usepackage[font=small,skip=-10pt]{caption}
\usepackage{subcaption}
\usepackage[a4paper, inner=1.5cm, outer=1.5cm, top=2.3cm, bottom=2.3cm]{geometry} 
\usepackage{newtxtext,newtxmath,amsmath}
\usepackage{apacite}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{threeparttable}
\usepackage{setspace}
\usepackage[table,xcdraw]{xcolor}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{enumitem}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage[table]{xcolor}
\usepackage{ulem}
\graphicspath{ {./Images/} }


\setstretch{1.25}
\begin{document}
\section{Introduction}
This is a cool citation \cite{sirin_socioeconomic_2005} and this is another cool citation \cite{angrist_perils_2014}
\clearpage

\bibliographystyle{apacite}
\bibliography{Thesis.bib}

\end{document}

Edit : I've also noticed a final error message next to \end{document}:

LaTeX Error: \begin{thebibliography} on input line 1 ended by \end{document}
10
  • Could you put this all together into a single MWE that we could copy and paste? A separate .bib file is ok. I think you do not need the ending .bib in \bibliography.
    – Unknown
    May 23, 2022 at 14:53
  • Just edited the main post with the MWE May 23, 2022 at 15:16
  • are you regenerating the bibliography by running pdflatex, bibtex,pdflatex,pdflatex after adding a new \cite ? May 23, 2022 at 15:30
  • I don't know what "regenerating the bibliography" means so I'll say no. I usually just cite in the text and compile the doc to have the citation appear. It also automatically appears in the reference part at the end of the doc. It's always worked up to now. May 23, 2022 at 15:38
  • 1
    latex never reads the bib file, it reads the .bbl file that is generated by bibtex, so if you add a new \cite you need to regenerate it. You must have run bibex at least once on this document if you have a .bbl file with \begin{thebibliography} May 23, 2022 at 16:19

1 Answer 1

2

I can reproduce a few errors of the sort

Runaway argument?
{\check@icl Labour Economics\check@icr \expandafter \egroup \fi \ifx \ETC.
! File ended while scanning use of \UL@on.

and then

! LaTeX Error: \begin{thebibliography} on input line 1 ended by \end{document}.

with the following MWE

\documentclass[12pt, oneside]{article} 
\usepackage[T1]{fontenc}
\usepackage{apacite}
\usepackage{ulem}

\begin{filecontents}{\jobname.bib}
@article{angrist_perils_2014,
  author  = {Angrist, Joshua},
  title   = {The Perils of Peer Effects},
  year    = {2014},
  journal = {Labour Economics},
  volume  = {30},
  doi     = {10.1016/j.labeco.2014.05.008},
}
@article{sirin_socioeconomic_2005,
  author     = {Sirin, Selcuk R.},
  title      = {Socioeconomic Status and Academic Achievement:
                A Meta-Analytic Review of Research},
  shorttitle = {Socioeconomic Status and Academic Achievement},
  journal    = {Review of Educational Research},
  year       = {2005},
  month      = sep,
  volume     = {75},
  issn       = {0034-6543},
  doi        = {10.3102/00346543075003417},
  language   = {en},
  number     = {3},
  pages      = {417--453},
}
\end{filecontents}

\begin{document}
This is a cool citation \cite{sirin_socioeconomic_2005}
and this is another cool citation \cite{angrist_perils_2014}

\bibliographystyle{apacite}
\bibliography{\jobname}
\end{document}

The problem here is

\usepackage{ulem}

ulem turns the classical \emph command into a command that applies underlining. This underlining command is quite a bit more fussy about the input it accepts. Typographically underlining is often discouraged anyway, so it is probably best to get rid of ulem for good.

If you need underlining elsewhere in your document, there are better solutions (https://tex.stackexchange.com/a/446488/35864), but you can even continue with ulem if you load it with the normalem option, so it leaves \emph alone.

\usepackage[normalem]{ulem}

Your document will also benefit from loading either \usepackage{url} or \usepackage{hyperref} so that URLs are handled nicely. (If you load neither of those packages special characters like _ may error in URLs.)


You may want to have a look at the other packages you load as well. If you don't need them, it is usually better not to load packages. That makes for code that is easier to maintain and avoids surprises like this one.

Also note that you should only load packages once. If you load packages multiple times with different options, there is even a chance you might get an error.

1
  • That worked ! I would've never guessed some randoma package was causing that issue. I just got rid of it because I realised I wasn't using it. Thanks a lot ! May 24, 2022 at 7:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .