Skip to content

Problem Latex Repr

escape_latex_special_character(text)

Replace characters that matches with the 10 latex special characters.

There are 10 latex special characters: 1. tilde ~ 2. circumflex ^ 3. backslash \ 4. percent sign % 5. ampersand & 6. dollar sign $ 7. number sign # 8. underscore _ 9. left brace { 10. right brace }

https://tex.stackexchange.com/questions/34580/escape-character-in-latex/34586#34586

If latex has some latex special characters, then replace the characters into other strings by following the below table:

name src dst
backslash "\" " extbackslash{}"
tilde "~" " extasciitilde{}"
circumflex "^" " extasciicircum{}"
ampersand "&" "\&"
percent sign "%" "\%"
dollar sign "$" "\$"
number sign "#" "#"
underscore "_" "_"
left brace "{" "{"
right brace "}" "}"

Parameters:

Name Type Description Default
text str

string

required

Returns:

Name Type Description
str str

string without 10 latex special characters


Last update: 2023年7月5日