as.includegraphics | R Documentation |
\includegraphics
expression for use with 'LaTeX' \includegraphics
macro in the
graphicx package. This is used for pdf
and png
files with the system pdflatex
command. This is used for
ps
files with the system latex
command.
Convert a filename into a complete 'LaTeX' \includegraphics
expression for use with 'LaTeX' \includegraphics
macro in the
graphicx package. This is used for pdf
and png
files with the system pdflatex
command. This is used for
ps
files with the system latex
command. The argument
wd
is included in the pathname in the generated expression.
The \includegraphics
macro is generated with the height
and optional width
specified by the
height.includegraphics
and width.includegraphics
arguments; the default NULL
means use the values in the
graphics (pdf
, png
, ps
) files. If either is
specified, the other should be left as NULL
to retain the
original aspect ratio.
## An optional raise
value is available for vertical alignment.
An optional trim
argument is available to remove excess margins
from the image. See the Details section for use of the trim
argument to trim panels in an externally produced graphics file.
as.includegraphics(object, ...) ## Default S3 method: as.includegraphics(object, height.includegraphics=NULL, ## LaTeX measurement (character) width.includegraphics=NULL, ## retains original aspect ratio, ## LaTeX measurement (character) scale=NULL, ## number raise=NULL, ## LaTeX measurement (character) tabularinclude=TRUE, hspace.left=NULL, ## LaTeX measurement (character) hspace.right=NULL, ## LaTeX measurement (character) wd=getwd(), ## working directory. No embedded spaces in directory name. viewport=NULL, ## if specified, then left bottom right top (character) ## used for pdf png jpeg ## See MediaBox in pdf file. ## Ask operating system for png or jpg file. bb=NULL, ## if specified, then left bottom right top (character) ## used for bmp tiff ps, ask operating system for values trim=NULL, ## for example, "0 0 0 0" left bottom right top (character) x.axis.includegraphics=TRUE, ## logical or a list of arguments ## to latex \includegraphics[here]{} y.axis.includegraphics=TRUE, ## logical or a list of arguments xlab.includegraphics=FALSE, ## logical or a list of arguments ylab.includegraphics=FALSE, ## logical or a list of arguments key.includegraphics=!is.null(attr(object, "key.name")), ## ## logical or a list of arguments as.attr=FALSE, ## logical label.x.axis="", ## empty, nchar=0 label.y.axis=" ", ## one space, nchar=1 columnKey=NULL, ## see ?microplotAttrDisplay ...) ## S3 method for class 'microplotMatrix' as.includegraphics(object, ...) ## principal usage. Calls default. ## S3 method for class 'includegraphicsMatrix' as.includegraphics(object, ...) ## returns object ## S3 method for class 'trellis' as.includegraphics(object, ...) ## generates an informative error message. ## S3 method for class 'ggplot' as.includegraphics(object, ...) ## generates an informative error message. ## S3 method for class 'graphicsList' as.includegraphics(object, ...) ## generates an informative error message.
object |
A |
scale |
Scale factor (number) applied to figure.
If either |
height.includegraphics, width.includegraphics |
Character vector containing a LaTeX distance (by default |
wd |
The directory in which the files reside. The default is the full path
to the current
working directory that R is using. The full path is necessary when
using the |
raise |
Character vector containing a LaTeX distance (by default |
tabularinclude |
Logical. When |
hspace.left, hspace.right |
Character vector containing a LaTeX distance (by default |
viewport |
Size in pixels of the image file. This is the MediaBox
in a |
bb |
Bounding Box: Size in pixels of the image file. It is the
number reported by the operating system for a |
trim |
Size in pixels to be trimmed. It must be a character string
containing four numbers in order: left, bottom, right, top. See the
manual for the LaTeX package graphicx for details. When
|
x.axis.includegraphics, y.axis.includegraphics |
logical, or list of arguments to nested calls to as.includegraphics. |
xlab.includegraphics, ylab.includegraphics,
key.includegraphics |
logical, or list of arguments to nested calls to as.includegraphics. |
as.attr |
Logical. When |
label.x.axis, label.y.axis |
Labels that will used by
|
columnKey |
If |
... |
Other arguments currently ignored. |
We recommend that the aspect ratio be controlled by the 'R' functions
that generated the figure. as.includegraphics
will use the
height and width values that are encoded in the pdf
,
png
, ps
files.
If you need to change the size of the image
we recommend that at most one of
height.includegraphics
and width.includegraphics
be used
in as.includegraphics
. Using both will change the aspect ratio
and consequently stretch the figure. The trim
argument is used
to remove excess margins from the figure; when trim
is
specified for height or width, the height.includegraphics
or
width.includegraphics
will also need to be specified
to retain the aspect ratio.
See demo("latex")
and demo("latex-ggplot")
for an example.
Either the viewport
(for pdf
or png
files) or
bb
(for ps
files) should be specified, not both.
The trim
argument can be used to take apart an externally
produced graphics file and use subsets of its area as components in a 'LaTeX' table.
See the files examples/irisSweaveTakeApart.Rtex
and
examples/irisSweaveTakeApart-Distributed.pdf
for an example.
A "includegraphicsMatrix"
object, a vector or matrix of 'LaTeX'
expressions with the 'LaTeX' macro
\includegraphics
for each of the input filenames. If the
input argument has axis.names
or lab.names
or
key.name
attributes, then the value will also have those
attributes, enclosed in \includegraphics
statements. The
arguments allow different \includegraphics
options for the
panels, the x.axis, the y.axis, xlab, ylab, and the key (legend).
The location of the
files listed in the input argument attributes depends on the value of
the as.attr
argument. When as.attr
is TRUE
the
object
attributes will become result
attributes. When
as.attr
is FALSE
, see the microplotAttrDisplay for
details.
Richard M. Heiberger <rmh@temple.edu>
latex.trellis
, microplot
, latex
as.includegraphics("abc.pdf") ## [1] "\setlength{\tabcolsep}{0pt}\begin{tabular}{c} ## \includegraphics{/Users/rmh/Rwd/abc.def}\end{tabular}" ## attr(,"class") ## [1] "includegraphicsMatrix" "character" ## This form, with the full pathname, is required when the Hmisc::print.latex ## and related functions are used for automatic display of ## the current .tex file on screen. as.includegraphics("abc.pdf", wd=".") ## [1] "\setlength{\tabcolsep}{0pt}\begin{tabular}{c} ## \includegraphics{./abc.pdf}\end{tabular}" ## attr(,"class") ## [1] "includegraphicsMatrix" "character" ## This form, with the relative path, is optional when the .tex file will be ## embedded into a larger file, and will not be automatically displayed on screen. ## Please see the package documentation ?microplot for a simple example in context. ## Please see the demos for more interesting examples. ## demo(package="microplot")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.