[Rd] Sweave processes \Sexpr in commented LaTeX source (2.3.1patched and 2.4.0)

Marc Schwartz MSchwartz at mn.rr.com
Wed Sep 20 02:14:39 CEST 2006

Hi all,

On FC5, using:

  Version 2.3.1 Patched (2006-08-06 r38829)

and today's

  R version 2.4.0 alpha (2006-09-19 r39397)

with the following .Rnw file:


   This line should print '2': \Sexpr{1 + 1}
%% This line should NOT print '2': \Sexpr{1 + 1}


The \Sexpr in the second line is processed even though the line is
commented. This results in the following .tex file content (in the case
of R 2.4.0):


   This line should print '2': 2
%% This line should NOT print '2': 2


Shouldn't Sweave just generally ignore commented LaTeX code? In
reviewing Sweave.R I did not see a check for this, so perhaps there are
circumstances where one wants a \Sexpr in commented LaTeX code
processed. An example escapes me at the moment however.


Marc Schwartz

More information about the R-devel mailing list