Hi,

Searching the archives has brought no clue:

For a tex chunk in an Sweave text

"Oracle query results: differences \Sexpr{varname},..."

I need to change the string varname from "X_1" to "X\_1",

sub("_",??,"X_+")  -> "X\_1"

so that subsequent Latex will generate "X_1" (i.e. show the underscore) 
instead of "X subscript 1" (subscripting the "1")

Various trials with sub("_","\\_",varname) and the like have not helped.

sub("_","\\_","X_1")             -> "X_1"
sub("_","\\_","X_1",fixed=TRUE)  -> "X\\_1"
sub("_","\_","X_1",fixed=TRUE)   -> "X_1"

Latex will translate  "X\\_1" to X  (linefeed) 1  !!

Thanks for help

Christian
-- 
Dr. Christian W. Hoffmann,
Swiss Federal Research Institute WSL
Zuercherstrasse 111, CH-8903 Birmensdorf, Switzerland
Tel +41-44-7392-277 (office), -111(exchange), -215  (fax)
[EMAIL PROTECTED],  www.wsl.ch/staff/christian.hoffmann

______________________________________________
[email protected] 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.

Reply via email to