Julia Jacobson
2011-Feb-15 21:55 UTC
[R] Sweave doesn't hand on width of special characters of Computer Modern fonts to LaTeX
Hello R users, Using R, Sweave and the cmsyase.afm font it is possible to write LaTeX documents including R figures with text in the Computer Modern Fonts: \documentclass{article} \usepackage{Sweave} \begin{document} <<echo = false, results = hide>>CM <- Type1Font("CM", c(file.path("C:/texlive/2009/texmf-dist/fonts/afm/public/cm-lgc", c("fcmr8a.afm", "fcmb8a.afm", "fcmri8a.afm", "fcmbi8a.afm")), "./cmsyase.afm")) pdfFonts(CM = CM) postscriptFonts(CM = CM) pdf.options(family = "CM", pointsize = 11) ps.options(family = "CM", pointsize = 11) @ <<fig = true, echo = false, include = true>>x <- c(1,2,3) y <- c(1,2,1) plot(y~x, xlab = "1 - 3 units") # The "-" sign here is @ # missing in the PDF file! \end{document} First of all, Sweave doesn't seem to hand on the width of the "-" sign on to LaTex, like the warning is indicating. Moreover, the font of the text in the graphics looks different from the Computer Modern fonts LaTeX is using. Thanks in advance for your answers, Julia
Erik Iverson
2011-Feb-15 22:07 UTC
[R] Sweave doesn't hand on width of special characters of Computer Modern fonts to LaTeX
Julia, While not a direct answer to your question, you may find the pgfSweave driver/package to be interesting. http://cran.r-project.org/web/packages/pgfSweave/ Among other things, it uses the tikzDevice package for figures, which will cause the labels and text to use the same font as in your LaTeX document. --Erik Julia Jacobson wrote:> Hello R users, > > Using R, Sweave and the cmsyase.afm font it is possible to write LaTeX > documents including R figures with text in the Computer Modern Fonts: > > \documentclass{article} > \usepackage{Sweave} > \begin{document} > <<echo = false, results = hide>>> CM <- Type1Font("CM", > c(file.path("C:/texlive/2009/texmf-dist/fonts/afm/public/cm-lgc", > c("fcmr8a.afm", "fcmb8a.afm", "fcmri8a.afm", "fcmbi8a.afm")), > "./cmsyase.afm")) > pdfFonts(CM = CM) > postscriptFonts(CM = CM) > pdf.options(family = "CM", pointsize = 11) > ps.options(family = "CM", pointsize = 11) > @ > <<fig = true, echo = false, include = true>>> x <- c(1,2,3) > y <- c(1,2,1) > plot(y~x, xlab = "1 - 3 units") # The "-" sign here is > @ # missing in the PDF file! > \end{document} > > First of all, Sweave doesn't seem to hand on the width of the "-" sign > on to LaTex, like the warning is indicating. > Moreover, the font of the text in the graphics looks different from the > Computer Modern fonts LaTeX is using. > > Thanks in advance for your answers, > Julia > > ______________________________________________ > 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.
Duncan Murdoch
2011-Feb-15 22:19 UTC
[R] Sweave doesn't hand on width of special characters of Computer Modern fonts to LaTeX
On 15/02/2011 4:55 PM, Julia Jacobson wrote:> Hello R users, > > Using R, Sweave and the cmsyase.afm font it is possible to write LaTeX > documents including R figures with text in the Computer Modern Fonts:This is very unlikely to have anything to do with Sweave, it's a graphics system problem. You might want to read the article Paul Murrell and Brian Ripley (2006) Non-standard fonts in PostScript and PDF graphics. R News, 6(2):41?47. http://cran.r-project.org/doc/Rnews/Rnews_2006-2.pdf for information. It looks as though you did everything it recommends, except embedding the fonts: maybe you need to do that. Duncan Murdoch> > \documentclass{article} > \usepackage{Sweave} > \begin{document} > <<echo = false, results = hide>>> CM<- Type1Font("CM", > c(file.path("C:/texlive/2009/texmf-dist/fonts/afm/public/cm-lgc", > c("fcmr8a.afm", "fcmb8a.afm", "fcmri8a.afm", "fcmbi8a.afm")), > "./cmsyase.afm")) > pdfFonts(CM = CM) > postscriptFonts(CM = CM) > pdf.options(family = "CM", pointsize = 11) > ps.options(family = "CM", pointsize = 11) > @ > <<fig = true, echo = false, include = true>>> x<- c(1,2,3) > y<- c(1,2,1) > plot(y~x, xlab = "1 - 3 units") # The "-" sign here is > @ # missing in the PDF file! > \end{document} > > First of all, Sweave doesn't seem to hand on the width of the "-" sign > on to LaTex, like the warning is indicating. > Moreover, the font of the text in the graphics looks different from the > Computer Modern fonts LaTeX is using. > > Thanks in advance for your answers, > Julia > > ______________________________________________ > 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.