Escape single backslashes in front of dollar signs (for LaTeX)
escape_dollar(txt)
A character string
A character string with escaped backslashes in front of dollar sings.
If a dollar sign in a character string is preceded by a single backslash, escape that to make it a double-backslash. Ignore cases where the dollar sign is already preceded by multiple backslashes.
escape_dollar("$x^2$")
#> [1] "$x^2$"
escape_dollar("\\$1000.00")
#> [1] "\\\\$1000.00"
escape_dollar("$\\\\$1000.00")
#> [1] "$\\\\$1000.00"