ltx_resize | R Documentation |
This function wraps LaTeX tabular-like environments
(e.g., tabular
, tabularx
, longtable
) with a \resizebox
command to
resize them to fit the \linewidth
. The function excludes resizing for
table
environments to prevent undesired behavior. This is useful for
ensuring tables are properly scaled within the document margins in LaTeX.
ltx_resize(x, print_tbl = FALSE, verbose = TRUE)
x |
A character vector representing the LaTeX code that contains tabular environments. |
print_tbl |
A logical flag indicating whether the modified table should
be printed to the console and copied to the clipboard. Defaults to |
verbose |
A logical flag to indicate whether messages should be printed
to the console. Defaults to |
The function works by identifying lines containing \begin{tabular}
,
\begin{tabularx}
, or other supported tabular environments
(excluding table
), and wraps these environments with a
\resizebox{\\linewidth}{!}{...}
command. It ensures that the
\end{tabular}
line is closed properly.
The modified LaTeX code with the resizebox
applied around tabular
environments, returned as a character vector. If print_tbl
is TRUE
,
the modified table is printed to the console.
## Not run:
# Example LaTeX table code
x <- c("\\begin{tabular}{ll}", "A & B \\\\", "\\end{tabular}")
ltx_resize(x)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.