如何使用#-sign标记文本?
在这里,Sweaving和编译没有问题:
<<echo=false,results=tex>>
cat("This is my text\n")
@
Run Code Online (Sandbox Code Playgroud)
但在这里,编译会出错:
<<echo=false,results=tex>>
cat("This is #my text\n")
@
Run Code Online (Sandbox Code Playgroud)
哈希标志无法在tex中编译.我必须将Sweave选项设置为"tex",因为我想在循环中打印不同的文本文件,每个文本文件应该用新的章节分隔.
<<results=tex>>
for(i in d){
tx <- readLines(i)
cat(tx, sep="\n")
\chapter{i}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的每一个提示.
TIM
你必须逃避哈希符号,因为它在LaTeX中具有特殊含义.
\documentclass{article}
\begin{document}
\SweaveOpts{concordance=TRUE}
<<echo=false,results=tex>>=
cat("This is \\#my text\n")
@
\end{document}
Run Code Online (Sandbox Code Playgroud)