2013-12-16 9 views
7

apa6eのようなクラスでknitrを使用すると、コードチャンクはデフォルトでドキュメントの残りの部分のようにダブルスペースになります。これは望ましくない。knitrシングルスペースコード(デフォルトはダブルスペース(Rnw))

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

はどのようにこれが世界的に行わなく、テックス単一のスペースタグでラップすることができます:

この

はでラップすることによって変更することができますか?

MWE .Rnw

\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} 

答えて

8

を提出あなたはsinglespace環境でknitr出力を配置する(デフォルトでは空である)knitroutを再定義することができます:

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

は完璧に動作します。ありがとうございました。 –

関連する問題