1

From this link I was able to replicate the references result.

https://texblog.org/2013/08/20/rknitr-automatic-bibliography-generation-with-biblatex-in-rstudio/

How can I add more than one output? And how can I add these references output manually ?

Ive been struggling these last days to find how to do this. But I wasnt able.

Any help?

This is the code:

\documentclass{article}
\usepackage{hyperref}
\usepackage[backend=bibtex, sorting=none]{biblatex}
\bibliography{references}

\begin{filecontents*}{references.bib}
@Manual{knitr2013,
    title = {knitr: A general-purpose package for dynamic report
      generation in R},
    author = {Yihui Xie},
    year = {2013},
    note = {R package version 1.4.1},
    url = {http://yihui.name/knitr/},
  }
\end{filecontents*}

\begin{document}

\section*{Automatic biblatex bibliography generation in RStudio using knitr}

<<setup, include=FALSE, cache=FALSE, echo=FALSE>>=
opts_chunk$set(fig.path='figures/plots-', fig.align='center', fig.show='hold', eval=TRUE, echo=TRUE)
options(replace.assign=TRUE,width=80)
Sys.setenv(TEXINPUTS=getwd(),
           BIBINPUTS=getwd(),
           BSTINPUTS=getwd())
@

<<sample-data-hist-and-box, out.width='0.48\\textwidth'>>=
sampleData <- rnorm(1000, 0,1)
hist(sampleData)
boxplot(sampleData)
@

This document was produced in RStudio using the knitr package \cite{knitr2013} by \url{http://texblog.org}.

\printbibliography
\end{document}
1

The example in https://texblog.org/2013/08/20/rknitr-automatic-bibliography-generation-with-biblatex-in-rstudio/ uses the filecontents environment to produce a .bib file and make the example self-contained.

In practice you will usually not have filecontents in your document, instead you will have a dedicated file references.bib in the same directory as the .tex file. That .bib file contains all your relevant references.

So your Rnw file would look like

\documentclass{article}
\usepackage{hyperref}
\usepackage[backend=bibtex, sorting=none]{biblatex}

\bibliography{references}

\begin{document}

\section*{Automatic biblatex bibliography generation in RStudio using knitr}
<<setup, include=FALSE, cache=FALSE, echo=FALSE>>=
options(replace.assign=TRUE,width=80)
Sys.setenv(TEXINPUTS=getwd(),
           BIBINPUTS=getwd(),
           BSTINPUTS=getwd())
@

<<sample-data-hist-and-box, out.width='0.48\\textwidth'>>=
sampleData <- rnorm(1000, 0,1)
hist(sampleData)
boxplot(sampleData)
@

This document was produced in RStudio using the knitr package \cite{knitr2013} by \url{http://texblog.org}.

See also \cite{sigfridsson}.

\printbibliography
\end{document}

and your references.bib would look like this

@Manual{knitr2013,
  title = {knitr: A general-purpose package for dynamic report
           generation in R},
  author = {Yihui Xie},
  year = {2013},
  note = {R package version 1.4.1},
  url = {http://yihui.name/knitr/},
}
@article{sigfridsson,
  author       = {Sigfridsson, Emma and Ryde, Ulf},
  title        = {Comparison of methods for deriving atomic charges from the
                  electrostatic potential and moments},
  journaltitle = {Journal of Computational Chemistry},
  date         = 1998,
  volume       = 19,
  number       = 4,
  pages        = {377-395},
  doi          = {10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P},
}

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.