Latex brush for Syntax Highlighter Plus Wordpress plugin

I post source code snippets quite often and I use this plugin for syntax highlighting. It works great but it doesn’t support every programming language. For example it lacks Latex support. On the other hand you can define coloring rules for unsupported languages by creating new “brushes”.

Taking advantage of this feature, I’ve defined an extremely simple Latex brush which highlights:

  • Latex comments beginning with a percent symbol ‘%’.
  • Latex commands beginning with a backslash “\”.
  • Some keywords such as ‘if’, ‘else’, etc.

You can download the brush from here.

If you want to see Latex coloring in action, you can take a look at the Latex section of my blog.

Note: I also had to add this line:

'Latex'     => array('latex', 'tex'),

…to the SetVariables() function in syntaxhighlighter.php for the new brush to work.

Share this post:

  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
Related posts:
  1. Less than and greater than symbols in Latex
  2. Get more section levels in Latex
  3. Indent first paragraph of the section in Latex
  4. Fix overfull problems when too many consecutive empty sections in Latex
  5. Visual Studio Doxygen Latex and encoding problems

One Comment

  1. Finally! Great! Took me a while to find this one, probably because I searched for TeX and not for LaTeX. Others commented on the forums that work was done, by never found the completed work.

    Anyway, I added your LaTeX highlighter to my list of “all” brushes (bundled and non-bundled alike), hope you don’t mind, of course with due credits: http://www.undermyhat.org/blog/2009/09/list-of-brushes-syntaxhighligher/

Leave a Reply