Skip to content
E. F. Haghish edited this page Aug 28, 2016 · 19 revisions

Description

Similar to the txt and img commands, the tbl command is also borrowed from the Weaver package and was updated to support MarkDoc package. Therefore, you have to make sure the Weaver log is closed. To do so, type weave query to check the status of the Weaver log. The tbl command works similar to the

Features

  • tbl simplifies writing and styling dynamic tables
  • It can also align the content of each column to the left, center, or right
  • It creates a table somehow similar to the way a matrix is defined in Stata

Syntax

The tbl command creates a dynamic table in the specified markup language. The default markup language is Markdown. The syntax of the command is:

tbl (*[,*...] [\ *[,*...] [\ [...]]]) [, markup(str) title(str) width(int) height(int) center left ] 

where the * represents a display directive which is:

    "double-quoted string"
    `"compound double-quoted string"'
    [%fmt] [=]exp
    , 
    {l}
    {c}
    {r}
Options

The tbl command takes fairly simple options. When HTML or LaTeX markup languages are used for writing the documentation, the markup(str) option must be specified. Otherwise, the command will append Markdown syntax to the log.

As noted, Markdown is a very minimalistic markup language with limited styling possibilities. Therefore, there should be no surprise that the width(int), height(int), and center options are only available when writing in HTML or LaTeX.

Optopns Discription
markup(str) specifies the markup language that is used for documentation
title(str) displays the table description
width(int) specifies the width of the table in HTML and LaTeX
height(int) specifies the height of the table in HTML and LaTeX
center aligns the table to the center of the document in HTML and LaTeX
left aligns the table to the left of the document
Display directives
Display Directive Discription
"double-quoted string" displays the string without the quotes
`"compound double-quoted string"' display the string without the outer quotes; allows embedded quotes
[%fmt] [=] exp allows results to be formatted
, separates the directives of each column of the table
{l} creates a left-aligned column
{c} creates a center-aligned column
{r} creates a right-aligned column

Examples

creating a simple 2x3 table with string and numbers

. tbl ("Column 1", "Column 2", "Column 3" \ 10, 100, 1000 )
Column 1 Column 2 Column 3
10 100 1000

creating a table that includes scalars and aligns the columns to left, center, and right respectively

. tbl ({l}"Left", {c}"Centered", {r}"Right" \ c(os),  c(machine_type), c(username))
Left Centered Right
MacOSX Macintosh (Intel 64-bit) haghish

Remarks

Note that the tbl command parses the rows using the backslash symbol. Therefore, to include LaTeX notations in a dynamic table that begin with a backslash such as \beta or 95\%, double backslash should be used to avoid conflict with the parsing syntax (e.g. \\beta and 95\\% ). Here are a couple of examples:

. tbl ("$\\beta$", "$95\\%$ Confidence Interval" \ "values...", "values...")

. tbl ("$\\beta$", "$\\epsilon$" \ "$\\sum$", "$\\prod$")