[Tex/LaTex] How does one insert a backslash or a tilde (~) into LaTeX

symbols

  • How does one insert a "\" (backslash) into the text of a LaTeX document?
  • And how does one insert a "~" (tilde)? (If you insert \~, it will give you a tilde as an accent over the following letter.)

I believe \backslash may be used in math formulae, but not into text itself. Lamport's, Kopka's, and Mittelbach's texts have said as much (but no more), and so left me hanging on how to get a backslash into regular text.

Best Answer

TL;DR

\textbackslash produces a backslash in text-mode. The math-mode $\sim$ and \texttildelow (from textcomp package) are options for a lower tilde (while \~{} and \textasciitilde produce a raised tilde in text-mode)


Long Answer:

The Comprehensive LaTeX Symbol List is your friend. The correct link seems to keep changing, but if you have a complete TeX Live installation, the command texdoc symbols-a4 will display your local copy.

\textbackslash and \textasciitilde are found in several places in the document, but the LaTeX 2e ASCII Table (Table 529 as of this writing) and the following discussion are a convenient resource for all ASCII characters. In particular, the discussion notes that \~{} and \textasciitilde produce a raised tilde, whilst the math-mode $\sim$ and \texttildelow are options for a lower tilde; the latter is in the textcomp package, and looks best in fonts other than Computer Modern. If you are typesetting file names or urls, the document recommends the url package.

Remember to delimit TeX macros from surrounding text, e.g. bar\textasciitilde{}foo.