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.
Asked
Active
Viewed 1,666 times
1 Answers
4
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.

\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}
Werner
- 603,163
-
Of course, you can also use
\usepackage{xspace} \newcommand{\vertrule}[1][1ex]{\rule{.4pt}{#1}\xspace}and avoid having to use\vertrule{}when you want to use the default height, but see Drawbacks ofxspace. It depends on your use-case. – Werner May 01 '14 at 22:39 -
2Since
\vertis a math rule, its endcaps are rounded, and not flat like a\rule. If a substitute for\vertis in the offing, consider using roundrule.sty and the\roundrule[]{}{}macro, found at http://tex.stackexchange.com/questions/161297/is-there-such-a-thing-as-a-mathrule-rounded-endcaps/161309#161309 – Steven B. Segletes May 02 '14 at 00:36
\documentclass{...}and ending with\end{document}. – Heiko Oberdiek May 01 '14 at 22:02listingsis to usemoreemph, which appends to the identifiers to highlight to the existing list, whereasemphoverwrites the existing list (if any) with the new one. For more details, see section4.6in thelistingsdocumentation. – jub0bs May 01 '14 at 22:10