The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
0
votes
0answers
15 views

How do I get my output to fit into the gray box using knitr?

Some of my output is extending outside of the gray box by about 1-1.5 inches. How do I make the gray box bigger or the output smaller so it fits in the gray box and looks better?
2
votes
1answer
61 views

R Markdown/pandoc: Change how code blocks are converted to LaTeX

I use rmarkdown to generate a pdf file (which uses pandoc, which in turn uses pdflatex). By enabling keep_tex option, I noticed that code blocks without language type always become verbatim, e.g.: ```...
2
votes
1answer
46 views

How can I have a latex type expression as a column name in R?

I am working on many kables using the kableExtra package. Say you have a dataframe,df, that is 5 rows and 5 columns. in R you can do names(df)=c("A","B","C","D","E") for example. Once you have the ...
0
votes
0answers
9 views

RStudio knits weave and miklatex/mactex

which is the best place to start for a newbie latex with rstudio and sweave/knitr i need to make mathematical calculations and simple plots of sales over time
0
votes
0answers
43 views

Basic R code yields errors of “unclosed $” in knitr

I cannot use R code in Overleaf Knitr, since any basic code which includes $ yields error of unclosed $. Even the sample file of knitr in Overleaf itself causes LaTeX error: https://www.overleaf.com/...
0
votes
0answers
36 views

The code works in R, but not while compiling it in LaTeX

I am trying to compile a code in LaTeX (the code is prepared by knitr in R). In RStudio everything seems to be OK: Writing to file Trial.tex Processing code chunks with options ... 1 : keep.source ...
1
vote
0answers
37 views

Cannot install packages in the Knitr environment Overleaf

I am trying to write my R code directly in my Overleaf document using knitR. However, this message pops up when I run the following code: <>= # Install relevant packages install.packages('...
1
vote
1answer
87 views

Is there a latex package for working with Rtex files locally

Working with Overleaf using .Rtex files and I love it. However, I just discovered that Overleaf does not support a lot of the R packages (e.g., tidyverse, sqldf) and does not work with large data sets....
2
votes
1answer
179 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
53 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
75 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 ...
2
votes
1answer
56 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
81 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,...
1
vote
1answer
47 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
129 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
63 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
826 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 ...
5
votes
1answer
688 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
284 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
191 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
387 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
51 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
135 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
715 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
56 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
128 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
73 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
420 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
183 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
452 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
184 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
368 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
513 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
213 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
1k 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
3answers
5k 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
3k 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
201 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
800 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
764 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
151 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
275 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 ...
2
votes
1answer
925 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
996 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
176 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
656 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
892 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
102 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 ...