This function makes a latex document including the plots defined
ltx_plot(
plot,
out,
title = "plot",
titlepr = NULL,
footnote = "",
plotnote = "",
lwidth = NULL,
pwidth = 10,
pheight = 5.5,
res = NULL,
hyper = TRUE,
outfmt = "pdf",
fontsize = 12,
units = "px",
rawout = paste0(out, ".rawtex"),
linebreak = TRUE,
label = NULL,
captpl = "top",
rotate = FALSE,
cleancur = FALSE,
titlesub = NULL,
shorttitle = NULL,
...
)plot object or function call that creates plot to be printed to file
filename for the output latex file
character string to define the title of the plot which will be added to the caption
character string to define the prefix of the title. Can be used to create custom numbering
character string with the footnote to be placed in the footer of the page (LaTeX coding can be used for example to create line breaks)
character string with the plot note to be placed directly below the plot (LaTeX coding can be used for example to create line breaks)
character string indicating the width of the plot within latex (e.g. "\\linewidth")
numeric indicating the width of the plot to be generated in inches or pixels (for respectively the extensions pdf and png)
numeric indicating the height of the plot to be generated in inches or pixels (for respectively the extensions pdf and png)
numeric indicating the resolution of the plot (in case png is used), if set to NULL it will adapt the value according height of the plot
logical indicating if a hypertarget should be set used for bookmarks
character string indicating the format of the output file (currently "pdf" and "png" are accepted)
character string with the default font or pointsize passed through to png or pdf function
character string with the units to use for plot width and height passed through to png function
character string with the name of the raw latex file to generate (e.g. only plot code with no preamble and document ending) In case NULL no raw output will be generated. In order to combine results the filename should end in .rawtex
logical indicating if a linebreak (clearpage) should be given after a plot
character with the label to add after the caption for referencing the table in text
character with the caption placement, can be either "top" or "bottom"
logical indicating if the resulting figure should be rotated 90 degrees clockwise
logical indicating if the available plots should be deleted before creating new ones
character string to define the subtext after title in footnotesize
character string to define the title in a shorter version of the plot which will be used in the TOF in a latex document
additional arguments passed through to ltx_doc(). Most important are template, rendlist, compile and show
The function returns a latex file (or writes output to console)
# It is convenient to have an object for the plot argument
if (FALSE) { # \dontrun{
data(Theoph)
library(ggplot2)
pl <- ggplot(Theoph,aes(Time,conc)) + geom_line() + facet_wrap(~Subject)
ltx_plot(pl,out=tempfile(fileext=".tex"))
# Base plots work a bit different and can be placed
# in the function directly or wrapped in a function
pl <- function() {
plot(conc~Time,data=Theoph)
title(main="a plot")
}
ltx_plot(pl(),out=tempfile(fileext=".tex"))
# In case of big data it can be more convenient to have a png included
ltx_plot(plot(rnorm(1e6)),out=tempfile(fileext=".tex"),
outfmt="png",pwidth=2000,pheight=1200)
} # }