[R] Sweavelistingutil: Encoding problems
Peter Ruckdeschel
peter.ruckdeschel at web.de
Fri Sep 4 11:42:28 CEST 2009
Hello Rasmus,
> I am not sure whether this is a bug or lack of R experience.
It is not your lack of R experience, and whether it is a bug
I am not sure ;-)
> However, I am using your Sweavelistingutil package, which is very
> nice.
Thank you.
> Obviously I use it to create LaTeX files. These are encoded in
> utf8.
>
> However, when I use the Sweavelistingutil is uses some funky
> character for "`" and "'" that is not recognized.
This is an issue I already have run into, too, more specifically,
when a (Linux-based) colleage sent me something I wanted to proceed
working on under Windows.
The easy solution is to use
options(fancyQuotes=FALSE)
in your R-code which avoids these "too-fancy" quotes.
Otherwise it is a TeX-package listings issue.
I have just looked into the documentation
listings.pdf (see vignette to SweaveListingUtils
for the exact reference).
On p.13/14 the authors propose to set
extendedchars=false
"[...] to avoid having listings get entangled in the other package’s
extended-character treatment."
I have hence just included this parameter as default in
the devel version of SweaveListingUtils (on r-forge, btw).
For the moment, you could use
<<SweaveListingsPreparations, results=tex, echo=FALSE>>=
require(SweaveListingUtils)
SweaveListingoptions(intermediate = FALSE)
SweaveListingoptions(Rset = c(getSweaveListingOption("Rset"),
"extendedchars" = "false"))
SweaveListingPreparations(ae = FALSE)
@
in your .Rnw (or .Rtex) file.
[BTW: the R-command
setToBeDefinedPkgs(pkgs = c("SweaveListingUtils","distr"),
keywordstyles = c("\\bf\\color{blue}","\\bf\\color{red}"))
is /not/ needed in general --- it is just for the purpose of
the vignette, ie. for producing the package-individual
coloring of keywords for /our/ packages
distr, SweaveListingUtils (and in general, you will not be
using distr, will you?)
OTOH you might want to use some similar command to give special
markup to keywords of your documented packages.
(In our devel-version there already is a corresponding comment...)
]
HTH, Peter
> Here is an example from my tex-file:
>
> ,----
> | Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> `----
>
> When comping this I get the following error:
>
> ,----
> | ERROR: Package inputenc Error: Unicode char
> | \u8:\lst at FillFixed@\lst at EC not set up
> `----
>
> There is /no problem/ when I the normal sweave-package.
>
> The relevant part of my preamble looks like this:
>
> ,----
> | \documentclass[a4paper]{scrartcl}
> | \usepackage{scrpage2}
> | \usepackage[english,danish]{babel}
> | \usepackage[T1]{fontenc}
> | \usepackage[utf8]{inputenc}
> `----
>
> And the "R-settings" looks like this (basically copied from the viginette):
>
> ,----
> | %\usepackage[noae]{Sweave}
> | \SweaveOpts{keep.source=TRUE}
> | % -------------------------------------------------------------------------------
> | <<SweaveListingsPreparations, results=tex, echo=FALSE>>=
> | require(SweaveListingUtils)
> | SweaveListingoptions(intermediate = FALSE)
> | SweaveListingPreparations(ae = FALSE)
> | setToBeDefinedPkgs(pkgs = c("SweaveListingUtils","distr"),
> | keywordstyles = c("\\bf\\color{blue}","\\bf\\color{red}"))
> | @Hello,
>
> I am not sure whether this is a bug or lack of R experience.
>
> However, I am using your Sweavelistingsutil package, which is very
> nice. Obviously I use it to create LaTeX files. These are encoded in
> utf8.
>
> However, when I use the Sweavelistingsutil is uses some funky
> character for "`" and "'" that is not recongnized.
>
> Here is an example from my tex-file:
>
> ,----
> | Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> `----
>
> When comping this I get the following error:
>
> ,----
> | ERROR: Package inputenc Error: Unicode char
> | \u8:\lst at FillFixed@\lst at EC not set up
> `----
>
> There is /no problem/ when I the normal sweave-package.
>
> The relevant part of my preamble looks like this:
>
> ,----
> | \documentclass[a4paper]{scrartcl}
> | \usepackage{scrpage2}
> | \usepackage[english,danish]{babel}
> | \usepackage[T1]{fontenc}
> | \usepackage[utf8]{inputenc}
> `----
>
> And the "R-settings" looks like this (basically copied from the viginette):
>
> ,----
> | %\usepackage[noae]{Sweave}
> | \SweaveOpts{keep.source=TRUE}
> | % -------------------------------------------------------------------------------
> | <<SweaveListingsPreparations, results=tex, echo=FALSE>>=
> | require(SweaveListingUtils)
> | SweaveListingoptions(intermediate = FALSE)
> | SweaveListingPreparations(ae = FALSE)
> | setToBeDefinedPkgs(pkgs = c("SweaveListingUtils","distr"),
> | keywordstyles = c("\\bf\\color{blue}","\\bf\\color{red}"))
> | @
> | % -------------------------------------------------------------------------------
> | \lstdefinestyle{TeXstyle}{fancyvrb=true,escapechar=`,language=[LaTeX]TeX,%
> | basicstyle={\color{black}\small},%
> | keywordstyle={\bf\color{black}},%
> |
> commentstyle={\color{Rcommentcolor}\ttfamily\itshape},%
> | literate={<-}{<-}2{<<-}{<<-}2}
> `----
>
> I use TexLive 2008, R 2.9.1 and I have updated all packages. I use
> Arch Linux, 32 bit.
>
> Thanks,
> Rasmus
>
More information about the R-help
mailing list