How can I get in TeXstudio the same syntax highlighting of TikzEdt? Look at the red word (called operation in Tikz, I think) "circle".

In TikzEdt:

TikzEdt syntax highlighting

In TeXstudio:

enter image description here

  • 2
    You probably need to write your own language definition: texstudio.sourceforge.net/manual/current/…
    – Troy
    May 23, 2018 at 17:35
  • @Troy In TikzEdt is present the file "TikzSyntax.xshd". Do you think it can be adapted for the task?
    – vi pa
    May 23, 2018 at 18:46
  • 1
    Hm, the syntax is a little different (after a quick glance at the file -- it's my first time seeing tikzsyntax.xshd), but certainly possible. I don't have time to look into it now, but maybe in the next few days... In the meantime you could give it a shot yourself.
    – Troy
    May 23, 2018 at 18:53
  • @Troy In TXS manual that you link there is written: "You can add your own languages or overwrite the default ones by placing appropriate .qnfa files in a languages folder inside the settings directory." First: where is the setting folder in windows? Second: Do I must even ricompile the TXS code? Or is it enough put the .qnfa file in the settings directory?
    – vi pa
    May 24, 2018 at 13:22
  • Put the .qnfa in .\TeXstudio\config\languages folder. And if you also want to add your own format, you need to define it inside a .qxf file and place it in that same folder (or just edit the defaultformats.qxf file). Though, this discussion might be of interest to you as well. Like the manual said, these are extra experimental features, so there's little support from the devs for these.
    – Troy
    May 24, 2018 at 13:30

1 Answer 1


I got the desired result.

Syntax Hightlighting as tikzEdt

For some strange reason, circle is highlighted as a grammatical error, that disappears if I select the dictionary in English (I'm italian). It is not a big deal.

I'm not being able to create a working .qxf file. I've create the file and put it in the folder where there is the texstudio.ini file, as suggested by Troy, but it don't work. Even the file .qnfa that I've create didn't work, when put in the same folder. So, how did I do it? I've download the tex.qnfa from the TXS's SourgeForge host, then I add the following code to this file:

    <!-- ========================= tikzPICTURES ====================== -->
    <context id="tikzpicture" format="picture" transparency="true"> 
        <start parenthesis="tikzpicture:open@nocomplete" parenthesisWeight="30" fold="1" format="extra-keyword">\\begin{tikzpicture}</start>
        <stop parenthesis="tikzpicture:close@nocomplete" parenthesisWeight="30" fold="1" format="extra-keyword">\\end{tikzpicture}</stop>
        <sequence id="tikzpicture/keyword" ambiguous="true" format="lua:comment">\\[a-zA-Z@]+</sequence>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">circle</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">coordinate</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">grid</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">rectangle</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">ellipse</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">edge</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">--</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">at</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">to</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">node</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">-|</word>
        <word id="tikzpicture/operation" ambiguous="true" format="lua:keyword">|-</word>

and put this file in the previous mentioned folder before the block of code that define the Syntax Highlighthing of PICTURES. It's possible put this code even after the PICTURES block, if you delete <e>tikzpicture</e> from the PICTURES block of code. Since I'm not succeed to create a working .qxf file I've used the format of lua:keyword suitably setted (Options > TeXstudio setting... > Syntax Hightligthing. I've set the color to a52a2a, that is the red-brown used in TikzEdt for circle, rectangle etc., and that's all.

I do not understand why a .qnfa file with only the part that I added to the file tex.qnfa does not work. Therefore I'm not very satisfied by the result. Please correct my prose, I don't speak english very well.

  • Meanwhile I'm doing all this trial on the tex.qnfa I find that in this file there is a repeated block at line nr 161 and 194 in all of which there is, I think, a syntax error prenthesisweight instead of parenthesisWeight
    – vi pa
    May 24, 2018 at 22:18

You must log in to answer this question.

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