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
--
View this message in context:
http://www.nabble.com/Computer-Modern-tp24303553p24303553.html
Sent from the R help mailing list archive at Nabble.com.
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 YouI 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 ------------------------------
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. >Hi There- I admit this is shameless self promotion but might I suggest the tikzDevice package. I am one of the developers and we just pushed up a beta version to r-forge that is quite usable. It enables graphic output in pgf/tikz format that can be directly imported into LaTeX. The fonts in your graphic will implicitly match that of your document. It also works well with Sweave, you can see examples in the vignette. Binary builds may not be available until tomorrow but you can install from source svn checkout svn://svn.r-forge.r-project.org/svnroot/tikzdevice R CMD INSTALL tikzdevice/pkg then: vignette('tikzDevice') -- View this message in context: http://www.nabble.com/Computer-Modern-tp24303553p24653180.html Sent from the R help mailing list archive at Nabble.com.