[R] Printing localized pdf file from Sweave snippets

Petar Milin pmilin at ff.uns.ac.rs
Fri Sep 14 13:07:55 CEST 2012


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}

>From this, I am getting dots. Also, I tried to play with the:
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



More information about the R-help mailing list