Texstudio: Allow math commands in macro argument

Created on 10 Aug 2018  路  4Comments  路  Source: texstudio-org/texstudio

I am currently writing a .cwl-file for a custom package in which I specify a \unit macro. In the .cwl I write \unit[quantity]{unit} and the auto-complete works fine with that. However the <unit>-part will be typeset in math mode and therefore constructs like \unit[3]{m^{-1}} are perfectly valid and won't produce any errors.

The problem is: TS complains about the ^ being used outside of math-mode. Is there some cwl-magic I can use to convince TS that the mandatory macro argument is going to be in math-mode?

enhancement

Most helpful comment

It appears that all arguments named formula will accept math commands just fine. As far as I can see this isn't documented in the user manual though.

Merged pull request #948 has added that to user manual. So I think the current issue is fully fixed.

All 4 comments

There is currently no way to deactivate the syntax check with certain command arguments.

You can only globally deactivate Options -> Editor -> Inline Checking -> Syntax.

Actually this feature seems to be implemented already as can be seen in the CWL for the chemformula package: https://github.com/texstudio-org/texstudio/blob/5dd68d835473083f9fce12b044fe335533ae03bc/completion/chemformula.cwl#L28

It appears that all arguments named formula will accept math commands just fine. As far as I can see this isn't documented in the user manual though.

A further question of mine would be if there is a %-version of this as well that can be appended to the argument's name (just like \test{something%text} will show something in the completion menu but handles the argument as normal text)?

A further question of mine would be if there is a %-version of this as well that can be appended to the argument's name (just like \test{something%text} will show something in the completion menu but handles the argument as normal text)?

I just opened #946 for this exact purpose.

It appears that all arguments named formula will accept math commands just fine. As far as I can see this isn't documented in the user manual though.

Merged pull request #948 has added that to user manual. So I think the current issue is fully fixed.

Was this page helpful?
0 / 5 - 0 ratings