0

I have the following directory:

/run.py
  /doc
     main.tex
     reference.bib

In main.tex, I have a reference \bibliography{reference} that should display the reference section from the bib file. I have also used \cite{something} in main.tex. All in all, the reference section should be displayed, as I have tested it on Overleaf, and it displays correctly with main.tex and reference.bib in the same level of directory.

Now I am trying to compile the .tex file on my computer with Python. Inside run.py, I have the code subprocess.call(["pdflatex", "./doc/main.tex"]), and I am running that code in the run.py directory. But that code produces errors that the reference cited is not found:

LaTeX Warning: Citation `something' on page 1 undefined on input line 104.


! LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.117 \end{mcsection}

and the compiled PDF file does not show the reference section.

I have tried \bibliography{reference.bib}, \bibliography{doc/reference}, \bibliography{./doc/reference.bib}, they all generate the same error. I have done some research where it says that I should compile using bibtex, so I tried the following code:

    subprocess.call(["pdflatex", "./doc/card.tex"])
    subprocess.call(["bibtex", "./doc/reference.bib"])
    subprocess.call(["pdflatex", "./doc/card.tex"])
    subprocess.call(["pdflatex", "./doc/card.tex"])

That still produces the same error.

1
  • Please try to provide a MWEB (minimal working example with bibliography) reproducing the problem. The bibliography part in your log just is a warning and does not seem to be the problem - instead there seems to be some syntax error with your other code. – epR8GaYuh Mar 9 at 6:27
0

I was calling bibtex on the wrong file. It should have been

    subprocess.call(["pdflatex", "./doc/card.tex"])
    subprocess.call(["bibtex", "card"])
    subprocess.call(["pdflatex", "./doc/card.tex"])
    subprocess.call(["pdflatex", "./doc/card.tex"])

So it runs bibtex on the generated pdf file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.