Adding group_rows HTML part; Finished group_rows
diff --git a/R/add_indent.R b/R/add_indent.R
index 18fdcd1..62c0a4e 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -1,6 +1,9 @@
 #' Add indentations to row headers
 #' @export
 add_indent <- function(kable_input, positions) {
+  if (!is.numeric(positions)) {
+    stop("Positions can only take numeric row numbers (excluding header rows).")
+  }
   kable_format <- attr(kable_input, "format")
   if (!kable_format %in% c("html", "latex")) {
     message("Currently generic markdown table using pandoc is not supported.")
@@ -16,14 +19,8 @@
 
 # Add indentation for LaTeX
 add_indent_latex <- function(kable_input, positions) {
-  table_info <- attr(kable_input, "original_kable_meta")
-  if (is.null(table_info)) {
-    table_info <- magic_mirror(kable_input)
-  }
+  table_info <- magic_mirror(kable_input)
 
-  if (!is.numeric(positions)) {
-    stop("Positions can only take numeric row numbers (excluding header rows).")
-  }
   if (max(positions) > table_info$nrow - 1) {
     stop("There aren't that many rows in the table. Check positions in ",
          "add_indent_latex.")
diff --git a/R/group_rows.R b/R/group_rows.R
index 9827811..3a179b0 100644
--- a/R/group_rows.R
+++ b/R/group_rows.R
@@ -1,25 +1,30 @@
 #' Put a few rows of a table into one category
 #'
 #' @export
-group_rows <- function(kable_input, group_label, start_row, end_row) {
+group_rows <- function(kable_input, group_label, start_row, end_row,
+                       label_row_css = "border-bottom: 1px solid;",
+                       latex_gap_space = "0.5em") {
+  if (!is.numeric(c(start_row, end_row))) {
+    stop("Start_row and end_row must be numeric position of rows (excluding",
+         "header rows and other group-title rows). ")
+  }
   kable_format <- attr(kable_input, "format")
   if (!kable_format %in% c("html", "latex")) {
     message("Currently generic markdown table using pandoc is not supported.")
     return(kable_input)
   }
   if (kable_format == "html") {
-    return(group_rows_html(kable_input, group_label, start_row, end_row))
+    return(group_rows_html(kable_input, group_label, start_row, end_row,
+                           label_row_css))
   }
   if (kable_format == "latex") {
-    return(group_rows_latex(kable_input, group_label, start_row, end_row))
+    return(group_rows_latex(kable_input, group_label, start_row, end_row,
+                            latex_gap_space))
   }
 }
 
-group_rows_html <- function(kable_input, group_label, start_row, end_row) {
-  if (!is.numeric(c(start_row, end_row))) {
-    stop("Start_row and end_row must be numeric position of rows (excluding",
-         "header rows and other group-title rows). ")
-  }
+group_rows_html <- function(kable_input, group_label, start_row, end_row,
+                            label_row_css) {
   kable_attrs <- attributes(kable_input)
   kable_xml <- read_xml(as.character(kable_input), options = "COMPACT")
   kable_tbody <- xml_tpart(kable_xml, "tbody")
@@ -35,8 +40,9 @@
   starting_node <- xml_child(kable_tbody, group_seq[1])
   kable_ncol <- length(xml_children(starting_node))
   group_header_row_text <- paste0(
-    '<tr groupLength="', length(group_seq), '"><td colspan="',
-    kable_ncol, '"><strong>', group_label, "</strong></td></tr>"
+    '<tr groupLength="', length(group_seq), '"><td colspan="', kable_ncol,
+    '" style="', label_row_css, '"><strong>', group_label,
+    "</strong></td></tr>"
   )
   group_header_row <- read_xml(group_header_row_text, options = "COMPACT")
   xml_add_sibling(starting_node, group_header_row, .where = "before")
@@ -49,3 +55,35 @@
   out <- add_indent(out, positions = seq(start_row, end_row))
   return(out)
 }
+
+group_rows_latex <- function(kable_input, group_label, start_row, end_row, gap_space) {
+  table_info <- magic_mirror(kable_input)
+  out <- kable_input
+
+  # Add group label
+  rowtext <- table_info$contents[start_row + 1]
+  if (table_info$booktabs) {
+    new_rowtext <- paste0(
+      "\\\\addlinespace[", gap_space, "]\n",
+      "\\\\multicolumn{", table_info$ncol, "}{l}{\\\\textbf{", group_label,
+      "}}\\\\\\\\\n",
+      rowtext
+    )
+    # last_row <- paste0(table_info$contents[end_row + 1], "\\\\\\\\")
+    # out <- sub(
+    #   last_row,
+    #   paste0(last_row, "\n\\\\addlinespace[", gap_space, "]"),
+    #   out
+    # )
+  } else {
+    rowtext <- paste0("\\\\hline\n", rowtext)
+    new_rowtext <- paste0(
+      "\\\\hline\n\\\\multicolumn{", table_info$ncol, "}{l}{\\\\textbf{",
+      group_label, "}}\\\\\\\\\n", rowtext
+    )
+  }
+  out <- sub(rowtext, new_rowtext, out)
+  if (table_info$booktabs)
+  out <- add_indent(out, seq(start_row, end_row))
+  return(out)
+}
diff --git a/tests/visual_tests/add_indent_and_group_rows_html.Rmd b/tests/visual_tests/add_indent_and_group_rows_html.Rmd
index 77be4ce..609e09a 100644
--- a/tests/visual_tests/add_indent_and_group_rows_html.Rmd
+++ b/tests/visual_tests/add_indent_and_group_rows_html.Rmd
@@ -21,9 +21,8 @@
 
 ```{r}
 kable(dt, format = "html") %>%
-  kable_styling("striped") %>%
-  group_rows("Group 1", 2, 4) %>%
-  group_rows("Group 2", 6, 7)  %>%
-  group_rows("Group 3", 9, 10)
+  kable_styling("striped", full_width = F) %>%
+  group_rows("Group 1", 4, 7) %>%
+  group_rows("Group 2", 8, 10)
 ```
 
diff --git a/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd b/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd
new file mode 100644
index 0000000..82e09d2
--- /dev/null
+++ b/tests/visual_tests/add_indent_and_group_rows_pdf.Rmd
@@ -0,0 +1,28 @@
+---
+title: "indents & row_group"
+output: pdf_document
+---
+
+# Introduction
+Nam non libero ut felis euismod efficitur. Maecenas ligula nisi, rutrum eu turpis quis, semper ultricies nibh. Quisque vehicula cursus erat. Donec aliquam augue ut magna vehicula lacinia. Quisque efficitur, arcu condimentum mollis scelerisque, tellus libero accumsan elit, in eleifend lorem lectus ut erat. Ut sit amet nulla quis turpis semper mattis. Ut rhoncus vitae nulla sit amet ultrices. Nulla justo ligula, rhoncus et interdum vel, cursus ut sem. Nullam elementum ullamcorper neque, imperdiet tempus sapien tincidunt et. Nulla diam nulla, varius ut nisi quis, hendrerit fringilla mi. In volutpat tincidunt faucibus. Donec luctus, mauris vitae consectetur placerat, elit velit tristique mauris, sed malesuada nisl sem eu justo. Nunc enim quam, pharetra vitae velit vel, posuere lacinia turpis. Proin volutpat porttitor ligula.
+
+```{r}
+library(knitr)
+library(kableExtra)
+dt <- mtcars[1:10, 1:8]
+```
+
+```{r}
+kable(dt[1:5,], format = "latex", booktabs = T) %>%
+  kable_styling() %>%
+  add_indent(c(3, 5)) %>%
+  add_indent(5)
+```
+
+```{r}
+kable(dt, format = "latex", booktabs = T) %>%
+  kable_styling() %>%
+  group_rows("Group 1", 4, 7) %>%
+  group_rows("Group 2", 8, 10)
+```
+