Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.


#665 autocompletion and \DeclareMathOperator*



When creating a new command with \DeclareMathOperator, it is automatically add to the autocompletion and the syntax check (as with \newcommand)... which is awesome.
However, when using the starred version \DeclareMathOperator*, this feature is not activated (under TXS 2.6.6, Windows XP).

See attachment for a screenshot.

The feature requests would be:
1) Can you make \DeclareMathOperator* behaves as its unstarred version?
2) Can I do this feature on my own (in a custom cwl file or elsewhere), for other \newcommand-like commands defined in other packages? (I have in mind, for instance, those given by mathtools: \DeclarePairedDelimiter, \DeclarePairedDelimiterX, ...).


1 Attachments


  • Tim Hoffmann
    Tim Hoffmann

    You can make a custom cwl in you settings directory with the following content:

    Then permanently load it by selecting the checkbox in Options -> Completion.

  • Mathieu2L

    ok, thanks for the quick answer! Works fine now for \DeclareMathOperator*.

    Though it raises new questions:
    1. I checked in completion/amsmath.cwl before posting and both \DeclareMathOperator and \DeclareMathOperator* are identically defined with (only) #n: shouldn't they behave the same way (before making that custom cwl file)? or are they redefined elsewhere?
    2. I put in my custom cwl the following
    And in my preambule
    It works fine except that the syntax checking of TXS highlights \rfloor (but not \lfloor) for not being inside a math mode (in fact, I'd say whichever command marked as #m is highlighted in the third argument of \DeclarePairedDelimiter but not in the second).
    ==> could this be possible (would this be a good idea??) to deactivate that syntax checking in all the arguments of a command marked as #d?
    3. I wanted to edit my own mathtools.cwl (to make those changes and also because \DeclarePairedDelimiter is already defined but not as #d); so I copied-pasted mathtools.cwl (found in Sourceforge) in my settings directory, I made the modif inside, I restarted TXS and activated the (newly appeared) mathtools checkbox in Options -> Completion. However, nothing happend: it seems that this new mathtools.cwl doesn't override the one shipped with TXS; is it supposed to do that?

  • Tim Hoffmann
    Tim Hoffmann

    1. There are still some commands hard-coded to be definition commands. \DeclareMathOperator is in this list \DeclareMathOperator* is not. This is still some relic from the time before it was possible to declare definition commands in the cwl format. We should (and will) change this in the future, so that it's directly in the supplied amsmath.cwl. I just gave you the workaround to make it work immediately.

    2. This is a limitation of the cwl format/parser. It's not flexible enough to understand the meaning of the three arguments. See also

    3. This is another limitation, currently. The cwl files on sf are compiled into the executable and take precedence over external files. Changing this is already on the TODO list.

  • Tim Hoffmann
    Tim Hoffmann

    Fixed 1. (hg 4300 (add42b59069f)): moved hard-coded definitions to the cwls. Also specified \DeclareMathOperator* and some more as definition commands. So the workaround with a user.cwl will not be necessary in future versions. Issues 2. and 3. will remain for the time being.

  • Mathieu2L

    Thank you for the response and the information!
    I look forward to future versions ;-)