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.
1 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
.
\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}
-
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 1, 2014 at 22:39 -
2Since
\vert
is a math rule, its endcaps are rounded, and not flat like a\rule
. If a substitute for\vert
is in the offing, consider using roundrule.sty and the\roundrule[]{}{}
macro, found at tex.stackexchange.com/questions/161297/… May 2, 2014 at 0:36
\documentclass{...}
and ending with\end{document}
.listings
is to usemoreemph
, which appends to the identifiers to highlight to the existing list, whereasemph
overwrites the existing list (if any) with the new one. For more details, see section4.6
in thelistings
documentation.