I've been looking for a way to use the \abs command in LyX (Version 2.3.0, using MikTex) but unfortunately I didn't find a solution.

For a reason I'm not aware of, this command does not appear as an option in a math box. I tried defining it as a macro:

enter image description here

with \lvert and \rvert, which is ok except for the fact that it doesn't scale. I read that there is something called a "starred" version of a command, which should solve the scaling problem ,but I didn't manage to define the macro as such.

Would appreciate any help!

  • The standard LaTeX way would be to use \DeclarePairedDelimiter{\abs}{\lvert}{\rvert} using the macro from mathtools as described in tex.stackexchange.com/q/1742/15925. Usable as \abs[\big]{X^Y} and \abs*{\frac{A}{X^2+Y^2}}. – Andrew Swann Mar 23 '19 at 15:51
  • I've tried putting this line \DeclarePairedDelimiter\abs{\lvert}{\rvert} in Document->Settings...->LaTeX Preamble, but I didn't notice any change. The \abs command is still not available. Is this the right place where it should be added? – Izo Sakallah Mar 23 '19 at 16:41
  • I don't think adding a latex command to the preamble makes LyX generate an interface for it. You'll need to input it as direct latex code in order to use it – daleif Mar 23 '19 at 17:37
  • Are any errors reported? – Andrew Swann Mar 24 '19 at 16:57

Include the package AND declaration in your preamble

Insert your TeX compile and enjoy!

enter image description here

  • Thank you very much! Now it works :) Please allow me to bother you with another question: do you know how I can add LaTeX code as a macro in LyX? – Izo Sakallah Mar 25 '19 at 12:52
  • That is not an area I am familiar with and best raised as a fresh question – user170109 Mar 25 '19 at 12:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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