Copied from knitr for internal use because it is unexported and CRAN rejects :::

escape_latex(x, newlines = FALSE, spaces = FALSE)

Arguments

x

a character string to escape

newlines

boolean

spaces

boolean