Learn R Programming

lazyWeave (version 3.0.0)

lazy.figure: Include Figures in Latex Documents

Description

Include Figures in Latex Documents

Usage

lazy.figure(filename, caption = NULL, align = "center", height = 3,
  width = 3, units = "in", counter, counterSet = NULL, label = NULL,
  placement = "h", alt = "Image Not Found",
  cat = getOption("lazyWeave_cat"))

Arguments

filename
Character string giving the location of the file to be included
caption
Text giving the caption for the figure
align
Character string stating the alignment. Valid options are "left", "right", or "center"
height
The height of the figure
width
The width of the figure
units
The units for height and width. Defaults to "in".
counter
Name of a counter to use to number the table
counterSet
The number to which counter should be set. In other words, the figure number for this figure
label
Name of a label
placement
Controls the placement of the figure. Options are "ht", "t", "b", "p", "H" and can be supplemented with "!". See "Details" for more explanation
alt
For HTML documents only--when filename cannot be found, this text is printed in the figure's place
cat
Logical. Determines if the output is returned as a character string or returned via the cat function (printed to console). The default value is set by options()$lazyWeave_cat. This argument allows for selective override o

Details

Generates the code to place a figure in a Latex document

Examples

Run this code
pdf("MPG.pdf", height=4, width=4)
hist(mtcars$mpg)
dev.off()

lazy.figure("MPG.pdf")

lazy.write(
lazy.file.start(),
lazy.figure("MPG.pdf",
caption="Distribution of Miles per Gallon in mtcars dataset",
height=5, width=5, label="MPGgraph"),
lazy.file.end(),
OutFile="Example-1.tex")

unlink("MPG.pdf")
unlink("Example-1.tex")
unlink("Example-1.pdf")

Run the code above in your browser using DataLab