8

Putting the below commands in the preamble of a document causes TexStudio to wrongly flag "math command outside math env" (as illustrated)

enter image description here

The declaration I found on the list at absolute value symbols. Is there any way to prevent TexStudio doing this?

Note: This is not the question of how to make TexStudio recognise the \DeclarePairedDelimiter command which is answered by editing the .cwl file

2
  • Sorry, my bad. Your question was very clear, I misunderstood the other one :-)
    – campa
    Dec 9 '20 at 15:43
  • No problem at all
    – peter2108
    Dec 9 '20 at 16:05
2

Edit:

I just realized that the highlighting had already worked before I added that line to my test .cwl.
Then I checked github and saw that a similar edit to what I proposed has already been to mathtools.cwl since that question was asked.

So, a better answer would probably be: update TeXstudio (if you haven't already in past months).


You can mark arguments in .cwl files as math-environment-like with the %formula-suffix, so you could redefine \DeclarePairedDelimiter using:

\DeclarePairedDelimiter{delim%cmd}{left%formula}{right%formula}#d

Then the code copied from the question you linked would look like this:

enter image description here

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.