I have a macro for absolute value (using \DeclarePairedDelimiter from mathtools):


This works great in terms of adjusting the size of fences etc. But the superscript position when I use \abs{x}^2 is too high. See the following:

PDF output

Any idea if this is a bug or not, or how I can fix it? Edit: It appears that the above behavior due to the fact that DeclarePairedDelimiter calls \mathclose / makes a subformula. I don't know if this was a design choice or not -- but I would certainly like to know if there is an easy way to work around it.

Here's my code for the above.

    The superscript following \verb'\abs{x}' is higher than that following \verb'\lvert x\rvert'.
    Here is an example:

      \verb'\abs{x}^2 \lvert x\rvert^2' produces $\abs{x}^2 \lvert x\rvert^2$.
    The same happens in displayed math:
      \abs{x}^2 \lvert x\rvert^2

Thanks in advance.


2 Answers 2


This is a design choice in mathtools. Not all users know \rvert is better than |, so we help them, also it helps us if someone wanted to use )(as the delimiter pair. Short of repeating the fenced material in a \vpahntom after the fence, I don't know a better method.

But, in this case, as you are using the proper left and right fences, there is an out:

  • Thanks. This works. I didn't get what you mean by someone wanting to use )( as the delimiter pair? Do you mean use the parenthesis in the wrong order?
    – gi1242
    Apr 11, 2017 at 21:30
  • @gi1242 if ( is the right delimiter in a construction like this (let's call it foo) then the minus in \foo{x} - 2 comes out wrong as ( has the class of a math open and then the minus following it is unitary not additional (wrong spacing). So when you remove the explicit you need to be sure the right delimiter is of type math closing (rvert is)
    – daleif
    Apr 11, 2017 at 21:35
  • Addition: I meant to write:_if you remove the explicit \mathclose..._
    – daleif
    Apr 12, 2017 at 6:08
  • @gi1242 please note that this code will produce an error in the upcomming mathtools update. I had to split nostar into two separate macros. Attempting to change nostar will now give an error. On the other hand your original problem is now fixed.
    – daleif
    May 24, 2017 at 8:17

DeclarePairedDelimiter produces a subformula. EDIT as @Daleif suggested this is due to DeclarePairedDelimiter to call \mathclose on the right brace.

This is equivalent of using braces ({ and }), which also produce math subformulas, which can cause alignment issues sometimes. (Incidentally, that's why you don't usually have adjacent braces {}) in math mode.

See following examples:


      \left|x\right|^2 \lvert x\rvert^2 \\
      \abs{x}^{2} \lvert x\rvert^{2} \\
      {|x|}^{2} \lvert x\rvert^{2} 


enter image description here

You can clearly see that the second example (which is your text) and the subformula produce the same alignment.

It seems that the exponent is applied to the whole subformula, and not carried as the exponent of your variable.

  • @Mico Yup, that's caused by DeclarePairedDelimiter creating a subformula, thus I guess that the exponent is applied to the fence and not to the variable. I corrected my post
    – Moriambar
    Apr 11, 2017 at 20:51
  • 1
    It seems to be due to the fact that \abs is using \mathclose on the right delimiter. Unstarred left/right is not used
    – daleif
    Apr 11, 2017 at 20:55
  • Thanks. You're right, the subformula has the same alignment of subscripts. is there a way I can get around it? That is can I get \DeclarePairedDelimiter to not create a subformula...?
    – gi1242
    Apr 11, 2017 at 21:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .