<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: PostScript/PDF Preview Device with Optional 'LaTeX' Touch</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="https://rpkg.net/assets/examples.css" />
</head><body>

<table width="100%" summary="page for ps.latex"><tr><td>ps.latex</td><td style="text-align: right;">R Documentation</td></tr></table>

<h2>PostScript/PDF Preview Device with Optional &lsquo;LaTeX&rsquo; Touch</h2>

<h3>Description</h3>

<p>All functions start a pseudo PostScript or Acrobat preview device, using
<code>postscript</code> or <code>pdf</code>, and further registering
the file name for subsequent calls to <code>pdf.end()</code> or
<code>ps.end()</code>.
</p>


<h3>Usage</h3>

<pre>
pdf.do(file, paper = "default", width = -1, height = -1, onefile = FALSE,
       title = NULL, version = "1.4", quiet = FALSE, ...)

pdf.latex(file, height = 5 + main.space * 1.25,  width = 9.5,
          main.space=FALSE, lab.space = main.space,
          paper = "special", title = NULL,
          lab=c(10, 10, 7), mgp.lab=c(1.6, 0.7, 0), mar=c(4, 4, 0.9, 1.1), ...)

ps.do(file, width=-1, height=-1, onefile=FALSE, horizontal=FALSE,
      title = NULL, ...)

ps.latex(file, height = 5 + main.space * 1.25,  width = 9.5,
         main.space=FALSE, lab.space = main.space,
         paper = "special", title = NULL,
         lab=c(10, 10, 7), mgp.lab=c(1.6, 0.7, 0), mar=c(4, 4, 0.9, 1.1), ...)
</pre>


<h3>Arguments</h3>

<table summary="R argblock">
<tr valign="top"><td><code>file</code></td>
<td>
<p>character giving the PostScript/PDF file name to be written.</p>
</td></tr>
<tr valign="top"><td><code>height</code></td>
<td>
<p>device height in <em>inches</em>, <code>height * 2.54</code> are
<em>cm</em>.  The default is 5 plus 1.25 iff <code>main.space</code>.</p>
</td></tr>
<tr valign="top"><td><code>width</code></td>
<td>
<p>device width in <em>inches</em>; for this and
<code>height</code>, see <code>postscript</code>.</p>
</td></tr>
<tr valign="top"><td><code>onefile, horizontal</code></td>
<td>
<p>logicals passed to
<code>postscript(..)</code> or <code>pdf(..)</code>, most probably
to be left alone.</p>
</td></tr>
<tr valign="top"><td><code>title</code></td>
<td>
<p>PostScript/PDF (not plot!) title passed to
<code>postscript()</code> or <code>pdf()</code>; by default use a
title with <span style="font-family: Courier New, Courier; color: #666666;"><b>R</b></span> version and <code>file</code> in it.</p>
</td></tr>
<tr valign="top"><td><code>version</code></td>
<td>
<p>a string describing the PDF version that will be
required to view the output, see <code>pdf</code>; our (high)
default ensures alpha-transparency.</p>
</td></tr>
<tr valign="top"><td><code>quiet</code></td>
<td>
<p>logical specifying that some (informative/warning)
messages should not be issued.</p>
</td></tr>
<tr valign="top"><td><code>main.space</code></td>
<td>
<p>logical; if true, leave space for a main title
(unusual for LaTeX figures!).</p>
</td></tr>
<tr valign="top"><td><code>lab.space</code></td>
<td>
<p>logical; if true, leave space for x- and y- labels
(by <em>not</em> subtracting from <code>mar</code>).</p>
</td></tr>
<tr valign="top"><td><code>paper</code></td>
<td>
<p>character (or missing), typically <code>"a4"</code> or
<code>"a4r"</code> in non-America, see <code>postscript</code>.  Only
if this is <code>"special"</code> (or missing) are your choices of <code>width</code>
and <code>height</code> completely honored (and this may lead to files that
cannot print on A4) with resizing.</p>
</td></tr>
<tr valign="top"><td><code>lab</code></td>
<td>
<p>integer of length 3, <code>lab[1:2]</code> are desired number of
tick marks on x- and y- axis, see <code>par(lab=)</code>.</p>
</td></tr>
<tr valign="top"><td><code>mgp.lab</code></td>
<td>
<p>three decreasing numbers determining space for axis
labeling, see <code>par(mgp=)</code>, the default is here smaller
than usual.</p>
</td></tr>
<tr valign="top"><td><code>mar</code></td>
<td>
<p>four numbers, indicating marginal space, see
<code>par(mar=)</code>, the default is here smaller than usual.</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>arguments passed to <code>ps.do()</code> or
<code>pdf.do()</code> from
<code>ps.latex</code> / <code>pdf.latex</code> and to <code>ps.options</code>
from <code>ps.do</code>/<code>pdf.do</code>.</p>
</td></tr>
</table>


<h3>Details</h3>

<p><code>ps.latex</code> and <code>pdf.latex</code> have an additional
LaTeX 
flavor,
and just differ by some extra <code>par</code> settings from the
<code>*.do</code> siblings: E.g., after <code>ps.do(..)</code>
is called, the graphical parameters <code>c("mar", "mgp", "lab")</code> are
reset (to values that typically are better than the defaults for LaTeX
figures).
</p>
<p>Whereas the defaults for <code>paper</code>, <code>width</code>, and <code>height</code>
<em>differ</em> between <code>pdf</code> and  <code>postscript</code>,
they are set such as to provide very similar functionality, for
the functions <code>ps.do()</code> and <code>pdf.do()</code>; e.g., by default,
both use a full plot on portrait-oriented page of the default paper,
as per <code>getOption("papersize")</code>.<br />
<code>pdf.do()</code> sets the default <code>paper</code> to <code>"special"</code>
when both <code>width</code> and <code>height</code> are specified.
</p>


<h3>Value</h3>

<p>A list with components
</p>
<table summary="R valueblock">
<tr valign="top"><td><code>old.par</code></td>
<td>
<p>containing the old <code>par</code> values</p>
</td></tr>
<tr valign="top"><td><code>new.par</code></td>
<td>
<p>containing the newly set <code>par</code> values</p>
</td></tr>
</table>


<h3>Author(s)</h3>

<p>Martin Maechler</p>


<h3>See Also</h3>

<p><code>ps.end</code>, <code>pdf</code>, <code>postscript</code>,
<code>dev.print</code>.
</p>


<h3>Examples</h3>

<pre>
if(interactive()) {

 ps.latex("ps.latex-ex.ps", main= TRUE)
  data(sunspots)
  plot(sunspots,main=paste("Sunspots Data, n=",length(sunspots)),col="red")
 ps.end()

 pdf.latex("pdf.latex-ex.pdf", main= TRUE)
  data(sunspots)
  plot(sunspots,main=paste("Sunspots Data, n=",length(sunspots)),col="red")
 pdf.end()

 ps.do("ps_do_ex.ps")
   example(plot.function)
 ps.end()

 pdf.do("pdf_do_ex.pdf", width=12, height=5)
   plot(sunspots, main="Monthly Sunspot numbers (in Zurich, then Tokyo)")
 pdf.end()
}
</pre>


</body></html>
