add row_spec latex part
diff --git a/R/row_spec.R b/R/row_spec.R
index 81b0190..c19044c 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -68,12 +68,16 @@
target_row <- table_info$contents[row + 1]
new_row <- latex_row_cells(target_row)
if (bold) {
- new_row <- paste0("\\{bfseries", new_row, "}")
+ new_row <- lapply(new_row, function(x) {
+ paste0("\\\\bfseries{", x, "}")
+ })
}
if (italic) {
- new_row <- paste0("\\{em", new_row, "}")
+ new_row <- lapply(new_row, function(x) {
+ paste0("\\\\em{", x, "}")
+ })
}
- new_row <- paste(new_row, collapse = " & ")
+ new_row <- paste(unlist(new_row), collapse = " & ")
out <- sub(target_row, new_row, as.character(kable_input), perl = T)
out <- structure(out, format = "latex", class = "knitr_kable")
diff --git a/tests/visual_tests/column_width_pdf.Rmd b/tests/visual_tests/column_row_spec_pdf.Rmd
similarity index 89%
rename from tests/visual_tests/column_width_pdf.Rmd
rename to tests/visual_tests/column_row_spec_pdf.Rmd
index 374cc90..f71c696 100644
--- a/tests/visual_tests/column_width_pdf.Rmd
+++ b/tests/visual_tests/column_row_spec_pdf.Rmd
@@ -1,6 +1,8 @@
---
title: "Untitled"
-output: pdf_document
+output:
+ pdf_document:
+ keep_tex: true
---
```{r setup, include=FALSE}
@@ -40,7 +42,14 @@
kable(dt, "latex", booktabs = T) %>%
kable_styling(latex_options = "scale_down") %>%
column_spec(2, "30em", bold = T) %>%
- column_spec(4, "3cm", italic = T) %>%
- group_rows("Group1", 1, 2)
+ column_spec(4, "3cm", italic = T)
+```
+
+```{r}
+dt <- mtcars[1:5, 1:6]
+
+kable(dt, "latex", booktabs = T) %>%
+ column_spec(7, bold = T) %>%
+ row_spec(5, bold = T)
```