Fix #158
diff --git a/R/row_spec.R b/R/row_spec.R
index 0d3d74a..e4f6df1 100644
--- a/R/row_spec.R
+++ b/R/row_spec.R
@@ -194,9 +194,7 @@
underline, strikeout,
color, background, align, font_size, angle,
hline_after, extra_latex_after)
- out <- str_replace(out,
- paste0(target_row, "\\\\\\\\"),
- new_row)
+ out <- sub(paste0(target_row, "\\\\\\\\"), new_row, out, perl = T)
}
out <- structure(out, format = "latex", class = "knitr_kable")
diff --git a/docs/best_practice_for_newline_in_latex_table.Rmd b/docs/best_practice_for_newline_in_latex_table.Rmd
index f798484..6910d91 100644
--- a/docs/best_practice_for_newline_in_latex_table.Rmd
+++ b/docs/best_practice_for_newline_in_latex_table.Rmd
@@ -28,7 +28,7 @@
```
## Insert linebreak in table
-In LaTeX, to make linebreaks in table cells, people usually use the `makecell` package. `kableExtra` 0.8.0 comes with a function called `linebreak` to facilitate that. Basically, this function will scan the existance of `\n`. If `\n` exists, it will put the texts in a `makecell` statement in a proper format. It works in a very similar way with `cell_spec`.
+In LaTeX, to make linebreaks in table cells, people usually use the `makecell` package. `kableExtra` 0.8.0 comes with a function called `linebreak` to facilitate that. Basically, this function will scan the existance of `\n`. If `\n` exists, it will put the texts in a `makecell` statement. It works in a very similar way with `cell_spec` so you will need to put `escape = F` in `kable`.
```{r}
linebreak("a\nb")
@@ -48,7 +48,7 @@
```
### Linebreak in other kableExtra functions
-If you have a need to put a linebreak in `kableExtra` functions such as `add_header_above` and `group_rows`, just go ahead and use `\n` and it will be automatically converted. Note that this feature is controlled by the `escape` option in those functions.
+If you have a need to put a linebreak in `kableExtra` functions such as `add_header_above` and `group_rows`, just go ahead and use `\n` directly (in kableExtra >= 0.8.0) and it will be automatically converted. Note that this feature is also controlled by the `escape` option in those functions.
```{r}
dt2 %>%