diff --git a/R/add_indent.R b/R/add_indent.R
index bddc5e4..8a90c49 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -3,20 +3,15 @@
 #' @param kable_input Output of `knitr::kable()` with `format` specified
 #' @param positions A vector of numeric row numbers for the rows that need to
 #' be indented.
-#' @param level_of_indent a numeric value for the indent level
+#' @param level_of_indent a numeric value for the indent level. Default is 1.
 #'
 #' @examples x <- knitr::kable(head(mtcars), "html")
 #' # Add indentations to the 2nd & 4th row
 #' add_indent(x, c(2, 4), level_of_indent = 1)
 #'
 #' @export
-add_indent <- function(kable_input, positions, level_of_indent) {
-
-  if(missing(level_of_indent)){
-    level_of_indent = 1
-    }else{
-    level_of_indent = level_of_indent
-    }
+add_indent <- function(kable_input, positions,
+                       level_of_indent = 1, all_cols = FALSE) {
 
   if (!is.numeric(positions)) {
     stop("Positions can only take numeric row numbers (excluding header rows).")
@@ -29,25 +24,20 @@
     return(kable_input)
   }
   if (kable_format == "html") {
-    return(add_indent_html(kable_input, positions, level_of_indent))
+    return(add_indent_html(kable_input, positions, level_of_indent, all_cols))
   }
   if (kable_format == "latex") {
-    return(add_indent_latex(kable_input, positions, level_of_indent))
+    return(add_indent_latex(kable_input, positions, level_of_indent, all_cols))
   }
 }
 
 # Add indentation for LaTeX
-add_indent_latex <- function(kable_input, positions, level_of_indent) {
+add_indent_latex <- function(kable_input, positions,
+                             level_of_indent = 1, all_cols = FALSE) {
   table_info <- magic_mirror(kable_input)
   out <- solve_enc(kable_input)
   level_of_indent<-as.numeric(level_of_indent)
 
-  if(missing(level_of_indent)){
-    level_of_indent = 1
-  }else{
-    level_of_indent = level_of_indent
-  }
-
   if (table_info$duplicated_rows) {
     dup_fx_out <- fix_duplicated_rows_latex(out, table_info)
     out <- dup_fx_out[[1]]
@@ -63,10 +53,19 @@
 
   for (i in positions + table_info$position_offset) {
     rowtext <- table_info$contents[i]
+    if (all_cols) {
+      new_rowtext <- latex_row_cells(rowtext)
+      new_rowtext <- lapply(new_rowtext, function(x) {
+        paste0("\\\\hspace\\{", level_of_indent ,"em\\}", x)
+      })
+      new_rowtext <- paste(unlist(new_rowtext), collapse = " & ")
+    } else {
+      new_rowtext <- latex_indent_unit(rowtext, level_of_indent)
+    }
     out <- sub(paste0(rowtext, "\\\\\\\\"),
-               paste0(latex_indent_unit(rowtext), "\\\\\\\\"),
+               paste0(new_rowtext, "\\\\\\\\"),
                out, perl = TRUE)
-    table_info$contents[i] <- latex_indent_unit(rowtext)
+    table_info$contents[i] <- new_rowtext
   }
   out <- structure(out, format = "latex", class = "knitr_kable")
   attr(out, "kable_meta") <- table_info
@@ -75,24 +74,18 @@
 
 }
 
-latex_indent_unit <- function(rowtext) {
-  paste0("\\\\hspace\\{",level_of_indent,"em\\}", rowtext)
+latex_indent_unit <- function(rowtext, level_of_indent) {
+  paste0("\\\\hspace\\{", level_of_indent ,"em\\}", rowtext)
 }
 
 
 
 # Add indentation for HTML
-add_indent_html <- function(kable_input, positions, level_of_indent) {
-
-  if(missing(level_of_indent)){
-    level_of_indent = 1
-  }else{
-    level_of_indent = level_of_indent
-  }
-
+add_indent_html <- function(kable_input, positions,
+                            level_of_indent = 1, all_cols = FALSE) {
   kable_attrs <- attributes(kable_input)
 
-  kable_xml <- read_kable_as_xml(kable_input)
+  kable_xml <- kable_as_xml(kable_input)
   kable_tbody <- xml_tpart(kable_xml, "tbody")
 
   group_header_rows <- attr(kable_input, "group_header_rows")
@@ -102,20 +95,30 @@
   }
 
   for (i in positions) {
-    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: ",paste0(level_of_indent*2,"em;")
-      )
-      xml_attr(node_to_edit, "indentlevel") <- 1
+    row_to_edit = xml_children(kable_tbody)[[i]]
+    if (all_cols) {
+      target_cols = 1:xml2::xml_length(row_to_edit)
     } else {
-      indentLevel <- as.numeric(xml_attr(node_to_edit, "indentlevel"))
-      xml_attr(node_to_edit, "style") <- sub(
-        paste0("padding-left: ", indentLevel * 2, "em;"),
-        paste0("padding-left: ", (indentLevel + 1) * 2, "em;"),
-        xml_attr(node_to_edit, "style")
-      )
-      xml_attr(node_to_edit, "indentlevel") <- indentLevel + 1
+      target_cols = 1
+    }
+
+    for (j in target_cols) {
+      print(j)
+      node_to_edit <- xml_child(row_to_edit, j)
+      if (!xml_has_attr(node_to_edit, "indentlevel")) {
+        xml_attr(node_to_edit, "style") <- paste(
+          xml_attr(node_to_edit, "style"), "padding-left: ",paste0(level_of_indent*2,"em;")
+        )
+        xml_attr(node_to_edit, "indentlevel") <- 1
+      } else {
+        indentLevel <- as.numeric(xml_attr(node_to_edit, "indentlevel"))
+        xml_attr(node_to_edit, "style") <- sub(
+          paste0("padding-left: ", indentLevel * 2, "em;"),
+          paste0("padding-left: ", (indentLevel + 1) * 2, "em;"),
+          xml_attr(node_to_edit, "style")
+        )
+        xml_attr(node_to_edit, "indentlevel") <- indentLevel + 1
+      }
     }
   }
   out <- as_kable_xml(kable_xml)
