On 11/4/2008 6:16 AM, Christian Reisinger wrote:
Dear list,

I using R as the statistical package for my dissertation in political sciences and I am using Sweave for documenting the work done for the creation of my dataset. However, I have a problem with Sweave (which is great, by the way) which is (hopefully) easy to solve:

I want Sweave to "echo" my code, so that the R source code of the code chunks appears in the Latex document. However, since I am using several $ signs per line, as in the example line below, Latex interprets this as a math environment, despite the fact that the $ signs are within the {Sinput} environment. The problem now is that I sometimes have an unequal number of $ signs in an input line, so that LaTex thinks that all of the following "normal" text is still part of the math environment, and formats it accordingly.

This is an example input line:

Pre_Year <- MyMain3$Con_Stat[MyMain3$MyID==ID_Count[i] & MyMain3$MyYear==Count_Years[y-1]]

where I have three $ sings, and LaTex thinks that everything following the last $ sign is still part of a formula.

Sinput is a verbatim environment, so LaTeX should not try to interpret that line, if it's in an Sweave block. Are you using the correct Sweave.sty file to define it?

A real reproducible example (i.e. a complete input file that fails) would be a lot easier to diagnose.

Duncan Murdoch


I have two question now:
1. Is there any way to solve the problem within Sweave itself, e.g. through setting options? 2. If not: is there a way to generally turn off the math mode in LaTex in the preamble, since I generally don't need it? (Maybe I should better post this in the LaTex mailing list, but maybe some people here had similar problems)

Thanks for all comments!
Best,
Christian

PS: I tried to replace all $ signs by \$, but this did not work either and caused many LaTex errors.


______________________________________________
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.

Reply via email to