Adding a no_of_indent argument which allows putting indents by every 2ems
diff --git a/R/add_indent.R b/R/add_indent.R
index 25448b5..adc4b18 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -9,7 +9,7 @@
#' add_indent(x, c(2, 4))
#'
#' @export
-add_indent <- function(kable_input, positions) {
+add_indent <- function(kable_input, positions, no_of_indent) {
if (!is.numeric(positions)) {
stop("Positions can only take numeric row numbers (excluding header rows).")
}
@@ -21,15 +21,15 @@
return(kable_input)
}
if (kable_format == "html") {
- return(add_indent_html(kable_input, positions))
+ return(add_indent_html(kable_input, positions, no_of_indent))
}
if (kable_format == "latex") {
- return(add_indent_latex(kable_input, positions))
+ return(add_indent_latex(kable_input, positions, no_of_indent))
}
}
# Add indentation for LaTeX
-add_indent_latex <- function(kable_input, positions) {
+add_indent_latex <- function(kable_input, positions, no_of_indent) {
table_info <- magic_mirror(kable_input)
out <- solve_enc(kable_input)
@@ -59,11 +59,11 @@
}
latex_indent_unit <- function(rowtext) {
- paste0("\\\\hspace\\{1em\\}", rowtext)
+ paste0("\\\\hspace\\{",no_of_indent*2,"em\\}", rowtext)
}
# Add indentation for HTML
-add_indent_html <- function(kable_input, positions) {
+add_indent_html <- function(kable_input, positions, no_of_indent) {
kable_attrs <- attributes(kable_input)
kable_xml <- read_kable_as_xml(kable_input)
@@ -79,7 +79,7 @@
node_to_edit <- xml_child(xml_children(kable_tbody)[[i]], 1)
if (!xml_has_attr(node_to_edit, "indentlevel")) {
xml_attr(node_to_edit, "style") <- paste(
- xml_attr(node_to_edit, "style"), "padding-left: 2em;"
+ xml_attr(node_to_edit, "style"), "padding-left: ",paste0(no_of_indent*2,"em;")
)
xml_attr(node_to_edit, "indentlevel") <- 1
} else {