0

I'm using texStudio and natbib

i've tried running (after deleting aux and bbl files) pdflatex test && bibtex test && pdflatex test && pdflatex test

But i still get the following error and nothing in my biblio section:

Package natbib Warning: There were undefined citations.

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\renewcommand{\baselinestretch}{1.5}
\usepackage{pdfpages}
\usepackage{pdftexcmds}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{chngcntr}
\usepackage{natbib}
\usepackage{fullpage}

\begin{document} \begin{sloppypar}

blah blah blah [\cite{1}] blah blah

\setstretch{1.0}{

\bibliographystyle{abbrvnat} \bibliography{test} \nocite{*} }

\end{sloppypar} \end{document}

bib file entry

@Article{1,
    author = {names},
    title = {title},
    journal = {journal},
    year = {2021},
    OPTdoi = {doi.org},
}

The output is:

blah blah blah [?] blah blah

and the biblio page is completely empty

any help would be greatly appreciated. Thank you in advance

leilaK
  • 1
  • As posted the MWE fails for me because \setstretch is undefined. If I load a package that defines it (e.g. \usepackage{setspace}) the example compiles fine. You need to compile your file with BibTeX if you want to obtain citations. See https://tex.stackexchange.com/q/63852/35864. Did you make sure to run LaTeX, BibTeX, LaTeX, LaTeX (where "LaTeX" stands for your favourite flavour of LaTeX: pdfLaTeX, LuaLaTeX, XeLaTeX, ...)? If you run BibTeX it should produce a .blg file and console output, what do they say? Is test.bib your .bib file? – moewe Aug 13 '21 at 12:43
  • yes, I changed the \setstretch to \renewcommand{\baselinestretch}{1.0} as was recommended, deleted my .aux file and ran the following: pdflatex test && bibtex test && pdflatex test && pdflatex test. I don't get an automated bbl file, my bibliosection is still empty, and citations in the document appear as [?] – leilaK Aug 13 '21 at 12:47
  • Well, I wouldn't say that \renewcommand{\baselinestretch}{1.0} is recommended over \setstretch. I would remove \renewcommand{\baselinestretch}{1.5}, would load \usepackage[onehalfspacing]{setspace} and keep using \setstretch (https://tex.stackexchange.com/q/819/35864). (Well, actually, I would simply never use onehalfspacing, but some times you don't have a choice ...). ... – moewe Aug 13 '21 at 12:51
  • ... But that is not the main issue here. Just to be sure: Your document is called test.tex. You first clean the .aux file. Then you run pdflatex test && bibtex test && pdflatex test && pdflatex test without cleaning any .aux files in between? Do you get any errors or warnings on any of those runs? – moewe Aug 13 '21 at 12:52
  • i don't get any errors but i get two warning messages: 1) no file test.bbl and 2) there were undefined citations. – leilaK Aug 13 '21 at 13:04
  • Interestingly, when i hover over my citation in my tex file, it gives a pop-up window with the correct citation. it just doesn't compile.... – leilaK Aug 13 '21 at 13:06
  • Can you run the four commands separately one after another and not in one big go? What does the BibTeX call produce? If you ran BibTeX there must be a .blg file: What does it say (Windows systems may classify .blg files as "performance monitor files" and hide the file extension, but they are simple text files you can inspect with every editor)? Did you enable a 'build directory' or moving of output files in your editor? If so, disable all those features, they confuse external tools like BibTeX. – moewe Aug 13 '21 at 13:07
  • Whether or not your editor shows auto-complete pop-ups for citations has nothing to do with how citations are resolved and the bibliography is produced by LaTeX and BibTeX. – moewe Aug 13 '21 at 13:08
  • i'm not using a windows machine... i'm on a linux system – leilaK Aug 13 '21 at 13:09
  • Even more reason for there to be a .blg file if you ran BibTeX: Can you find it? It should be in the same folder as your main .tex file (test.tex). – moewe Aug 13 '21 at 13:10
  • Too many commas!!!!
    i have commas separating the authors names
    – leilaK Aug 13 '21 at 13:14
  • Multiple authors must always be separated with an and in the .bib file regardless of the desired output. Commas are only used to separate name parts of the same name. See https://tex.stackexchange.com/q/36396/35864 and https://tex.stackexchange.com/q/557/35864. – moewe Aug 13 '21 at 13:16
  • THANK YOU very much for your help! =) – leilaK Aug 13 '21 at 13:18

1 Answers1

4

Looks like the issue is caused by \setstretch{1.0}. A possible quick fix:

enter image description here

\documentclass[12pt,a4paper]{report}
\usepackage[utf8]{inputenc}
\renewcommand{\baselinestretch}{1.5}
\usepackage{pdfpages}
\usepackage{pdftexcmds}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{chngcntr}
\usepackage{natbib}
\usepackage{fullpage}

\begin{document}

blah blah blah [\cite{1}] blah blah

\renewcommand{\baselinestretch}{1.0} \bibliographystyle{abbrvnat} \bibliography{test} \nocite{*} \end{document}

citsahcots
  • 7,992
  • Thank you for your response... but it didn't work... i still get the same [?] and nothing in my biblio.... =/

    and i still get a warning at the end saying, "nofile test.bbl"

    – leilaK Aug 13 '21 at 12:07