Allow no colnames with PDF output when booktabs enabled
diff --git a/R/add_indent.R b/R/add_indent.R
index de6fc32..c0e1c1e 100644
--- a/R/add_indent.R
+++ b/R/add_indent.R
@@ -39,15 +39,23 @@
table_info <- dup_fx_out[[2]]
}
- if (max(positions) > table_info$nrow - 1) {
+ if (table_info$booktabs & is.null(table_info$colnames)) {
+ max_position <- table_info$nrow
+ position_offset <- 0
+ } else {
+ max_position <- table_info$nrow - 1
+ position_offset <- 1
+ }
+
+ if (max(positions) > max_position) {
stop("There aren't that many rows in the table. Check positions in ",
"add_indent_latex.")
}
- for (i in positions) {
- rowtext <- table_info$contents[i + 1]
+ for (i in positions + position_offset) {
+ rowtext <- table_info$contents[i]
out <- sub(rowtext, latex_indent_unit(rowtext), out, perl = TRUE)
- table_info$contents[i + 1] <- latex_indent_unit(rowtext)
+ table_info$contents[i] <- latex_indent_unit(rowtext)
}
out <- structure(out, format = "latex", class = "knitr_kable")
attr(out, "kable_meta") <- table_info