Questions tagged [knitr]

knitr is an R package for dynamic report generation based on the concept of literate programming.

Filter by
Sorted by
Tagged with
2
votes
1answer
37 views

Embedding R (kable) results in LaTeX

Apology at first if this question has been asked or the sample is not reproducible. I'm totally new to LaTex and happy to take any advice. I am working on my thesis on a .tex LaTex template given by ...
2
votes
1answer
43 views

Manual bibliography in knitR with \bibitem{} works but cannot use \cite{} with it

I am trying to use a manual/embedded bibiography in a knitR/LaTeX document (long story short but for various reasons I don't want to be using a seperate .bib file because this script will be used many ...
2
votes
2answers
34 views

How to use \sexpr{} with variable that has “_” in it (i.e. avoid “math mode” error)

I am using knitr in R to write up a document in LaTex. Below a certain of code, I would like to refer to a variable I used in R. <<chunk>> var <- "ENSEMBL_MART_ENSEMBL" @ In this ...
0
votes
0answers
18 views

Multiple spacing in RMarkdown Beamer

How can I set different spacings in my RMarkdown Beamer. I use the package setspace but when I put \singlespace in some place and \doublespace in other place, I got an Error. It seems that RMarkdown ...
1
vote
1answer
44 views

Class tufte-book and R listings code box width problem

When I run the following MWE: \documentclass{tufte-book} \usepackage{Sweavel} \usepackage{amsthm} \usepackage{mathtools} \usepackage{soul} %%%%%%%%%% % R example %%%%%%%%%% \newtheoremstyle{rex}{}{...
1
vote
0answers
33 views

read_chunk doesn't work [closed]

I tried the code suggested previously which should work execute R code in latex file imported from separate R file but I can't see the external-code from R. Here's my script \documentclass[12pt,...
0
votes
1answer
36 views

Syntax highlighting not working properly

I'm using TeXstudio and for a while now, every time I write in math mode using $...$ or \[...\], it highlights most of the commands as if they were syntax errors although it compiles just fine. For ...
1
vote
0answers
90 views

Run code chunks in subfiles

My document consists of several subfiles that are imported into my main. However, i would like to run code chunks with R output in each subfile before the document is stitched together by main.tex. I'...
1
vote
1answer
43 views

How to cite german book titles properly (upper case) with csl and rmarkdown?

I am using RMarkdown in RStudio and want to cite several sources using csl, specifically I use the style "elsevier-with-titles.csl". I want to cite a german reference, so title must have upper case ...
0
votes
3answers
395 views

Can I type \LaTeX inside inline code in Rmarkdown?

I know I can use $$ to write \LaTeX in Rmarkdown documents like $\beta$. My goal is if this is possible inside inline code. I would do `$\beta$` or `$\\beta$`, but both do not work. In case it is ...
4
votes
1answer
368 views

How to insert references and bibliography into a .Rnw file produce with RStudio R Sweave and knitr?

So far, I have successfully used RStudio and R Markdown to write scientific papers and insert citations from the medical literature without significant problem as shown in the minimal example (MWE) ...
0
votes
1answer
224 views

format inline Sexpr number to include a comma

I have the following inline code to call a value from R code. The value called for example is 8000. I would like to format the value so there is a comma for the 1,000 place - for example 8,000. The ...
2
votes
0answers
127 views

escape=F kable pdf not compiling

I am trying to include m\\textsubscript{2} in a column name using kable. When I change escape=F to allow this to occur the PDF fails to compile. Code: library(kableExtra) kable(table2.1,format="...
2
votes
1answer
237 views

incorporate R code into latex paragraph

I have a large R script I am trying to source in a LaTex document and then reference output from specific dataframes created in the source code in text in a LaTex paragraph. When I compile the PDF ...
2
votes
1answer
37 views

wrong encoding using knitr on bibentry

I'm trying to cite packages used following this code: https://stackoverflow.com/a/43888025/8146116 I change the bibentry style to latex but I get the warning: Warning: :0-4: Some input could not ...
0
votes
0answers
94 views

Overfull hbox within an R output

I'm using Sweave to work with R in a LaTeX document and when I compile my script I get the following badbox, as showed in the log file: Overfull \hbox (14.62822pt too wide) in paragraph at lines 127--...
1
vote
2answers
426 views

Overfull hbox in a section title

Every now and then I get this error and I don't know how to solve it. From what I understand reading other posts, it's because LaTeX doesn't know how to hyphenate some sentences and finds no good way ...
0
votes
1answer
38 views

creating multiple generic letters from pulling info from an excel/csv file

I wanted to create 100 invitation letters for a group of 100 people whose name and phone number I have in an excel sheet. I have written one generic letter and wanted to the put in the name and phone ...
1
vote
0answers
47 views

Greeks Letter in RStudio + Sweave

This is my Rsweave reproducible code: \documentclass{article} \usepackage[a4paper,left=1.5cm,right=1.5cm,bottom=1cm,top=3cm]{geometry} \usepackage[perpage]{footmisc} \usepackage{csquotes} \...
1
vote
0answers
98 views

Problem with out of KableExtra tables with LATEX in Rstudio: paste0 function

This is my Rsweave reproducible example: \documentclass{article} \DeclareUnicodeCharacter{3B1}{$\alpha$} \DeclareUnicodeCharacter{3C4}{$\tau$} \DeclareUnicodeCharacter{3C3}{$\sigma$} \...
0
votes
0answers
65 views

Get path of (custom) auxiliary file when `-output-directory` flag is given to pdflatex

In short: Say the following is built using pdflatex -output-directory=tmp: \documentclass{article} \newwrite\fileHandle \immediate\openout\fileHandle=outfile.csv \immediate\write\fileHandle{hello ...
0
votes
1answer
342 views

Loading Custom Fonts into RMarkdown

I've been testing loading my own fonts into a personal rmarkdown document using the fontspec latex package. Because I'll eventually need to knit this on a server, using the font library on my mac is ...
3
votes
0answers
143 views

Including an Rmd file in a Rnw file using pandoc

I was trying to follow this example that shows how to write a separate chapter in RMarkdown and then include it in your main RNW file using \include{}. However, I have not been able to get pandoc to ...
2
votes
1answer
399 views

Option clash with RMarkdown and beamer

I work across two separate Mac computers, a Macbook Pro at work, and a Macbook Air at home. Both macs are running identical operating systems. I am writing in RMarkdown, using knitr to compile beamer ...
3
votes
1answer
127 views

Plot symbols not showing properly using R + knitr with 'pdf' device

When I include R plots in a latex document using knitr, symbols do not show properly when knitr's graphic device is 'pdf', while everything is OK when the graphic device is 'png'. Here is a MWE: \...
2
votes
2answers
327 views

Automatic bibliography by DOI

I would like to know if it is possible in LaTeX to automatise the bibliography. For example, I would only put the DOI link in the bibliography and latex would take all the info (author, date, title ...
1
vote
1answer
422 views

How to re-run Bibtex on the file(s) - RSweave; KnitR

I have a document called Code.Rnw where I write my document in and I'm using Sweave and Knitr to compile it. For my bibliography I use biblatex. My setting is the following: \usepackage[bibstyle=...
3
votes
2answers
2k views

Left Quotation Marks when using RMarkdown and knitR

Normally when you want left quotation marks in LaTeX, you type the following: `` However, in RMarkdown, you will trigger a block of R code to run when you type two pairs of backticks on the same ...
1
vote
0answers
175 views

TeX capacity exceeded using Knitr

I am unable to weave a document containing LaTeX and R code using RStudio due what I think are TeX capacity limitations. Is there a way of fixing this without having to compile using LuaLaTeX which is ...
2
votes
1answer
718 views

Escaping % symbol when passed as a string from R chunk to knitr

I can't get the following to work: \begin{minipage} <<percentile, echo=FALSE>>= your_rank <- percentile ## calculated earlier rank_message <- ifelse(is.na(score), ' ', paste0("...
2
votes
1answer
3k views

pdflatex problem with Rstudio

I'm trying to compile a simple Rnw file in Rstudio using knitr "compile pdf" functionality. But it gives me an error. This is what I have in hello.Rnw: \documentclass{article} \begin{document} ...
1
vote
1answer
2k views

Minimal LaTeX install for knitr to export PDFs from Rmarkdown on Debian-based system

I use RStudio and started writing Rmarkdown documents to knit them into HTML pages and PDFs. I tried installing TexLive but it failed when the astounding number of packages filled my limited ...
2
votes
2answers
172 views

Determine within LaTeX how many times latexmk have run

Backround So I've gathered that latexmk runs pdflatex until "all files are up to date". Problem and motivation Say that I have some dynamic content that should only be run once. By dynamic I mean a ...
1
vote
1answer
690 views

execute R code in latex file imported from separate R file

My personal objective in this Rnotebook revolution where typesetting and number crunching cohabitate is to keep R files separate from latex and as little polluted by markdown as possible and only in ...
8
votes
1answer
682 views

colour R code to match knitr theme using listings, minted, or other

with the listings package, and the help of this answer and this answer, I can include R code in my LaTeX document that looks almost like what knitr produces natively. However, as I am combining a ...
0
votes
1answer
137 views

Decreasing the size of a plot

Hi there so I have this plot in knitr in R, which i want to transfer to my Latex PDF file, but it's just way too big it fills up like 3/4 of a page: compPlot ( mdata$GDP, fitted( cesNewton), xlab = "...
1
vote
1answer
239 views

Using knitr and Latex problem

So I am currently doing a CES function estimation using the micEconCES package in R. I want to incorporate the outputs of the estimation into my latex file, but I cant seem to get it to work. This is ...
1
vote
1answer
744 views

Including multiple images with single caption

I'm trying to insert side-by-side images with one caption using knitr: --- title: "XY" author: "Doogan" date: '`r format(Sys.Date(), "%B %d, %Y")`' graphics: yes output: pdf_document: toc: no ...
0
votes
1answer
877 views

Make all fonts in beamer presentation larger

I'm working in R and knitting my output into a beamer presentation (The script below can be copied into an R script). My titles are naturally larger than the main text. However, I would like ...
1
vote
0answers
156 views

Incredibly slow compilation with knitr and tikzDevice

I am having some compilation difficulties when using knitr and tikzDevice. Compilataion works, but I am seeing times upwards of 10 minutes, and this is only increasing as my document grows (I am ...
2
votes
2answers
506 views

Using LuaLaTeX and knitr together

I would like to include R results in a LuaLaTeX document, which I prefer over XeLaTeX mainly because of the greater support of the package microtype. Do you know whether and how is it possible? ...
2
votes
1answer
705 views

Excessive blank space after a graphic using R and kntir

The problem is the following: I want to have the text from section 6 way closer to the graphics. This is the code I am using: \documentclass{article} \usepackage{graphicx} \usepackage{microtype} \...
0
votes
1answer
93 views

PassOptionsToPackage and knitr child documents

I am using Knitr and the standalone version of .RNW files where I can compile either a main document or work with and compile child documents individually. Because of other packages, I would like to ...
2
votes
1answer
673 views

debugging LaTeX errors in R - viewing dependencies

I've installed MacTex and I'm trying to format tables in a PDF with the kable function using knitr/Rmarkdown. When I output my data as kable(dt, format = 'latex') it works fine, but as soon as I try ...
2
votes
1answer
340 views

Can’t yet set up knitr with TeXShop

I want to use knitr with TeXShop. So far I can’t get knitr and TeXShop to talk. I’m not sure how to make a reproducible example nor how to make the following succinct, but here’s what I’ve tried: ...
3
votes
0answers
239 views

Proper ERT LaTeX Code in LyX Math-mode

The problem I am having is I cannot have full "monospaced font" ERT code in LyX math-mode. In the picture below, you can see that in math-mode there is no red box and the argument in the curly ...
4
votes
1answer
5k views

How to center a multiline equation? [duplicate]

I want to center multi row equationing but all my attemts won't work. I'm working with pandoc/knitr of Rmarkdown. I show you an example: \begin{equation} \begin{aligned} <!-- \begin{center} --> ...
1
vote
2answers
591 views

Compiling a Latex-Sweave child into a main Latex-Sweave file

I'm in the process of writing my thesis, where I have two chapters ready. I'm looking to unify those two chapters into one single Sweave file. Suppose I have a folder called chapter1 which contains ...
1
vote
1answer
1k views

Rmarkdown - fig.cap will not add caption in figure

I want to add a caption to a figure in Rmarkdown, and it won't let me. The header of the file looks like this --- title: "..." author: "..." date: '...' output: pdf_document: fig_caption: ...
6
votes
2answers
627 views

pandoc, markdown: create self-contained .bib file from cited references

In Latex there are a variety of tools that can be used to create a self-contained .bib file for the cited references that are extracted from several larger .bib files; see this popular tex....