ERS,
我们的实验室无法在LaTeX中正确排版包含单引号的R代码。文档编译没有错误,但是用单引号包装的R代码不是排版,因此R代码没有正确显示。
问题仍然存在,与用于编译.Rnw到pdf的工具无关。到目前为止,我们已经尝试在RStudio中编译,在CLI上使用knit()调用pdflatex,并使用knit2pdf()。
我们已经提出了一个问题的实例:
\documentclass{article}
\usepackage{graphicx}
\usepackage{upquote} %Using this pkg does not fix single quotes problem
\usepackage[sc]{mathpazo} %Problem persists with or without Computer Modern
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\usepackage[unicode=true,pdfusetitle,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=false]
{hyperref}
\usepackage{breakurl}
\usepackage{inconsolata} %Problem persists with or without inconsolata
\usepackage[auth-sc]{authblk}
%
\title{Some title \\ \vspace{3 mm}
{\large \textit{Supplemental Methods To:}\\
\normalsize "Even bigger title"}}
\begin{document}
<<setup, include=FALSE, cache=FALSE>>=
# this is equivalent to \SweaveOpts{...}
opts_chunk$set(fig.path='figure/minimal-', fig.align='center', fig.show='hold')
options(replace.assign=TRUE,width=90)
#require(highlight) # Problem persists with or without highlight
@
\maketitle
\section{Some Section}
In R, characters can be entered with double quotes or single quotes. The single quote is the apostrophe key next to ENTER on an American keyboard.\\
This R code with characters contained by single quotes does not render correctly in \LaTeX{}. But characters in double quotes do render correctly.
<<raw_nums>>=
Vector1<-c('A','B','C') # This line not typeset correctly; the quotes are missing in the pdf
Vector1
Vector2<-c("A","B","C") # Typeset correctly
Vector2
@
<<sessionInfo>>=
sessionInfo()
@
\end{document}
一种解决方法始终使用双引号,但我们中的许多人按惯例使用单引号。我们想知道是否有其他人注意到这个问题,他们是否找到了解决方案?
谢谢,菲利普A。
R版本:3.2.1
knitR版本:1.10.5
LaTeX 2e
Ubuntu Precise 64bit