.bib file not used
bstaton1 opened this issue · 3 comments
I continue to be impressed by and enjoy using this package!
I'm trying to use this to preview how citations will appear in latex output:
texPreview::tex_preview(tex_lines = readLines("natbib_sample.tex"))
Where natbib_sample.tex
is taken directly from the MWE here and looks like:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[square,numbers]{natbib}
\bibliographystyle{abbrvnat}
\title{Bibliography management: \texttt{natbib} package}
\author{Share\LaTeX}
\date { }
\begin{document}
\maketitle
This document is an example of \texttt{natbib} package using in bibliography
management. Three items are cited: \textit{The \LaTeX\ Companion} book \cite{latexcompanion}, the Einstein journal paper \citet{einstein}, and the
Donald Knuth's website \cite{knuthwebsite}. The \LaTeX\ related items are
\cite{latexcompanion,knuthwebsite}.
\medskip
\bibliography{sample}
\end{document}
In the same directory, I also have the sample.bib
file:
@article{einstein,
author = "Albert Einstein",
title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
[{On} the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004"
}
@book{latexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The \LaTeX\ Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts"
}
@misc{knuthwebsite,
author = "Donald Knuth",
title = "Knuth: Computers and Typesetting",
url = "http://www-cs-faculty.stanford.edu/\~{}uno/abcde.html"
}
When I run tex_preview()
on natbib_sample.tex
, the document renders but the citations are not found:
This error is displayed in the tex_tempDoc.log file
file as well.
I can render natbib_sample.tex
just fine by opening it in RStudio and knitting it (expected.pdf).
Any ideas? Thanks!
That is great that you are exploring the package. Thank you for the feedback.
Unfortunately bib
would be beyond the scope of the package since internally only pdflatex
is called.
To render the bib
file a sequence of calls would be needed to be invoked
pdflatex DOCNAME.tex
bibtex DOCNAME.aux
pdflatex DOCNAME.tex
pdflatex DOCNAME.tex
Where DOCNAME
is the name of the parent tex
file.
Thank you for your response. I understand the reason why this doesn't work now!
I don't suppose there would be any interest in including a bibtex = TRUE
argument to tex_preview()
? I don't know much about the guts of this package and how much it would involve to do such a thing, and it may not be worth it if I'm the only one interested, but I thought I would float the idea anyways.
Thank you for the suggestion.
We haven't had any requests for this thus far.
I think that usually users use Rmarkdown
output:pdf_document
to compile such things since it does already support bib files.
If there are some repeated requests for this we would surely look into adding such a feature.
Thanks again for trying out the package.
Closing for now.