2

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 https://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

2 Answers2

1

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 –  Mar 25 '19 at 12:56
0

Simply click on "[blue box]" (the blue box is actual blue box) at the bottom, i.e., last one in the series () [] {} [blue box]. It is the "insert delimiters" option. A pop up as "math delimiter" will appear. Use it (for absolute sign | & |). It will resize automatically.