2013-12-16 6 views
7

Podczas korzystania z programu knitr z klasą, taką jak apa6e, fragmenty kodu są domyślnie podwójne, jak reszta dokumentu. To nie jest pożądane.knitr kod pojedynczego spacji, gdy klasa domyślnie podaje podwójną spację (Rnw)

ten może być zmieniany przez owijania:

\begin{singlespace} 
<<*>>= 
CODE 
@ 
\end{singlespace} 

Jak można to zrobić globalnie zamiast owijania TEX pojedynczych tagów przestrzeni?

MWE .Rnw złożyć

\documentclass[leavefloats]{apa6e} 
\usepackage[american]{babel} 
\usepackage{csquotes} 
\usepackage[style=apa,backend=biber,bibencoding=latin1]{biblatex} 
\DeclareLanguageMapping{american}{american-apa} 

\begin{document} 

<<setup, include=FALSE, cache=FALSE>>= 
# set global chunk options 
opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold') 
options(replace.assign=TRUE,width=90) 
library(ggplot2); library(xtable) 
@ 

\title{MWE} 
\shorttitle{MWE} 
\author{Tyler Rinker} 
\date{\today} 
\authornote{\dots} 
\abstract{This is an example of an abstract in APA.} 
\maketitle 


<<foo>>= 
x <- "Got me some code" 
y <- "look another line" 
paste(x, y) 
@ 

\begin{singlespace} 
<<bar>>= 
x <- "Got me some code" 
y <- "look another line" 
paste(x, y) 
@ 
\end{singlespace} 

\end{document} 

Odpowiedz

8

Można przedefiniować knitrout (która jest domyślnie pusta), aby umieścić knitr wyjście w środowisku singlespace:

\renewenvironment{knitrout}{\begin{singlespace}}{\end{singlespace}} 
+0

działa idealnie. Dziękuję Ci. –

Powiązane problemy