ltx_stretch | R Documentation |
This function modifies a LaTeX table to adjust the row stretch
(i.e., vertical space between rows) by appending the array stretch command
(\ra{}
) after the beginning of a tabular
or tabularx
environment.
The \ra{}
command is custom defined in my Overleaf as
\newcommand{\ra}[1]{\renewcommand{\arraystretch}{#1}}
.
ltx_stretch(x, array_stretch = 1.2, verbose = TRUE, print_tbl = FALSE)
x |
A character vector representing a LaTeX table or an object that can
be captured as LaTeX output using the |
array_stretch |
Numeric. The row stretch factor to apply.
Must be a positive number. Default is |
verbose |
Logical. If |
print_tbl |
Logical. If |
The function searches for \begin{table}
in the LaTeX table and
appends the array stretch command \ra{}
right after. If no such environment
is found, an error is thrown. The function does not modify the
\begin{table}
environment.
Returns the modified LaTeX table as a character vector with the array stretch applied. Invisibly returns the modified table.
## Not run:
# Example LaTeX table
latex_table <- c("\\begin{table}",
"\\begin{tabular}{ccc}",
"\\hline", "1 & 2 & 3 \\\\",
"\\hline",
"\\end{tabular}",
"\\end{table}")
# Apply array stretch of 1.5
modified_table <- ltx_stretch(latex_table, array_stretch = 1.5, verbose = TRUE)
# Print the modified table
ltx_stretch(latex_table, array_stretch = 1.5, print_tbl = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.