开发者

how do I store as a string a long quote (with weird characters)

For example, I would like to store the string below (including the endlines), but I cannot figure out what the function is. I thought quote() would work:

mystring <- quote(
\documentclass{article}

\usepackage{graphicx}

\begin{document}

%\tableofcontents
\addcontentsline{toc}{chapt开发者_JAVA技巧er}{List of Figures}
\listoffigures

\newpage
\stepcounter{figure}
)

but no luck.

Thank you, Xu.


You need to escape the backslashes:

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")
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜