Kile automatically highlights what is inside a math environment. Now, if I use an environment that I defined and that includes opening a math environment, this is not recognized by kile.

Is it possible to add this newly defined environment to the list of environments that kile recognizes as math?


You need to edit the xml file that provides the markup definitions. Depending on the distro, the file is

  • /usr/share/apps/katepart/syntax/latex.xml
  • ~/.kde4/share/apps/katepart/syntax/latex.xml
  • /opt/share/apps/katepart/syntax/latex.xml
  • /usr/share/kde4/apps/katepart/syntax/latex.xml

You then need to add your environment name to

  <!-- filter the environment name and check the type -->
  <context name="BeginEnvironment" attribute="Environment" lineEndContext="#stay">
  <RegExpr String="(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)" attribute="Environment" context="MathEnv"/>

and also to

  <!-- end of math environment -->
  <context name="MathFindEnd" attribute="Normal Text" lineEndContext="#pop" fallthrough="true" fallthroughContext="#pop">
  <RegExpr String="(equation|displaymath|eqnarray|subeqnarray|math|multline|gather|align|flalign|alignat|xalignat|xxalignat|IEEEeqnarray|IEEEeqnarraybox|smallmatrix|pmatrix|bmatrix|Bmatrix|vmatrix|Vmatrix)\*?" attribute="Environment" context="#stay"/>
  • Thanks for your reply. Unfortunately, I can't find the file you mentioned, neither under the adress you gave nor using file search. (Just on a side note, I am using linux as a "simple" user at work, w/out root privileges, but I guess that isn't the problem here)
    – ChrisBln
    Jan 31 '13 at 15:30
  • Thought of this too late, can't edit previous comment anymore: The path you gave ends at katepart for me, "syntax" already does not exist. Does this indicate the file would be somehwhere else or could it simply not be there and wait to be created?
    – ChrisBln
    Jan 31 '13 at 15:38
  • @ChrisBln I don't know. I would search for latex.xml, you may have a system wide config. You might be better off asking in a kde or distro specific forum.
    – StrongBad
    Jan 31 '13 at 22:01
  • Thank you, @Seul, found it now. Unfortunately, I'm not allowed to edit the file though...
    – ChrisBln
    Feb 12 '13 at 14:50
  • 3
    @ChrisBln you should be able to copy it to your local home directory ~/.kde4/share/apps/katepart/syntax/latex.xml and edit that version
    – StrongBad
    Feb 12 '13 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.