[R] Computer Modern

(Ted Harding) Ted.Harding at manchester.ac.uk
Thu Jul 2 12:59:33 CEST 2009


On 02-Jul-09 09:06:44, Mr Derik wrote:
> I am trying to use computer modern fonts in postscript files
> for a latex document. Ultimately I want to automate this through
> sweave. I've read the documentation ans have tried the following
> code to use lattice to produce a graph using computer modern:
> 
> library(lattice)
> library(grid)
> testPlot=(
> xyplot(seq(1:10) ~ seq(1:10),
>                     main="one to ten",
>                     xlab="the quick fox",
>                     ylab="jumped over the lazy brown dog",
>                     xlim=c(0,1),
>                     ylim=c(0,1),
>                     col="black",
>                     type="l" ,
>                     lwd=2
>                     )
>                     )
> setwd("C:\\R_folder\\CMtests")
> postscript("cm_test.eps", width = 4.0, height = 3.0,
>            horizontal = FALSE, onefile = FALSE, paper = "special",
>            family = "ComputerModern", encoding = "TeXtext.enc")
>        print(testPlot)
> dev.off() 
> 
> This produces a plot with courier.
> 
> I am using R 2.9.0 on a windows XP machine. I did manage to produce
> one plot with CM as the font so I know it's possible with my set up.
> I can't get back to that. Please help me with the code.
> Thank You

I think you may need to also use the "fonts" pAramater to postscript().
See in '?postscript':

  fonts: a character vector specifying additional R graphics font
        family names for font families whose declarations will be
        included in the PostScript file and are available for use
        with the device. See 'Families' below.  Defaults to 'NULL'.

Since the Computer Modern family is most probably not built in
to your printer, the PostScript file will need to include font
definitions for these fonts. If I understand aright, this is what
would be achieved by appropriate use of the "fonts" parameter.

If the font definitions are not included, the calls for them will
not be recognised by the printer which may then substitute a default
(likely to be Courier).

See also the section "TeX fonts" in '?postscript'.

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 02-Jul-09                                       Time: 11:59:29
------------------------------ XFMail ------------------------------




More information about the R-help mailing list