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

learn more… | top users | synonyms

8
votes
1answer
211 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 ...
2
votes
1answer
336 views

Dynamically format labels/columns of a LaTeX table generated in R/knitr/xtable

I have some tables coming from the statistical package R that I want to export in LaTeX markup. I would like to make every column large as the longest word of its label (assuming for simplicity the ...
4
votes
1answer
154 views

Insert a TeX file created with knitr into a main TeX file [duplicate]

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: ...
1
vote
0answers
16 views

Insert the .tex file created through the knitter to main .tex file [duplicate]

I want to insert out put file (created in RStudio as .rnw file, then I complied, it creates the .tex file) into my main .tex file. But I got an error, hw we can do this?
3
votes
2answers
975 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} ...
4
votes
1answer
278 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 ...
2
votes
1answer
209 views

How to loop over R objects OUT OF chunks

I want to typeset with TeX a report based on data from an R object (dataframe). The idea is to print a nice TeX table from each line of a R dataframe. Something like \begin{tabular}{ l c r } A1 ...
6
votes
0answers
270 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 ...
8
votes
1answer
283 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 ...
0
votes
0answers
146 views

knitr yielding different output in pdf than in R console

I am running RStudio Version 0.98.484 and R version 3.0.2 on OS X Mavericks. While using knitr I noticed a discrepancy between the console output from a summary() command and that generated in the ...
1
vote
0answers
95 views

Is it a known bug with the animate package?

In slide 10 here, I have embedded three animations in only one slide. You can see there's a bug by playing with the animations, is it a known bug ? Or is there something special to do in the code for ...
1
vote
1answer
266 views

knitr generated pdf cut border off from figure

I have a a problem with a figure that is correctly generated in RStudio but when knitted its right margin is not set correctly. Please consider the following MWE \documentclass[a4papera4paper, ...
7
votes
0answers
614 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 ...
3
votes
0answers
348 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
1answer
59 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, ...
0
votes
1answer
347 views

Special characters in knitr generated figure caption

I would like to pass special characters and formatting with the knitr generated captions. I am trying to understand two things: 1) Is it possible to pass LaTeX syntax through the caption? 2) How ...
2
votes
0answers
64 views

knitr pdf search invisible text

I use the fantastic knitr to generate beamer-pdf’s with hundreds of slides of plots. Every plot shows data of different measuring equipment, so for example the plot showing result of measuring ...
3
votes
0answers
98 views

Fontsize with knitr & tikzDevice [duplicate]

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 ...
1
vote
0answers
169 views

Clash between knitr, tikzDevice and pgfplotstable

I use knitr to compile a document composed of two .Rnw. Please considered the following examples from this answer main.Rnw % !Rnw weave = knitr % !TeX program = pdfLaTeX ...
2
votes
1answer
406 views

Is it possible to \include a .TeX file compiled from .Rnw?

I have a document with this structure: main.TeX which (ideally) includes bodytext.TeX compiled with knitr from bodytext.Rnw. I say ideally because apparently it is not that simple. I noted that ...
4
votes
0answers
106 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 ...
0
votes
0answers
28 views

How to prevent plots being printed out of document's sections? [duplicate]

I am preparing a document using knitr in which I have multiple charts within two or more sections. The majority of the plots is printed at the end of the document but I would like them to stay within ...
3
votes
0answers
122 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: ...
2
votes
1answer
557 views

passing a variable from R to Tex in knitr

I am sure this has been asked multiple times since it seems to be a common issue. I looked around but all I could find was the \Sexpr for sweave which does what I want. I am using knitr and I can't ...
6
votes
1answer
622 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: ...
1
vote
1answer
462 views

How to debug if Knitr quits unexpectedly when composing tikz figure

I have a .Rnw file that Knitr used to compile perfectly fine until my backend dataset changed. Probably then the size of the graph changed also. For reasons I don't understand knitr now stops abruptly ...
2
votes
1answer
883 views

knitr xtable make two tables equal width

I am using knitr and xtables to automate a report procedure. I want to include a few tables in this report and make them displayed with equal width. The Rnw code is listed below. Anyone could tell me ...
2
votes
1answer
168 views

knitr compiling time with large datasets

I noticed that with a large dataset knitr takes an unexpected long time to compile my document: about 23 minutes from when knitr completes the last chunk to when it writes the .tex. I don't understand ...
2
votes
1answer
222 views

siunitx error: “invalid-number” from R

I have a document in .Rnw which I use to produce a .texdocument with kntir. I have a problem with the formula \num{\Sexpr{max(degree)}} which in R console produce 12598 but after the running knitr in ...
5
votes
1answer
319 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 ...
3
votes
1answer
307 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 ...
2
votes
1answer
118 views

How to escape inline R command to avoid issue with “while-typing” spelling check

I have a problem with my text editor Aquamacs Emacs (GNU Emacs 23.4.1) when use it with \Sexpr to print inline the output from R functions. The problem results when the R command includes special ...
3
votes
1answer
246 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 ...
2
votes
1answer
185 views

Knitr plotting outside margin

I like the look of plots that extend beyond the margins \documentclass{article} \usepackage{lipsum} \usepackage[demo]{graphicx} \begin{document} \begin{figure} \centering ...
7
votes
1answer
1k 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 ...
9
votes
2answers
972 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 ...
1
vote
0answers
128 views

Knitr/LaTeX: conditional execution based on external parameters

I'm using knitr to create LaTeX documents with integrated R code. Now I'd like to readout some external parameters (saved in a TXT or CSV file) and create a document based on the conditions specified ...
2
votes
1answer
288 views

xtable function generated latex does not get parsed for special char such as square brackets

I'm using the knitr package for putting my R output into PDF. I have two problems using xtable: When my table data has chars like this: [, ] in them, the conversion from .tex to .pdf fails with ...
3
votes
1answer
267 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
165 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 ...
2
votes
1answer
2k views

Plot two figures side by side in knitr without changing mfrow?

I would like to plot 2 figures side-by-side using knitr. I know I could use par(mfrow=c(1,2)), but I've done a lot of work making the figures just right as they are. I've seen this (Two column layout ...
2
votes
1answer
491 views

insert figure in sweave using knitr fig.path

I'm trying to insert a figure using Sweave which is located in the path C:\Users\eccehomo\Documents\mi\fig1.png. I'm using the package knitrwhich has a function called fig.pathbut I'm getting many ...
2
votes
1answer
137 views

How can I make German characters from \input file display correctly?

I'm working with a Rnw file in RStudio and knitr. Everything works correctly so far, but I stumbled upon a problem when I included a chapter to the report that is written in German. I wrote the ...
3
votes
1answer
405 views

Texstudio and Rnw Files

Is there any way in Texstudio, for the document tree to detect Rnw files called within a knitr chunk? For example, the following would be ignored: <<MYCHUNK,child='./Myfile.Rnw'>>= @ ...
5
votes
1answer
400 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
160 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 ...
2
votes
1answer
108 views

Finding the current position on the PDF

I am trying to generate automated reports in R using knitr. There are a list of objects I need to print on the PDF and the size (rows, columns, length etc.) can vary. The problem is that when any of ...
4
votes
1answer
1k 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 ...
4
votes
1answer
440 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 ...
3
votes
1answer
353 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$", ...