Debian Codegraph @

R/toLatex-tools.R

raw
1 LaTeXcape <- function(x){
2 x <- gsub("$","\\$",x,fixed=TRUE)
3 x <- gsub("_","\\_",x,fixed=TRUE)
4 x <- gsub("^","\\^",x,fixed=TRUE)
5 }
6
7 checkLaTeXcape <- function(x,where){
8 do.warn <- any(grepl("$",x,fixed=TRUE))
9 do.warn <- do.warn || any(grepl("_",x,fixed=TRUE))
10 do.warn <- do.warn || any(grepl("^",x,fixed=TRUE))
11 if(do.warn)
12 warning("Unescaped TeX special in ",where)
13 }