toLatex {papeR} | R Documentation |
Cleaning R Code for printing in LaTeX environments
Description
The function produces code that LaTeX is able to typeset.
Usage
## S3 method for class 'character'
toLatex(object, ...)
## S3 method for class 'sessionInfo'
toLatex(object, pkgs = NULL, locale = FALSE,
base.pkgs = FALSE, other.pkgs = TRUE,
namespace.pkgs = FALSE, citations = TRUE,
citecommand = "\\citep", file = NULL,
append = FALSE, ...)
Arguments
object |
either an object of class character which should be cleaned for printing in
LaTeX environments or an object of class |
pkgs |
character vector (optional). Specify specific packages here to show
information on these (instead of all attached packages). See
|
locale |
logical (default = FALSE). Show information on locale. |
base.pkgs |
logical (default = FALSE). Show information on base packages. |
other.pkgs |
logical (default = TRUE). Show information on currently attached
packages. If |
namespace.pkgs |
logical (default = FALSE). Show information on packages whose namespaces are currently loaded but not attached. |
citations |
logical (default = TRUE). Should citations for all packages be added? BibTeX is used for storing the citations. |
citecommand |
Specify LaTeX-command for citation here. Curly brackets are added
internally. Note that |
file |
Specify path to BibTeX file where citations should be saved. If
|
append |
logical (default = FALSE). Should citations be added to an existing BibTeX file (if existing) or should old BibTeX files be overwritten? |
... |
additional arguments. Currently not used. |
Value
A character string with special markup is returned: The output is
printed with LaTeX style syntax highlighting to be used
e.g. in Sweave chunks with results=tex
.
Author(s)
Benjamin Hofner, based on code from package xtable, bibtex and package utils. See source code for documentation.
See Also
toLatex
. For details on toLatex.sessionInfo
see
also sessionInfo
.
Examples
txt <- "Price: <= 500$ & additional goodies"
toLatex(txt)
############################################################
## session info for automatic inclusion in reports
info <- toLatex(sessionInfo())
info
## extract first part (the Latex part)
toLatex(info)
## extract second part (the BibTeX part)
toBibtex(info)
############################################################
## usual usage scenario
## Do not run the following code automatically as it needs
## write access to the current working directory.
## This code (without removing the file) could for example
## be included in a LaTeX chunk of your Sweave or knitr
## report.
## Not run: getwd() ## location where write access is needed
toLatex(sessionInfo(), file = "packages.bib")
file.remove("packages.bib")
## End(Not run)