on 07/14/2008 01:09 PM Stephan Kolassa wrote:
Dear guRus,
I am trying to replace "~" by "$\sim$" for TeX. However, I can't get the
backslash to work. I would like to turn "DV~IV" into "DV$\sim$IV".
sub("~","$\sim$","DV~IV") => "DV$sim$IV"
sub("~","$\\sim$","DV~IV") => "DV$sim$IV"
sub("~","$\\\sim$","DV~IV") => "DV$sim$IV"
sub("~","$\\\\sim$","DV~IV") => "DV$\\sim$IV"
Alternatives 1 and 3 also yield warnings about unknown escape sequences
(no surprise there). I have been unsuccessfully searching the archives.
sessionInfo below.
Thank you all for your time!
Best regards
Stephan
You want door number 4 because when the double escape is cat()'d to the
.tex file, you get:
> cat("DV$\\sim$IV", "\n")
DV$\sim$IV
which is what you want latex to process.
HTH,
Marc Schwartz
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.