2014-05-04 107 views
0

當使用knitr將.Rnw文件轉換爲.tex文件時,我試圖使用一個科學名稱。運行knit時出現錯誤。這是我的包含文件.Rnw內我的代碼(需要taxizestringr庫運行):在一個Rnw文件中混合使用R和LaTeX代碼

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \Sexpr{str_c("Collared Flycatchers (\\textit{", comm2sci(commnames='Collared Flycatcher', db="itis")[[1]], "})")[1]} 

在.tex文件輸出應該是:

Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum Collared Flycatchers (\textit{Ficedula semitorquata}) 

我怎樣才能得到這個輸出在.tex文件中?

+0

does http://stackoverflow.com/questions/14124022/setting-html-meta-elements-with-knitr help? –

+0

我會想象有比這更簡單的方法,我還沒有弄清楚 – luciano

回答

3

這對我的作品

\documentclass{article} 
\begin{document} 
<<message=FALSE>>= 
library("taxize") 
@ 
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum \textit{\Sexpr{comm2sci(commnames='Collared Flycatcher', db="itis")[[1]][2]}} 
\end{document} 

這是否給你想要的是什麼?在輸出pdf中看起來是正確的。

相關問題