[R] Sweave and accents

Duncan Murdoch murdoch at stats.uwo.ca
Tue Jun 9 18:58:39 CEST 2009


On 6/9/2009 12:07 PM, Arnau Mir Torres wrote:
> Hello.
> 
> I want to write my notes in Sweave in my own language (spanish). But  
> my language has accents and when I run Sweave in R to translate my Snw  
> file into the tex file the accents are translated into unrecognizable  
> characters.
> For example, the word "camión" (truck) is translated into "camión"
> 
> Somebody knows how can I do it?

That looks as though you are using Latin1 encoding, and Sweave is giving 
you UTF-8.  (If not those two, then a similar sort of problem.)

The handling of encodings is tricky, because it depends on your system 
settings (what sort of locale you are running in).  The l10n_info() and 
  sessionInfo() functions may be helpful in diagnosing the problem.

Duncan Murdoch

> 
> One solution I don't like is using a perl program to substitute my  
> accented letters into "normal" accents in LaTeX in my Snw file before  
> running Sweave.  That is:
> 
> á -> \'a
> é -> \'e
> ...
> 
> The problem is when I run the spelling program, it doesn't work  
> because the spelling doesn't recognize the words with "normal" accents.
> 
> There is a solution but it is tedious:
> 
> 1)  substitute the accented letters letter into "normal" accents in  
> LaTeX.
> 2) run Sweave and create the tex file.
> 3) subtitute the "normal" accents into the accented letters in the tex  
> file.
> 
> 
> My question is:
> Is there another way to do it?
> 
> 
> Arnau.
> 
> ------------------------------------------------------------
> Arnau Mir Torres
> Edifici A. Turmeda
> Campus UIB
> Ctra. Valldemossa, km. 7,5
> 07122 Palma de Mca.
> tel: (+34) 971172987
> fax: (+34) 971173003
> email: arnau.mir at uib.es
> URL: http://dmi.uib.es/~arnau
> ------------------------------------------------------------
> 
> 
> 
> 
> 
> 
> 
> 
> ______________________________________________
> R-help at 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.




More information about the R-help mailing list