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

muzimuzhi Z
  • 26,474
peter2108
  • 213

1 Answers1

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

schoekling
  • 3,142