toLatex: Cleaning R Code for printing in LaTeX environments

Description Usage Arguments Value Author(s) See Also Examples

Description

The function produces code that LaTeX is able to typeset.

Usage

1
2
3
4
5
6
7
8
9
## 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.pks = FALSE, citations = TRUE,
        citecommand = "\\citep", file = "Rpackages.bib",
        append = FALSE, ...)

Arguments

object

either an object of class character which should be cleaned for printing in LaTeX environments or an object of class sessionInfo.

pkgs

character vector (optional). Specify specific packages here to show information on these (instead of all attached packages). See package in sessionInfo.

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 pkgs is specified, information on these packages is given instead of all attached packages.

namespace.pks

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 \ needs to be escaped, i.e., one needs to write \\ instead.

file

Specify path to BibTeX file where citations should be saved. If file = NULL is specified, the BibTeX entries are attached to the output as attribute "BibTeX". See examples for details.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
txt <- "Price: <= 500$ & additional goodies"
toLatex(txt)

############################################################
## session info for automatic inclusion in reports

info <- toLatex(sessionInfo(), file = NULL)
info

## extract first part (the Latex part)
toLatex(info)
## extract second part (the BibTeX part)
toBibtex(info)


############################################################
## usual usage scenario

## Do not run 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.

getwd()     ## location where write access is needed
toLatex(sessionInfo(), file = "packages.bib")
file.remove("packages.bib")

papeR documentation built on May 2, 2019, 4:55 p.m.