# [Tex/LaTex] Escape character in LaTeX

I need to output the below text but since \ is a special character, I cannot:

[RegularExpression(@"\d+")]


Also sometimes I need use dollar sign $ as well but it seems to be a special char, too. What is the way to escape those in LaTeX? UPDATE: I used \verb as suggested but I am unable to run commands inside it. Also, in the output the font and the opacity of the text is different than the default one: \verb|[RegularExpression(\newline @"\d+")]|  #### Best Answer The following ten characters have special meanings in (La)TeX: & % $ # _ { } ~ ^ \

Outside \verb, the first seven of them can be typeset by prepending a backslash; for the other three, use the macros \textasciitilde, \textasciicircum, and \textbackslash.

\documentclass{article}

\begin{document}

\& \% \\$ \# \_ \{ \}

\textasciitilde

\textasciicircum

\textbackslash

\end{document}


Note that the seven "single non-letter" macros don't gobble the space following them. For the last three that do gobble up the space after them you can try one of these methods to add space.