3

This question already has an answer here:

Everyone seems to ask about this and the usual solution seems to be to use \lvert and \rvert with the amsmath package, but that doesn't work for me either.

example:

f_{3,2} = \left(\sqrt{13}-2-\lvert \frac{\sqrt{13}}{6}+2-2\sqrt{7}\left(1+\delta V\right)\rvert\right)/4  

Here's what I get

enter image description here

I want the absolute value bars to scale taller in accordance with the content.

What am I doing wrong?

marked as duplicate by Mico, egreg amsmath Nov 11 '15 at 21:11

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

7

You can scale then with \left\lvert and \right\rvert, just as with parentheses.

f_{3,2} = \left(\sqrt{13} - 2 - \left\lvert \frac{\sqrt{13}}{6} + 2
- 2\sqrt{7}\left(1 + \delta V\right) \right\rvert \right)/4  

If you load the mathtools package, you can use a \DeclarePairedDelimiter command which simplifies scaling delimiters: writing \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} defines two commands: \abs, which delimits its argument with \lvert and \rvert, and \abs*, which does the same, but scaling it automatically.

Here's what this would look like for your code.

% in preamble
\usepackage{mathtools}
\DeclarePairedDelimiter{\paren}{(}{)}
\DeclarePairedDelimiter{\abs}{\lvert}{\rvert}

% document
f_{3,2} = \paren*{\sqrt{13} - 2 - \abs*{\frac{\sqrt{13}}{6} + 2
- 2\sqrt{7}\paren*{1 + \delta V}}}/4  
  • 2
    Even better use mathtools and it's \DeclarePairedDelimiter to make \abs{} (i think it is even an example in the manual). It gives you a simpler interface to use. – daleif Nov 11 '15 at 19:36
  • 1
    My god. Thank you Arun. But why god does LaTeX need "\left" and "\lvert" (with an "l" for left!)? Makes no sense. Either way, this has been causing me problems forever, so thanks! – Steve Nov 11 '15 at 19:38
  • 1
    @daleif: oops, while you wrote that I was editing in an answer to use that. Thanks for pointing it out, though! – Arun Debray Nov 11 '15 at 19:39
  • @Steve: the l and r in \lvert and \rvert indicate "spacing as a left delimiter" and "spacing as a right delimiter," respectively. I agree it's counterintuitive, but there are times where I want the correct spacing, but to not scale the delimiters, such as $\abs{A_j}$ in text mode (if the delimiters scaled with the subscript, it would make the line too tall). So it's nice to have both options. – Arun Debray Nov 11 '15 at 19:43
  • 3
    @Steve try |-1| vs \lvert -1\rvert then you will see the significance – daleif Nov 11 '15 at 19:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.