# sanitizeTexString

0th

Percentile

##### Replace LaTeX Special Characters in a String

This function is used by tikzDevice when sanitize = TRUE to replace special LaTeX characters (such as the comment character where the user does not have direct control over the generated text.

Keywords
character
##### Usage
sanitizeTexString(string, strip = getOption("tikzSanitizeCharacters"),
replacement = getOption("tikzReplacementCharacters"))
##### Arguments
string

A character vector of length 1 (a string).

strip

A character vector of single characters to search for.

replacement

A character vector of replacement values.

##### Details

sanitizeTexString() searches character by character through a string replacing each occurrence of a special character contained in strip[i] with the corresponding replacement value in replacement[i]. tikzDevice calls back this function for every piece of text when the sanitize option is TRUE. See tikz() for more information on the default special characters and replacement values.

By default, tikzSanitizeCharacters replaces the following characters:

• %

• $ • } • { • ^ • _ • # • & • ~ With the contents of tikzReplacementCharacters: • \% • \$

• \}

• \{

• \^{}

• \_{}

• \#

• \&

• \char\~

These defaults may be adjusted using the options() function.

##### Value

sanitizedString

A character vector of length 1 with all special characters replaced.

tikz()

##### Aliases
• sanitizeTexString
##### Examples
# NOT RUN {
# Be careful with sanitizing, it may lead to unexpected behavior.
# For example, we may want -1 to be a superscript it gets
# sanitized away with the other default special characters.
# The string appears in LaTeX exactly as shown.
# }
# NOT RUN {
sanitizeTexString('10\% of 10$is 10^\{-1\}$')
# }
# NOT RUN {
# }
`
Documentation reproduced from package tikzDevice, version 0.12.3.1, License: GPL (>= 2)

### Community examples

Looks like there are no examples yet.