首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将长引号(带有奇怪的字符)存储为字符串

如何将长引号(带有奇怪的字符)存储为字符串
EN

Stack Overflow用户
提问于 2011-06-28 01:59:49
回答 1查看 671关注 0票数 2

例如,我想存储下面的字符串(包括结束线),但是我不知道这个函数是什么。我以为quote()会起作用:

代码语言:javascript
复制
mystring <- quote(
\documentclass{article}

\usepackage{graphicx}

\begin{document}

%\tableofcontents
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures

\newpage
\stepcounter{figure}
)

但没那么走运。

谢谢你,徐。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-06-28 02:06:59

您需要转义反斜杠:

代码语言:javascript
复制
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")
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6496947

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档