diff --git a/R/ama_export_tab.R b/R/ama_export_tab.R index 5895bda..18b46da 100644 --- a/R/ama_export_tab.R +++ b/R/ama_export_tab.R @@ -8,6 +8,7 @@ #' @param filename A character string specifying the filename without the extension. #' @param filepath A character string specifying the directory to save the file. #' @param caption A character string specifying the caption for the table. +#' @param size Latex size including "tiny", or "small" #' @import xtable #' @import rio #' @importFrom utils capture.output @@ -18,7 +19,7 @@ #' data(mtcars) # Load the mtcars dataset #' ama_export_tab(mtcars[1:5, 1:5], "sample_table", tempdir(), "Sample Caption for mtcars") #' } -ama_export_tab <- function(table, filename, filepath, caption = NULL) { +ama_export_tab <- function(table, filename, filepath, caption = NULL, size = "small") { # Get current date date <- format(Sys.Date(), "%Y-%m-%d") @@ -49,7 +50,16 @@ ama_export_tab <- function(table, filename, filepath, caption = NULL) { rio::export(table, file.path(filepath , paste0(filename, ".xlsx"))) # Export LaTeX table without current date to current folder as LaTeX file - writeLines(capture.output(print(xtable_obj, type = "latex", caption.placement = "top", include.rownames=FALSE, sanitize.text.function=sanitize_custom)), file.path(filepath, paste0(filename, ".tex"))) + writeLines(capture.output( + print( + xtable_obj, + type = "latex", + caption.placement = "top", + include.rownames = FALSE, + size = size, + sanitize.text.function = sanitize_custom + ) + ), file.path(filepath, paste0(filename, ".tex"))) # Export LaTeX table with current date to "archive" folder as LaTeX file writeLines(capture.output(print(xtable_obj, type = "latex", caption.placement = "top",include.rownames=FALSE, sanitize.text.function=sanitize_custom)), file.path(filepath, "archive", paste0(filename, "_", date, ".tex"))) diff --git a/causalverse_0.0.0.9000.pdf b/causalverse_0.0.0.9000.pdf index 4f5af3b..46ad349 100644 Binary files a/causalverse_0.0.0.9000.pdf and b/causalverse_0.0.0.9000.pdf differ diff --git a/man/ama_export_tab.Rd b/man/ama_export_tab.Rd index 1ed8123..7b80805 100644 --- a/man/ama_export_tab.Rd +++ b/man/ama_export_tab.Rd @@ -4,7 +4,7 @@ \alias{ama_export_tab} \title{Function to export a table with AMA style} \usage{ -ama_export_tab(table, filename, filepath, caption = NULL) +ama_export_tab(table, filename, filepath, caption = NULL, size = "small") } \arguments{ \item{table}{A data frame or matrix.} @@ -14,6 +14,8 @@ ama_export_tab(table, filename, filepath, caption = NULL) \item{filepath}{A character string specifying the directory to save the file.} \item{caption}{A character string specifying the caption for the table.} + +\item{size}{Latex size including "tiny", or "small"} } \description{ This function exports the provided table in both Excel (\code{.xlsx}) and LaTeX (\code{.tex}) formats.