R/Centering.R

Defines functions Centering

Documented in Centering

#' Centering Caption of LaTeX Table
#'
#' This function adds the "\\centering" command to the caption of a LaTeX table,
#' allowing the caption to be centered in the final output.
#'
#' @param x LaTeX-formatted table with a caption.
#'
#' @return LaTeX-formatted table with a centered caption.
#'
#' @export
#'
#' @examples
#' latex_table <- "\\begin{table}\\caption{This is a caption.}\\end{table}"
#' centered_table <- Centering(latex_table)
#' print(centered_table)

Centering <- function(x) {
  gsub(
    "\\caption{",
    "\\caption{\\centering ",
    x,
    fixed = TRUE,
    ignore.case = FALSE
  )
}

Try the RTLknitr package in your browser

Any scripts or data that you put into this service are public.

RTLknitr documentation built on Aug. 25, 2023, 9:06 a.m.