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

learn more… | top users | synonyms

10
votes
1answer
869 views

Two column layout with text and knitr chunk

When making presentations (with latex beamer class), I often go for a frame layout with text and equations on the left and a corresponding figure on the right. My standard solution has been to wrap ...
9
votes
1answer
1k views

R+LaTex to HTML5 better than pdf?

I use R together with ggmap, ggplot2, Rstudio, knitr, and beamer to produce presentations in pdf. Soon I hope to have time to learn TikZ too. I have not moved to Markdown because I appreciate the ...
8
votes
1answer
969 views

Command already defined

I came across an odd problem compiling LaTeX exam.cls document producing with knitr. Pasted below is minimal reproducible code. knitr compiles fine, but pdflatex terminated with: Command \framed ...
8
votes
1answer
118 views

Different colors for default and language-specific listings

I'm generating pdf documents using knitr and pandoc. The conversion is mostly automated from R markdown -> markdown -> latex -> pdf. However, my documents combine R source code and its output, and I ...
7
votes
2answers
661 views

tikzDevice is not getting sizes right (knitr)

I am using OSX, pdflatex, R (cran), tikz/tikzDevice and knitr to create my documents. My problem is that the font sizes of the produced tikZ-file do not match the LaTeX document font sizes. Result / ...
7
votes
4answers
113 views

tikz has probably problems with czech babel when compiling .Rnw

Problem Tikz seems to have a problem with \usepackage[czech]{babel}. I had a moderately big .Rnw document written in czech with some plots via knitr chunks. When I set dev = 'tikz' the TeXmaker ...
7
votes
4answers
1k views

knitr and biblatex

I'd like to create a PDF report with knitr with LaTeX-code in RStudio with biblatex for citations. However, the in-text-citations are always undefined and no bibliography is printed. The same ...
6
votes
2answers
2k views

Vertical aligning text and vertical height of rows in longtable environment

I have now been working on fixing this problem for some time and I have read through some forums on the Internet and tried different things, but I can't solve this problem. I am looking to have some ...
6
votes
1answer
159 views

Is it possible to get Sweave/knitr in RStudio to output the .tex file without typesetting it?

I would like to know if it is possible to tell Sweave or knitr in RStudio to create the .tex file without trying to typeset it. I want to be able to run my .Rnw file and produce a .tex file which I ...
6
votes
2answers
1k views

R-code linebreaks AND code highlighting in knitr

I used the great answer from @Sharpie on 19 Jan 2012 Getting Sweave code chunks to stay inside page margins? to get linebreaks in the R-code, but how can there be code highlighting (colors) too? ...
6
votes
1answer
361 views

Error compiling .Rnw in TeXstudio (knitr with PdfLaTeX)

I´ve been trying to get the minimal Demofile for knitr running and compiling in TeXstudio, but I keep getting errormessages. Here´s the info, mybe somebody can help me out about what I´m doing wrong: ...
6
votes
1answer
502 views

Building TeX file from knitr Rnw as child of larger parent TeX file to use R objects and output

Here's my general problem: I'm writing my dissertation using a LaTeX template (http://www.latextemplates.com/template/masters-doctoral-thesis). The template is a parent file with multiple chapters as ...
5
votes
2answers
92 views

What do Sweave/knitr offer that make doesn't?

I use LaTeX to write papers and R for data analysis and visualization, so I've been looking into Sweave and knitr. The Sweave website says: The purpose is to create dynamic reports, which can be ...
5
votes
1answer
453 views

How to build Knitr document from the command line

I would like to compile a knitr document from the command line. With Sweave, the sequence R CMD Sweave my_sweave_file.Rnw latex my_sweave_file.tex latex my_sweave_file.tex dvips my_sweave_file.dvi ...
5
votes
1answer
329 views

Beamer (with style) to Html5?

My organization require the use of a standardized powerpoint template for how slides should look, so I've written my own Beamer .sty (style file). Then I write .Rnw-files in RStudio that I knit ...
5
votes
2answers
144 views

Create pdf with subset of slides

I use knitr and RStudio with XeLaTeX to create a presentation with many slides. But sometimes not all of the slides should appear in the final pdf. Is it possible to have a variable that I change ...
5
votes
1answer
227 views

knitr and font style consistency in graphics

I am starting to use knitr to print graphics from R in my document. So far what I have been doing (I don't know if this is the best approach, but it is working) is to load the my R workspace with ...
5
votes
0answers
173 views

Arguments of R Functions in Beamer with knitr

I'm using helpExtract.R function (can be obtained from here) to get arguments of R functions in Beamer with knitr. My (.Rnw) MWE is \documentclass{beamer} \usepackage{ragged2e} %new code ...
5
votes
0answers
287 views

knitr & xcolor: incompatible color definition

I'm using knitr and RStudio to compile LaTeX. In my real project I'd like to use some options from the LaTeX package 'xcolor', but when I do include \usepackage[options]xcolor, I get the error message ...
4
votes
1answer
328 views

Using Greek letters in LaTeX tables

I have the following Rnw document which I intend should produce a small table with "a b c" and "α β γ". At the moment, the encoding seems to be causing problems. The funny thing is that the output in ...
4
votes
1answer
703 views

knitr problem after update to R 3.0.0

I just updated R to 3.0.0. I couldn't compile PDF from my .Rnw file, which I could do with R 2.15. Here is the error I got: ! Undefined control sequence. l.192 \SweaveOpts ...
4
votes
1answer
149 views

Pgfplotstable converting zeros to — in a knitr inline table

how do I change each 0.0 to -- without having to reference each as string type or making the whole table string type? The actual table is quite long and it would take too long to do it manually. For ...
4
votes
1answer
23 views

Howto: Set up knitr (*.Rnw compilation) from in TexStudio

How do I set up TeXstudio to compile xxx.Rnw files? I am using the TeX-Editor TeXstudio 2.7, on Windows 7, and R 3.01 64-bit. I would like to write a xxx.Rnw-file in TeXstudio and then from ...
4
votes
1answer
35 views

Turning off line-wrapping in auctex for smooth transition with ess in same file

I sometimes use auctex + ess for Sweave/knitr documents. Every time I switch from auctex to ess and vice versa, there is a pause/jolt while the auctex lines re-wrap themselves. Previously, I also ...
4
votes
1answer
73 views

Insert a TeX file created with knitr into a main TeX file

I want to insert a knitr output file (created in RStudio as .rnw file, then I compiled, it creates the .tex file) into my main .tex file. But I got an error, how we can do this? Knitter Tex file: ...
4
votes
1answer
224 views

Align Numeric Values from knitr command \Sexpr{} by Decimal in Table

How can I align numeric values brought in from the knitr command \Sexpr{} by decimal in a table?
4
votes
1answer
27 views

inline knitr code that isn't a simple number

It is easy enough to do something like \Sexpr{1 + 1}. But how can I do \Sexpr{mymatrix} with mymatrix being a matrix object in R workspace? More generally, how can I print object that is more complex ...
4
votes
0answers
108 views

Best Practice for nice layout with tikzDevice

R+tikDevice+LaTex+knitr is (as I understand it) the most efficient way to get relly nice looking publications from R, with maximum layout-support from LaTeX. I'm using R+LaTex+knitr now, but would ...
4
votes
0answers
51 views

passing a String from an R Script to .Rnw template R code section ,brew/knitr

this is my first ever post and i am quite new to all of this, so i hope i am doing this right. my problem is the following: i wrote some R code to get some ID's from a Database, which are then used ...
4
votes
0answers
120 views

Color first row in a xtable generated table

I am trying to color the FIRST row of my table. But if I add \rowcolor[gray]{0.95} to the FIRST row the colored row will be the SECOND. Indeed it is quite straight forward to modify from the second ...
4
votes
0answers
89 views

How to mantain consisten font size in different plots

I usually embed numerous R plots in my TeX documents. knitr is very handy in helping me producing plots using the same font family of the TeX document. But a different problem of consistency is given ...
3
votes
2answers
183 views

Force paragraph to stay with previous

I am using knitr to create inline sparkline-esque graphics. However, when knitr inserts images that it generates with R, it add a blank line, which forces LaTeX to make a new paragraph. That is, if I ...
3
votes
1answer
171 views

Setting Knitr options

The following code chunk doesn't work I get an error message and it disrupts the compilation of my document. Not sure if anyone has any ideas? Very M WE below. As @Speravir pointed out, not sure it ...
3
votes
1answer
7 views

display \Sexpr{} in Latex without evaluation

I am working on a tutorial for the knitr package using the beamer class. I was able to display latex code and knitr chunks inside my presentation without evaluation but I additionally want to add ...
3
votes
1answer
48 views

R console output spills into LaTeX when using rgdal

I can't avoid the R console output from spilling into the LaTeX document compiled by knitr. Please consider the following \documentclass{article} \begin{document} <<Map, dev='jpeg', dpi=300, ...
3
votes
1answer
183 views

how to keep position of rotated tables

Since I'm working with R, I'm using the xtable package to produce my tables in Latex. Some of the tables only fit the page if rotated. It seems that sidewaystable always starts a new page. My problem ...
3
votes
1answer
222 views

Is there a PythonTex equivalent to \Sexpr{} in R?

I started to use the excellent PythonTex package to write reproducible reports but can't seem to get it to evaluate Python code inside a LaTeX command. R has Sweave & knitr which provide the ...
3
votes
1answer
138 views

Robust processing of autogenerated LaTeX files that contain many errors

I use knitr to generate pretty reports, with pdflatex as backend. Everything works fine if the R code runs without error. However, if the R code fails, the autogenerated file is sometimes invalid in ...
3
votes
1answer
715 views

Using knitr, how can I rotate page to landscape and fit the figure to full extent?

LaTeX newbie here, so please be gentle. I'm working with knitr to generate pdf report. The document consists of quite few large maps, with a lot of details or small multiples. Ideally, whenever such ...
3
votes
1answer
242 views

knit with `pdflatex --shell-escape myfile.tex`?

I want to insert a word count into my .Rnw file. To do this, I have the following line in myfile.Rnw: \makeatletter\@@input|"echo `texcount -1 myfile.tex`| cut -c1-4"\makeatother But this requires ...
3
votes
2answers
177 views

Suppress library comments from ouput with knitr

I noticed that some library comment manage to pass through the knitr options, with R 3.0.1 and knitr 1.5 running on Mac OSX 10.8.5. The following MWE \documentclass{article} \begin{document} ...
3
votes
1answer
230 views

addplot data frame

Square one: I have about 8 hours of experience. I want to make a barplot in pgfplots and see many great, creative solutions on this blog. All I want at this stage is not to specify coordinates and not ...
3
votes
1answer
210 views

Math mode in knitr

How do one use a math-mode in knitr? For example as a label for X-Y axis: <<fe, echo=FALSE, sanitize=TRUE, dev="tikz">>= plot(1:10, main="${}^{57}Fe$", xlab="$\\\\lambda$", ...
3
votes
1answer
133 views

Knitr and tikzDevice not working together with article options

I have a problem with knitr and tikzDevice, like someone before me. (See tikzDevice is not getting sizes right (knitr) .) He used dev.args to get rid of this error, but if I run this code through ...
3
votes
1answer
67 views

TikzDictionary slow and blocking in knitr

I need to knit presentations with many slides and Tikz-plots. Knitr is fantastic for this, but it takes very long time and I cant knit two reports in parallel. I have isolated the problem to the ...
3
votes
1answer
344 views

How use LaTeX counters to label knitr code chunks?

Imagine one has the LaTeX environments Example and Solution defined from the theorem environment. I have several Examples in numerous child documents which make up a book. LaTeX will automagically ...
3
votes
0answers
237 views

How to keep ggplot font size constant when varying figure width

I have different figures across my document with different width. I set the the font size for all ggplots globally with theme_set(theme_bw() + theme(text=element_text(family="Palatino", size=20))) but ...
3
votes
0answers
79 views

Fontsize with knitr & tikzDevice

I saw there are already a couple of questions on the argument (here and here) but since they are a few months old and since I can't manage to make the option dev.args=list(pointsize=5) works even ...
3
votes
0answers
69 views

Using subcaption package with knitr

How can I use subcaption package in knitr, instead of the obsolete subfig and \subfloat? Or, maybe, specify additional options with fig.env = 'subfigure'? It needed something like this: ...
3
votes
0answers
208 views

Show knitr-RNW document structure in Kile

When working with a knitr file (RNW document) on Kile the document structure isn't shown in the structure view, even though it contains a valid LaTeX structure of parts, sections etc. If I change the ...