I would like to use the following command in my LaTeX code
\newcommand{\newsym}[2]{\newcommand{#1}{\ensuremath{#2}}}
so that I can easily define new symbols that I often use in my equations, such as:
\newsym{\kTq}{\frac{k_BT}{q}}.
The intent being to reduce the amount of typing necessary to define new symbols and to enhance readability of the code.
The problem now is twofold:
- TeXstudio dosn't realize my
\newsym
defines a new command and complains that the first argument (\kTq
) is an uncrecognized command. - It also doesn't realize the second argument is eventually enclosed in an
\ensuremath
environment and complains math command outside math environment
As a result I have my \newsym
definitions cluttered with bad-syntax highlighting, impeding the readability, which was the entire half of the purpose of defining \newsum
in the first place.
Can I solve this dilemma by somehow adjusting the way TeXstudio does the error highlighting in this particular case? I don't wan't to disable the highlighting altogether; they are otherwise useful.
Or is there a smarter alternative to my definition of \newsym
that avoids this problem?
.cwl
for TXS to recognize your custom commands. – naphaneal Jul 1 '16 at 14:28\ensuremath
here at all? do you use\kTq
outside of math mode? – David Carlisle Jul 1 '16 at 14:38\ensuremath
, as is also the case when I use\newsym
, teXstudio will highlight the math-mode commands in the new symbol's definition. It's true that the new symbol still works nonetheless and you are right that I don't use the new symbol outside math-mode but that wasn't the point. – Glemi Jul 1 '16 at 14:55\ensuremath
the new command is just the same as\newcommand
so you could use that and presumably your editor will be happy without any more work needed. – David Carlisle Jul 1 '16 at 16:28