# sanitize_latex: Escape Characters for Printing in LaTeX Output In pixiedust: Tables so Beautifully Fine-Tuned You Will Believe It's Magic

## Description

sanitize_latex translates particular items in character strings to LaTeX format, e.g., makes a^2 = a\$^2\$ for superscript within variable labels. LaTeX names of greek letters (e.g., "alpha") will have backslashes added if greek==TRUE. Math mode is inserted as needed. sanitize_latex assumes that input text always has matches, e.g. [) [] (] (), and that surrounding by \$\$ is OK.

## Usage

 1 2 3 4 5 6 7 8 9 sanitize_latex( object, inn = NULL, out = NULL, pb = FALSE, greek = FALSE, na = "", ... ) 

## Arguments

 object character vector of strings to translate. Any NAs are set to blank strings before conversion. inn character vector. Additional strings to translate. out character vector the same length as inn. This gives the translated value of the corresonding element in inn pb logical(1) If pb=TRUE, sanitize_latex also translates [()] to math mode using \left, \right. greek logical(1). set to TRUE to have sanitize_latex put names for greek letters in math mode and add backslashes. na character(1) Single character string to translate NA values to. ... Additional arguments for other methods. Currently ignored.

## Value

Vector of chracter strings.

## Author(s)

This code is lifted from the Hmisc package in order to avoid depending on that package.

Frank E. Harrell Jr.
Department of Biostatistics,
Vanderbilt University,
f.harrell@vanderbilt.edu

Richard M. Heiberger,
Department of Statistics,
rmh@temple.edu

David R. Whiting,
School of Clinical Medical Sciences (Diabetes),
University of Newcastle upon Tyne, UK.
david.whiting@ncl.ac.uk

Hmisc::latexTranslate, Hmisc::sedit
 1 sanitize_latex("75% of the cars were | more than \$20,000 Delta = 1.30", greek = TRUE)