I am using the following piece of code to draw a Feynman diagram using the tikz-feynman package.

    \feynmandiagram[layered layout, medium, horizontal=a to b] {
        a [particle=\(H\)] -- [scalar] b [dot] -- [photon] f1 [particle=\(W^{\pm}\)],
        b -- [boson, edge label=\(W^{\mp}\)] c [dot],
        c -- [fermion] f2 [particle=\(f\)],
        c -- [anti fermion] f3 [particle=\(\bar{f}'\)],

The output comes out correctly, but the code is always highlighted in red to indicate that there might be some fault with the code.

I was wondering if there is some fault with this piece of code.

  • 1
    If your editor (I'm guessing TeXStudio?) highlights the code as bad, but it doesn't produce any warnings/errors, and the output is as expected, then the problem is not the code, but that the editor doesn't know about the syntax of tikz-feynman. Feb 18, 2017 at 23:22
  • this is sharelatex. how do I turn off the highlighting? Feb 18, 2017 at 23:41
  • 1

1 Answer 1


That your editor, in this case ShareLaTeX, highlights a block of code in red like that, indicating that something is wrong with it, does not necessarily mean that there is anything wrong.

There are thousands of packages available on CTAN, and for an editor to do syntax checking of all the syntax provided by all of these packages is unrealistic I think. As a result, this type of checks by editors sometimes just causes confusion for users, because, as in your case, everything looks fine, but the editor claims that something is wrong.

What this means is that the editor's syntax checking isn't always reliable, so you should put more trust in the .log file (and the output). If you don't get any warnings or errors, and the output looks as it should, then there's no reason to think that anything is wrong.

To turn off this type of checks for ShareLaTeX, see https://www.sharelatex.com/learn/Code_Check: It can be turned off globally in the settings, or for a specific document by adding %%novalidate at the start of the file.

You must log in to answer this question.

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