escape_latex: Escape LaTeX special characters

Description Usage Arguments Details Value Examples

Description

Escape special LaTeX special characters in text.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
escape_latex(x, ...)

## S3 method for class 'character'
escape_latex(x, url = TRUE, ...)

## Default S3 method:
escape_latex(x, ...)

## S3 method for class 'tex'
escape_latex(x, ...)

Arguments

x

Character vector

...

Other arguments passed to methods

url

If TRUE, escape URLs by enclosing them in \url macros The \url command is from the hyperref package.

Details

The following characters are escaped as follows:

Orginal Escaped
{ \{
} \}
# \#
$ \$
& \&
_ \_
% \%
\ \textbackslash{}
~ \textasciitilde{}
^ \textasciicircum{}
... \dots
| \textbar
https://cran.r-project.org \url{https://cran.r-project.org}

Value

A character vector with all LaTeX special characters escaped.

Examples

1
2
3
4
escape_latex(paste(c("These characters will be escaped",
                     "{ } # $ & _ % \\ ~ ^ ... | "),
                    collapse = ""))
escape_latex("By default so are URLs like https://cran.r-project.org")

jrnold/textools documentation built on May 20, 2019, 2:06 a.m.