lazy.table {lazyWeave}R Documentation

Tables in LaTeX

Description

Generate code for custom LaTeX tables

Usage

lazy.table(x, align = "center", cspan = 1, cwidth = NULL,
  cwidth.units = "in", cborder = NULL, cborder.thick = 1,
  cborder.style = "solid black", rborder = NULL, rbspan = NULL,
  rborder.thick = 1, rborder.style = "solid black", rcol = NULL,
  usecol = "lightgray", font, family, size, justify = "center",
  placement = "h", open = TRUE, close = TRUE, caption = NULL,
  footnote = NULL, label = NULL, counter = NULL, counterSet = NULL,
  translate = TRUE, cat = getOption("lazyWeave_cat"))

Arguments

x

Matrix to be put into the table. Other objects are coerced to matrices. Vectors are coerced to a row vector

align

Character vector or string giving the alignment for each column. Options are "left", "center", "right".

cspan

A vector specifying how many columns of the table each column of x should span. This is used when using successive calls to latex.table to build tables with complex headers

cwidth

specify the width of each column

cwidth.units

Units of measure for the column width. For example, "in", "cm", or "mm"

cborder

A vector denoting vertical border positions. Borders are placed to the right of the given columns. See "Details".

cborder.thick

For HTML, column border thickness denoted in pixels

cborder.style

A valid HTML descriptor for the color of the column border

rborder

A vector denoting horizontal border positions. Borders are placed at the bottom of the given rows. See "Details".

rbspan

A vector or list giving the start and stop positions of the horizontal borders. Use a list when borders should go from columns 1 - 3 and 5 - 7, but not at column 4.

rborder.thick

For HTML, row border thickness denoted in pixels

rborder.style

A valid HTML descriptor for the color of the row border

rcol

A vector denoting which rows should be colored

usecol

A character vector or string giving the color to be used for the rows in rcol. The color must be a recognized LaTeX color

font

HTML font for the paragraph. Defaults to the HTML option (see setHtmlOptions).

family

HTML font family for the paragraph. Defaults to the HTML option (see setHtmlOptions).

size

Text size of the paragraph. Defaults to the HTML option (see setHtmlOptions). May be an integer or a LaTeX size descriptor. See "Details" for options

justify

Character string giving the alignment for the table on the page. Options are "left", "center", "right".

placement

Controls the placement of the figure. Options are "ht", "t", "b", "p", "H" and can be supplemented with "!". See "Details" for more explanation

open

Logical. Indicates if a new table environment should be opened

close

Logical. Indicates if the current table environment should be closed.

caption

Caption for the table. Currently, captions are placed above tables.

footnote

Additional footnotes to be placed below tables

label

The label to be used by lazy.ref

counter

The name of the counter to be used for this table

counterSet

The value to which counter should be set. In other words, the number of this table

translate

Toggles if inputs in x should be passed through latexTranslate. This should be set to FALSE if writing custom code

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 of the default.

Details

cborder (or column border) will create vertical borders in the table. Borders are placed on the right side of the specified columns. If a border is needed on the far left side of the table, use 0.

rborder (or row border) acts similarly, but for rows. Borders are placed under the specified rows. Use 0 if a line is needed at the top of a table.

Multiple calls to latex.table may be used to make complex tables. For instance, a header may be desired with group names that span over three summary values (See example 2). In these instances, it is the responsibility of the user to make sure the number of columns in each call is the same as in the other calls. There is no way in lazyWeave to check the column consistency of tables.

placement options are used as follows:

ht Place the float here, i.e., approximately at the same point it occurs
t Position at the top of the page
b Position at the bottom of the page
p Put on a special page for floats only
H Places the float at precisely the location in the LaTeX code. Requires the float package

The "!" may be used after any of these in order to override LaTeX float rules and force your selection. More can be learned by reading about floats in a LaTeX manual.

Author(s)

Benjamin Nutter

Examples

## Not run: 
#*** Example 1: Simple Table
tab.text <- lazy.table(mtcars[, c(1, 2, 4, 6)], align="right", 
                       cborder=c(0, 4), rborder=c(0, nrow(mtcars)))

lazy.write(
  lazy.file.start(),
  tab.text,
  lazy.file.end(),
  OutFile="Example 1.tex")
  
unlink("Example 1.tex")

#*** Example 2: Complex Table
person <- c("Rachel", "John", "Elizabeth", "George", "Ryan")
veg <- c("", "x", "x", "", "x")
meat <- c("x", "", "", "x", "")
soup <- c("x", "", "x", "x", "")
salad <- c("", "x", "", "", "x")
ice <- c("", "x", "x", "x", "")
cake <- c("x", "", "", "", "x")

dinner <- cbind(person, veg, meat, soup, salad, ice, cake)
colnames(dinner) <- c("Name", "Vegetarian", "Meat", 
                      "Soup", "Salad", "Ice Cream", "Cake")

tab1 <- lazy.table(c("", "Entree", "Side", "Dessert"), 
                   cspan=c(1, 2, 2, 2),
                   rborder=c(0, 0, 1), rbspan=2:7, 
                   caption="Dinner Orders", close=FALSE)
tab2 <- lazy.table(colnames(dinner), 
                   align=c("left", rep("center", 6)),
                   cborder=c(3, 5),
                   open=FALSE, close=FALSE)
tab3 <- lazy.table(dinner, 
                   align=c("left", rep("center", 6)),
                   cborder=c(1, 3, 5),
                   rborder=c(0, nrow(dinner)), open=FALSE)

lazy.write(
  lazy.file.start(),
  tab1, tab2, tab3,
  lazy.file.end(),
  OutFile="Example 2.tex")
  
unlink("Example 2.tex")

## End(Not run)


[Package lazyWeave version 3.0.2 Index]