wrapLaTable: Wrapper for a floating LaTeX Table

View source: R/tables.R

wrapLaTableR Documentation

Wrapper for a floating LaTeX Table

Description

wrapLaTable() wraps (a table and tabular environment) around the lines of the body of a LaTeX table and utilizes writeLines() to write the LaTeX table.

Usage

wrapLaTable(x, align, do.table = TRUE, placement = "htbp", center = TRUE,
            fontsize = "normalsize", booktabs = TRUE,
            caption = NULL, label = NULL)

Arguments

x

a character vector containing the lines of the body of the table (for “booktabs” tables, everything strictly between \midrule and \bottomrule). A table header can be passed via attributes of x.

align

table columns alignment string (e.g., "lcccS[table-format=1.2]", the notation of "S[...]" coming from the LaTeX package siunitx).

do.table

logical indicating whether a LaTeX ‘table’ environment should be used at all.

placement

(if do.table:) character string containing a LaTeX table placement string such as "htbp".

center

logical indicating whether centering should happen.

fontsize

character string giving a fontsize (such as "tiny", "scriptsize", "footnotesize", "small", "normalsize", "large", "Large", "LARGE", "huge", or "Huge").

booktabs

logical indicating whether a LaTeX table in the format of the LaTeX booktabs package is created.

caption

(if do.table:) character string containing the table caption or NULL for no caption.

label

(if do.table:) character string containing the table label or NULL for no label.

Details

Note that necessary LaTeX packages (such as tabularx) have to be loaded in the preambel of the corresponding .tex or .Rnw file.

Value

a “LaTeX table”, of class "Latex" (where the print method uses writeLines()).

Author(s)

Marius Hofert.

References

see simsalapar-package.

See Also

toLatex() where it is used to create a LaTeX table.

Examples

ftab <- ftable(Titanic, row.vars = 1:2)
fftab <- fftable(ftab)
tlist <- tablines(fftab)

wrapLaTable(structure(tlist$body, head = tlist$head), align = tlist$align,
            caption="The Titanic data set.", label="tab:titanic")

simsalapar documentation built on April 27, 2023, 9:05 a.m.