ltx_placement: Adjust LaTeX Table Placement

View source: R/ltx_placement.R

ltx_placementR Documentation

Adjust LaTeX Table Placement

Description

This function modifies the placement specifier of LaTeX tables within a provided text. It allows for verbose feedback during execution and the option to selectively replace specific table environments.

Usage

ltx_placement(
  x,
  tbl_placement = NULL,
  print_tbl = FALSE,
  verbose = TRUE,
  replace_idx = NULL
)

Arguments

x

A character vector containing LaTeX code that includes ⁠\begin{table}⁠ environments.

tbl_placement

A string specifying the desired table placement (e.g., !htbp). If NULL, defaults to !htbp.

print_tbl

A logical indicating whether to print the modified LaTeX table to the console. Default is FALSE.

verbose

A logical indicating whether to provide feedback during execution. Default is TRUE.

replace_idx

An integer specifying which occurrence of the ⁠\begin{table}⁠ environment to replace. If NULL, all occurrences will be replaced. Default is NULL.

Value

The modified LaTeX code as a character vector, invisibly.

Examples

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

# Replace all table placements with '!htbp'
ltx_placement(latex_code, tbl_placement = "!htbp")

# Replace only the first table placement with 'H'
ltx_placement(latex_code, tbl_placement = "H", replace_idx = 1)

## End(Not run)

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