Color schemes for Emacs and TeX


I lastly tried the Solarized color theme for Emacs which provides a nifty colorscheme (for light or dark backgrounds). This led me to wonder whether I could use this theme for highlighting code chunks in my LaTeX documents.

Although it looks great, I gave up on it for Emacs because I had difficulties reading my text with the base color for body text (base0 or base00, depending on the background color). Also, I don't like having different emphasizes for the same code identifier, e.g. <a href= where color for < is different than for a.


Pygmentize is very great, and the Minted LaTeX is based on it. I already wrote a post on it.

According to the documentation, it is possible to customize the output and add our own formatter. Let's try a simplified style:

from import Style
from pygments.token import Keyword, Name, Comment, String, Error, \
     Number, Operator, Token

class SolarizedStyle(Style):
    background_color = "#fcf4dc"
    default_style = ""
    styles = {
        Token:                  '#52676f',
        Comment:                '#465a61',

        Operator:               '#728a05',       
        Keyword:                '#728a05',

        Name:                   "#a57705",
        Name.Builtin:           '#2075c7',
        Name.Function:          '#2075c7',
        Name.Class:             '#2075c7',

        String:                 '#259185',
        Number:                 '#c61b6e'

Then, we need to put this in the pygments/styles/ folder, in Python site-packages. To check that it works,

>>> from pygments.styles import get_style_by_name
>>> get_style_by_name('solarized')

It should return something like


We can test it with a little Python script, e.g. Below, from top to bottom are the simplified solarized theme, and the built-in colorful and Tango themes.




I must admit that I still like how the Tango palette looks like. Now, here is how it looks under my Emacs (top, solarized; bottom, my custom tango palette):



Well, I have to test it into a LaTeX paper.

VIM color scheme

The Tango palette is great. And it is with great irony that I have to use VIM to beautify my code that I'm typing in Emacs. Indeed, as I like working with CONTEXT, instead of LaTeX, I was in need of an efficient solution for syntax highlighting. Despite my best efforts with on-line wiki, I raised the question on, see Code highlighting in ConTeXt. At the time I asked on tex.SE, I wasn't able to get it because of my outdated version of CONTEXT. Once I updated to the svn version, everything worked well per @Aditya's solution.

Wrapping the above code like this


\definevimtyping [PYTHON] [syntax=python]
 ### Put code here ###

and running

$ context par_checker.tex

I get the following PDF:



Articles with the same tag(s):

Collecting email usage statistics from mu
Data science at the command-line
Interacting with Weka from Jython
CoffeeScript or how to avoid typing ugly Javascript code
Workflow for statistical data analysis
Playing with Julia
GSL Shell
Apple weekend miscellanies
Compiling Gnuplot on OS X
Weaving scientific document