[Tex/LaTex] Creating a smaller vertical bar

charactersmath-mode

I want a vertical bar but in mathematical mode it appears too big. I just want a small | at the same height as the letters.

Best Answer

You can use \rule{.4pt}{1ex} which will sit on the baseline and be 1ex high. Of course, adjust 1ex to suit your "small" requirement. Here's a small example showing the use case via a macro \vertrule[<len>] where <len> defaults to 1ex.

enter image description here

\documentclass{article}
\newcommand{\vertrule}[1][1ex]{\rule{.4pt}{#1}}
\begin{document}
You can use \vertrule{} (compared to $|$) which will sit on the baseline and be \verb|1ex| high. 
Of course, adjust \verb|1ex| to suit your "small" requirement using \vertrule[1.5ex].
\end{document}