Skip to content

Printing localized pdf file from Sweave snippets

3 messages · Duncan Murdoch, Petar Milin

#
Hello!
I am struggling for quite some time with proper printing of local
characters in pdf plot, via Sweave snippets in Rnw file.

When I am working directly within R, all is fine and I can get local
character properly, like:
pdf('figs/fig-relativeEntropy0.pdf', h=6, w=6, encoding='CP1250')
matplot(par[, c(3)], type='b', ylim=c(0,0.5), xaxt='n', pch=c(21),
	lty=c('dashed'), lwd=c(3), xlab='', ylab='')
	axis(1, at=1:6, labels=as.character(par$suffix), cex.axis=1.2)
	legend(2, 0.48, 'pu?ina (open-sea)', bty='n', cex=1.2)
dev.off()

However, in Rnw file, I made an preamble line:
\usepackage{Sweave}
\usepackage[cp1250]{inputenc}
pdf.options(encoding='CP1250')
within the Sweave snippet. No luck at all!

Please, is there a straightforward solution?!?

I read two links, but no sign of correct how-to:
http://stackoverflow.com/questions/3434349/sweave-not-printing-localized-characters
http://r.789695.n4.nabble.com/Problems-with-Sweave-and-pdf-options-encoding-quot-ISOLatin7-quot-PR-13234-td921653.html

Many thanks!
PM
#
On 14/09/2012 7:07 AM, Petar Milin wrote:
This isn't really an answer to your question, but it might be a 
workaround:  switch to the UTF-8 encoding.  It is the default on many 
systems (e.g. most Unix-alikes these days), so it is probably better 
supported internally.  You might need to convert your string to UTF8; 
you can do that by replacing

'pu?ina (open-sea)'


with

'pu\u010dina (open-sea)'

Duncan Murdoch
#
Hello!
Many thanks, but this is not working. I put:
\usepackage[utf8]{inputenc}
and than:
'pu\u010dina (open-sea)'
Blank space is printed in pdf file, after R CMD Sweave and pdflatex.

Please, any other idea?! I am losing my mind here...

Best,
PM

        
On Fri, 2012-09-14 at 08:17 -0400, Duncan Murdoch wrote: