I have defined a command for absolute value using providecommand. Initially, I simply used
That was working fine until I needed to take the absolute value of an integral, and the lines did not scale at all. To make the lines scale, I tried
This works in the document, but my editor (overleaf) does not like it at all, and has highlighted all subsequent text in red - an error message intermittently displays saying command may only be used in math mode. Is my use OK (and should I therefore ignore the error message - can I override it?) or is there a better way of writing it?