例如,我想存储下面的字符串(包括结束线),但是我不知道这个函数是什么。我以为quote()会起作用:
mystring <- quote(
\documentclass{article}
\usepackage{graphicx}
\begin{document}
%\tableofcontents
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures
\newpage
\stepcounter{figure}
)但没那么走运。
谢谢你,徐。
发布于 2011-06-28 02:06:59
您需要转义反斜杠:
mystring <- "
\\documentclass{article}
\\usepackage{graphicx}
\\begin{document}
%\\tableofcontents
\\addcontentsline{toc}{chapter}{List of Figures}
\\listoffigures
\\newpage
\\stepcounter{figure}
"
cat(mystring)
#
# \documentclass{article}
#
# \usepackage{graphicx}
#
# \begin{document}
#
# %\tableofcontents
# \addcontentsline{toc}{chapter}{List of Figures}
# \listoffigures
#
# \newpage
# \stepcounter{figure}
#
# assuming your string is stored in "foo.txt"
mystring <- paste(readLines("foo.txt"), collapse="\n")https://stackoverflow.com/questions/6496947
复制相似问题