Skip to contents

Functions related to table options.

Usage

find_posOption(table)

posOption(table)

posOption(table, asis = FALSE) <- value

find_widthOption(table)

widthOption(table)

widthOption(table, asis = FALSE) <- value

find_columnOptions(table)

columnOptions(table)

columnOptions(table, asis = FALSE) <- value

Arguments

table

A known tabular-like environment object, or the contents of one.

asis

Whether to make small modifications in replacement functions.

value

A character string or LaTeX2 object.

Value

find_posOption() returns the indices of the entries corresponding to the "pos" option, including the brackets, within the table.

posOption() returns a LaTeX2 object containing the "pos" option.

find_widthOption() returns the index of the block corresponding to the "width" option, if there is one. Only some tabular-like environments have these.

widthOption() returns a LaTeX2 object containing the "width" option, if the table has one.

find_columnOptions() returns the index of the block corresponding to the column spec.

columnOptions() returns a LaTeX2 object containing the "column" options.

Details

Unless asis == TRUE, the value for value in posOption(table) <- value can be specified with or without the enclosing brackets.

Examples

latex <- kableExtra::kbl(mtcars[1:2, 1:2], format = "latex")
parsed <- parseLatex(latex)
table <- parsed[[find_tabular(parsed)]]
table
#> ENVIRONMENT: \begin{tabular}[t]{l|r|r}
#> \hline
#>   & mpg & cyl\\
#> \hline
#> Mazda RX4 & 21 & 6\\
#> \hline
#> Mazda RX4 Wag & 21 & 6\\
#> \hline
#> \end{tabular}
find_posOption(table)
#> [1] 1 2 3

posOption(table)
#> [t] 

posOption(table) <- "h"
posOption(table)
#> [h] 
find_widthOption(table)
#> NULL

widthOption(table)
#> NULL

find_columnOptions(table)
#> [1] 4
columnOptions(table)
#> {l|r|r} 

columnOptions(table) <- "lrr"
table
#> ENVIRONMENT: \begin{tabular}[h]{lrr}
#> \hline
#>   & mpg & cyl\\
#> \hline
#> Mazda RX4 & 21 & 6\\
#> \hline
#> Mazda RX4 Wag & 21 & 6\\
#> \hline
#> \end{tabular}