TeX knows the difference between a "left" and a "right" delimiter (e.g. (
and )
) and adjusts spacing accordingly. However, the left and right versions of the delimiter |
are the same, so TeX has to guess. Usually TeX guesses correctly, but sometimes it does not. Now, I know that I can use \left
and \right
to force TeX to consider a given |
as a left or right delimiter, however these have the additional effect of changing the size (which maybe I don't want). Even the smallest "big" commands \bigl
and \bigr
increase the size (albeit only a small amount). Is there a way to make |
a left or right delimiter without changing its size at all?
Here is a specific example where I know how to do it, but it isn't a general solution:
\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
$|\operatorname{A}|$
$|{\operatorname{A}}|$
$\left|\operatorname{A}\right|$
\end{document}
The spacing is incorrect on the first line and correct on the second and third lines. The second line works well, but seems a bit hacked to me. The third line isn't good since it would increase the size of the delimiters if the stuff in between were taller (and maybe I don't want that).
(Yes, I know that the reason the spacing is incorrect on the first line is because TeX is treating the second |
as the "argument" of \operatorname{A}
.)
mathtools, define
\abs` withDeclarePairedDelimiter||
, you won't have this problem, and it will be shorter to type.mathtools
! This doesn't solve everything though, since if I have an equation with more than two|
, how will it know how to pair them up?\mathopen
or\mathclose
before a symbol to force interpretation of that symbol as an opening atom or a closing atom, respectively. For example,$\mathopen|-x\mathclose| \neq |-x|$
.|a|b|c|
could be either\left|a\left|b\right|c\right|
or\left|a\right|b\left|c\right|