How to Write a Backslash in LaTeX

In LaTeX, the backslash \ is a special character used to introduce commands. To display a backslash as a character in document, you will need to escape it by using a double backslash [\\].

The following examples show how to write a backslash in LaTeX.

How to Write a Backslash in Text

We can use a double backslash to display a backslash in LaTeX document for text.

Example: Backslash in Text

Suppose we want to write a backslash in the text.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

This is an example of using a backslash \\ in a sentence.

\end{document}

Output: 👇️

This is an example of using a backslash \ in a sentence.

In this example, we use double backslash [\\] to display a single backslash in the text.

How to Write a Backslash in Mathematical Expressions

For mathematical expressions, to display backslash (), we need to escape it with another backslash: \backslash.

Example: Backslash in Mathematical Expressions

Suppose we would like to write mathematical expressions that contain a backslash.

We can use the following LaTeX code to do so:

\documentclass{article}
\begin{document}

An inline mathematical expression: \( a \backslash b \).

A displayed mathematical expression:
\[
a \backslash b
\]

\end{document}

Output: 👇️

Backslash

In this example, we use the \backslash to display a single backslash in both inline and displayed mathematical expressions.

Conclusion

We can use the standard keyboard character \ for both text and mathematical expressions to display backslash. For mathematical expressions, you can use \backslash to properly render a backslash.