Reputation: 377
I am working on a two-column (Rnw, latex) document where the width is at a premium. By default knitr indents the code blocks by 4 spaces. How can I reduce this default indentation?
Many thanks David
Upvotes: 6
Views: 1100
Reputation: 30194
Either do not reformat the code (use the chunk option tidy=FALSE
) and manually indent by two spaces,
<<tidy=FALSE>>=
if (TRUE) {
# code here
}
@
or set the R option reindent.spaces
to a smaller value, e.g.
options(reindent.spaces = 2)
This option is passed to the formatR package to reindent your code, and knitr uses formatR to reformat your R code by default.
Upvotes: 3