ltx_fontsize: Set Font Size for LaTeX Table

View source: R/ltx_fontsize.R

ltx_fontsizeR Documentation

Set Font Size for LaTeX Table

Description

This function modifies the LaTeX code for a table to set the font size and line spacing. It appends the necessary LaTeX command to the table's LaTeX code.

Usage

ltx_fontsize(x, font_size = 8, skip = NULL, print_tbl = FALSE, verbose = TRUE)

Arguments

x

A character vector representing LaTeX code for a table, typically captured via ltx_capture_output().

font_size

Numeric value indicating the desired font size (default is 8).

skip

Numeric value for the line spacing (skip), typically set to 1.2 times the font size. If NULL, it defaults to 1.2 * font_size.

print_tbl

Logical, whether to print the modified LaTeX table to the console (default is FALSE).

verbose

Logical, whether to display informative messages via the cli package (default is TRUE).

Details

The function appends a LaTeX ⁠\\fontsize{}⁠ and ⁠\\selectfont⁠ command directly after the ⁠\\begin{table}⁠ tag in the input LaTeX code. If the skip parameter is NULL, the function sets the skip value to 1.2 times the font_size.

The function validates that font_size and skip are positive values and that a ⁠\\begin{table}⁠ tag is present. If verbose is enabled, informative messages are displayed to guide the user.

Value

Returns the modified LaTeX code as a character vector (invisible).

See Also

ltx_capture_output

Examples

## Not run: 
# Sample LaTeX table code
table_code <-
c("\\begin{table}",
"\\centering",
"\\begin{tabular}{cc}",
"A & B \\\\",
"1 & 2 \\\\",
"\\end{tabular}",
"\\end{table}")

# Modify font size to 10
modified_code <- ltx_fontsize(table_code, font_size = 10, skip = 12, print_tbl = TRUE)

## End(Not run)

AndreSjuve/texaid documentation built on Oct. 20, 2024, 6:17 a.m.