How to insert pipe symbol in (La)TeX?

The pipe symbol may be used directly in the input and will produce the desired output if you use T1 font encoding. For example:

\documentclass{article}
\usepackage[T1]{fontenc}
\begin{document}
Pipe sign: |
\end{document}

Output:

enter image description here

Compare these tables to see the difference between the two font encodings: OT1 (Standard encoding) vs. T1 (Cork encoding). The OT1 table doesn't contain the pipe symbol, but it can be found in the T1 table. It's position is 7C. With OT1 7C means a wide dash, that's why we get a wide dash instead of the pipe symbol in standard encoding.

See Special LaTeX characters for some more information.

For using the command \textpipe loading a package like tipa or t4phonet is necessary.


It is unnecessary to load any additional packages unless there are other reasons to do so. Mathmode provides alternative symbols $\vert$ for a vertical pipe and $\Vert$ for a double pipe. These appear to be independent of encoding. Actually as a math symbol $|$ appears also to be encoding independent.


I would recommend using the command \textbar, since this does not require you to use different encoding or additional packages. For me this was a much better solution, as I was already committed to usepackage[utf8]{inputenc}. Also, I am using a system that puts UTF-8 data into LaTeX templates (escaping special characters), and this system cannot rely on any additional packages (other than UTF-8 encoding).