1

I am trying to setup a Knitr workflow in EMACS ESS.

I can get a pdf to compile using pdflatex and knitr-ess, but the bibliography is not generated.

I am using zotxt to insert citations from zotero, but I am not sure if that is relevant.

In my search to find a solution I found this https://tex.stackexchange.com/a/73779/287729 saying I should do the following:

  1. Run LaTeX
  2. Run BibTex
  3. Run LaTeX
  4. Run LaTeX

But when I try to compile the pdf with LaTeX (via Command -> LaTeX in EMACS) I get an error:

! I can't find file `myfile.rnw.tex'.
<*> myfile.Rnw.tex

(Press Enter to retry, or Control-Z to exit) Please type another input file name ! Emergency stop. <*> myfile.Rnw.tex

And the pdf is not compiled.

I tried the following:

  1. Run pdflatex
  2. Run Bibtex

but when I try to run pdflatex again it fails because of the error

Not re-weaving as input file ’myfile.rnw’ hasn’t changed
Not re-exporting as input file ’myfile-woven.tex’ hasn’t changed

Here is an MRE:

\documentclass{article}
\usepackage[backend=bibtex]{biblatex}
\bibliography{sample}
\title{ETemplate}  
\author{Your name goes here}

\begin{document}

\maketitle

\section*{Abstract} This is my abstract. It is not abstract.

@hilbornQuantitativeFisheriesStock1992

\printbibliography

\end{document}

I am open to other approaches as just want to get this functional.

Interestingly, I can get the following to compile with citations in Rstudio

\documentclass{article}
\usepackage[backend=bibtex]{biblatex}
\bibliography{sample.bib}
\begin{document}

<<setup, include=FALSE, cache=FALSE, echo=FALSE>>= Sys.setenv(TEXINPUTS=getwd(), BIBINPUTS=getwd(), BSTINPUTS=getwd()) @

this doc

\parencite{nefsc62ndNortheastRegional2017}

\parencite{hilbornMeasuringFisheriesManagement2020}

\printbibliography \end{document}

So clearly this is an EMACS issue.

Jacob
  • 11
  • You say you're using knitr, and you have rnw and woven files, but your workflow only involves pdflatex and bibtex. I don't know knitr, but I'm confused. Is this how it's supposed to work? – Teepeemm Apr 13 '23 at 14:18

1 Answers1

0

For anyone following along at home...I figured it out. Here are the steps 1. use pdflatex on the document, 2. open the myfile.tex in emacs file that was created by pdflatex (it also created a pdf). 3. use the emacs menu bar command -> LaTeX 4. use the emacs menu bar command -> BibTeX 5. use the emacs menu bar command -> LaTeX 6. use the emacs menu bar command -> LaTeX (again) and the bibliography is generated.

Jacob
  • 11
  • I'm not understanding your distinction between "use pdflatex on the document" and "use the emacs menu bar command -> LaTeX". It looks to me like your solution is pdflatex -> pdflatex -> bibtex -> pdflatex -> pdflatex, but you originally said that wasn't working. And I still don't see how knitr, rnw, and woven are involved. – Teepeemm May 27 '23 at 22:15