# How to write vertical bar (|) symbol in LaTeX?

The vertical bar or line (|) serves various purposes, from denoting absolute values to separating matrix elements. This guide will walk you through the steps to elegantly integrate the vertical bar symbol into your mathematical expressions and more.

Contents

## Guide to Writing Vertical Bar Symbol in LaTeX

\vert and \mid both produce the same vertical bar (|) symbol.

### LaTeX: Vertical bar in text

You can also enclose (|) in a pair of dollar signs to use the vertical bar symbol within the text to enter inline math mode. For example:

\documentclass{article}

\begin{document}

This is a vertical line: $|$

\end{document}

Or

\documentclass{article}

\begin{document}

This is a vertical line: $\mid$

\end{document}

Output

### Vertical line in LaTeX equation

For equations or mathematical expressions that are displayed on their own line, you can use double  or the $and$. You can use the \vert command to produce a vertical line symbol. For example:

\documentclass{article}

\begin{document}

This is an equation with a vertical line:
$f(x) = x^2 + 3x - 2 \vert_{x=2}$
$g(y) = y^2 + 4y - 10 \vert_{y=4}$

\end{document}

Output

Following these examples, you can easily incorporate the vertical line or bar symbol into your LaTeX documents. To see the results, remember to compile your document using a LaTeX editor or compiler.

### 1 thought on “How to write vertical bar (|) symbol in LaTeX?”

This site uses Akismet to reduce spam. Learn how your comment data is processed.