[R] dev.copy(postscript,...) generates a disrupted string

(Ted Harding) Ted.Harding at manchester.ac.uk
Sat Oct 24 22:53:27 CEST 2009


On 24-Oct-09 20:28:04, Barry Rowlingson wrote:
> On Sat, Oct 24, 2009 at 9:09 PM, Marius Hofert <m_hofert at web.de> wrote:
>> Dear R-Users,
>>
>> I have the following problem: I would like to create a postscript
>> file containing an r-plot with the string "\\vartheta" in it
>> (reason: this is later converted to the TeX-string "\vartheta"
>> and a vartheta is printed in the figure). In the minimal example
>> below, the problem is that the created postscript file does _not_
>> contain the string "\\vartheta" as a whole, but rather the following
>> code:
>> ...
>> 284.38 36.00 (\\v) 0 ta
>> -0.300 (ar) tb
>> 0.480 (theta) tb gr
>> ...
>> The problem is, that the program which converts the created .ps file
>> to a
>> .tex file does not understand this disrupted string. Why does the
>> dev.copy(postscript,..)-command produce such an output and how can I
>> prevent
>> it from doing so? If I use a different string such as "\\v_i", then
>> everything works fine and "\\v_i" appears as a whole string in the
>> postscript file. So why does it not work for "\\vartheta"?
> 
>  Because postscript() doesn't know what you want to do with \vartheta,
> and thinks you want to typeset the text itself. So it very cleverly
> adjusts the spacing between the letters to look nice - this is called
> 'kerning'. This means the text has to be set by postscript in several
> parts.
> 
>  You can do greek characters in plots - see help(plotmath).
> 
> Barry

To follow up: The issue is indeed kerning, and the way to avoid
this happening is to use useKerning=FALSE in the call to postscript(),
or to dev.copy(postscript,...) or to dev.copy2eps().

See the fairly recent thread "ridiculous behaviour printing to eps:
labels all messed up!" starting at

  http://finzi.psych.upenn.edu/Rhelp08/2009-June/200664.html

where the problem is quite extensively discussed.

Hoping this helps,
Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
Fax-to-email: +44 (0)870 094 0861
Date: 24-Oct-09                                       Time: 21:53:23
------------------------------ XFMail ------------------------------




More information about the R-help mailing list