I don't know how to get syntax highlighting in TeXstudio (windows 10) with semantex. I found some guides on the internet but I'm not a programmer so not sure how to do it. Can someone help me?

  • 1
    I’m not familiar enough with the TeXstudio .cwl syntax to know how to do that. Also, one thing is getting the system to recognize command names; this is not a big deal, I guess, since there are essentially only a few object and class commands (\NewObject, \NewVariableClass, etc.) which are used to define them. On the other hand, getting it to recognize key names (especially the user-defined keys) might require black magic.
    – Gaussler
    Dec 15, 2020 at 19:49
  • 1
    What is semantex?
    – Alan Xiang
    Dec 18, 2020 at 4:03
  • 1
    @AlanXiang ctan.org/pkg/semantex :)
    – Cinque
    Dec 18, 2020 at 8:10

1 Answer 1


This is not an answer, but an overview of the commands which a syntax highlighting system would need to be able to recognize:

There are five different commands for creating new classes, corresponding to different “class types”: \NewVariableClass, \NewCohomologyClass, \NewSymbolClass, \NewDelimiterClass, and \NewSimpleClass. Each of them has the syntax

\New<???>Class\<Class Name><extra syntax>

So for instance, \NewVariableClass\MyVar creates the class \MyVar. The <extra syntax> depends on the class type, but it’s usually options in [...]. A syntax highlighter should probably just ignore the <extra syntax> and interpret \New<???>Class as commands that create other commands.

There is one command, \NewObject, for creating new objects. It has the syntax

\NewObject\<Class>\<object><extra syntax>

So for instance, \NewObject\MyVar\myobject creates the object \myobject of class \MyVar. In other words, \NewObject should be regarded as a command that discards the first argument and defines a command whose name is the second argument. Again, it’s probably best to ignore the <extra syntax>, as this depends on the class type of the class \<Class>.

There is one predefined class, called \SemantexBaseObject.

Next, there are a couple of commands, \SemantexSetup, \SetupClass, and \SetupObject, which do what the name suggests. No magic there, they should just be recognized as any other commands.

There is a command, \SemantexDelimiterSize, which contains the size of the surrounding brackets.

There is a lot of keyval syntax in semantex, including a lot of user-defined keyval syntax. I think this part of the syntax is too complex to be recognized by a syntax highlighter. Therefore, recognizing the above commands is probably all you can do.

I finally managed to figure out the .cwl system, which turns out to be rather simple. Simply add a file semantex.cwl in the appropriate folder with the following content:


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .