ltx_caption | R Documentation |
The ltx_caption
function processes LaTeX table code by modifying the header,
including the caption, label, and table notes. It removes unnecessary lines,
captures the table title, and optionally appends a label and table note,
while also printing the table if specified.
ltx_caption(x, tbl_note = "", print_tbl = FALSE)
x |
A character vector representing the LaTeX table code that needs to be processed. |
tbl_note |
A character string for an optional table note that will be added to the table header. |
print_tbl |
Logical. If |
This function refines LaTeX table code by removing unwanted \\usepackage
commands and blank lines, capturing and modifying the \\caption
and
\\label
, and optionally adding a custom table note. The function
identifies the LaTeX table title and reformats it into a custom format.
If a table label is present in the title, it is extracted and repositioned
before the table content. If a table note is provided, it is
appended after the caption.
The function returns the processed LaTeX table code as an invisible
character vector. If print_tbl
is set to TRUE
, it also prints the
modified table code to the console and copies it to the clipboard for easy
pasting into a latex editor.
ltx_print_tbl()
, ltx_capture_output()
## Not run:
# Example LaTeX table with caption, label, and table note
tbl_code <- c("\\usepackage{booktabs}",
"\\caption{Sample Table}",
"\\label{tab:example}",
"\\begin{tabular}{|c|c|}",
"\\hline",
"A & B \\\\",
"\\hline",
"1 & 2 \\\\",
"\\hline",
"\\end{tabular}")
# Process the table header with a table note and print the table
ltx_caption(tbl_code, tbl_note = "Table Note", print_tbl = TRUE)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.