I included the chemfig package to draw chemical stuff in LaTex. But the commands aren't recognized by TeXstudio. I even added the package to the autocompletion list in the settings to get recognized in every document but that doesn't help either.

The commands are red like following:

Looks like:

The file compiles as it should, so everything works except the recognition of the chemfig commands.

  • What is your question?
    – TeXnician
    Commented Apr 13, 2017 at 11:11
  • 5
    @TeXnician Obviously how make TeXstudio recognize commands from chemfig, though it isn't stated explicitly. Commented Apr 13, 2017 at 11:15
  • exactly thank you @Torbjørn T. Have not thought that someone doesn't get what i want to ask with my post... Commented Apr 13, 2017 at 11:18

1 Answer 1


Short answer:

It's not in the .cwl file for some reason, you're gonna have to add it in manually. (I think(!) that's the only alternative. I'm happy to be proven wrong..)

Long answer:

The Why: Autocompletion and recognition of commands by TeXstudio is controlled by the .cwl file, which can be found in your local directory. For Windows, it's in:


The .cwl file autogenerated by TeXstudio looks like this:

cwl file for chemfig

The commands in the .cwl file are in the format: <command>[#classification], so note that there are no \setatomsep, \schemestart, \chemfig etc. commands in here, so that's why they are unrecognized.

Also note that the classification are #S which means that they will not appear in the autocompleter tab when typing the command in TeXstudio.

The How:

Like I said in the short answer, you're probably gonna have to add the commands in manually if you don't want to see the 'warnings' by TeXstudio about unrecognised commands.

See my other answer here to find out how. But I have here something you can copy-paste for a quick fix. You just need to add this into your chemfig.cwl file and restart your TeXstudio to see its effect. You will need to activate chemfig.cwl in the options -> completion tab from within TeXstudio as well.

\setatomsep{sep dist}#n
\schemestart{your scheme}#n

Note: I chose to use #n classification here so you will see it in the autocompleter.

Proof that it works:

proof :)

The Hack: Of course, there is always the less desirable, but still effective solution of just plain ignoring it. :p

You can simply turn off syntax highlighting for a wrong/unrecognized command by TeXstudio, by right-clicking on the background colour box to reset it to 'no colour'.

turn off syntax highlighting

  • I have activated chemfig.cwl but still doesn't work. Any ideas?
    – ado sar
    Commented Oct 4, 2019 at 21:48

You must log in to answer this question.

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