Posts Tagged ‘color’

Tango LaTeX Syntax Highlighting

Tuesday, December 9th, 2008

As I have previously mentioned, I am quite a fan of the Tango color palette. In this installment, I want to show how to highlight code listings in LaTeX using the Tango colors like in the following Smalltalk example:

Tango Syntax Highlighting

The screenshot above is actually from a full blown example which I have created for XeLaTeX. If you wish to typeset the example in pdfLaTeX or similar, you can just comment out the lines it complains about.

Let’s go through the source. First of all, you will need the xcolor package to define the custom colors:

\usepackage{xcolor}

Then we can define the colors. I have simply converted the hex color definitions into rgb values acceptable to xcolor. For more information, see the xcolor documentation.

\definecolor{Butter}{rgb}{0.93,0.86,0.25}
\definecolor{Orange}{rgb}{0.96,0.47,0.00}
\definecolor{Chocolate}{rgb}{0.75,0.49,0.07}
\definecolor{Chameleon}{rgb}{0.45,0.82,0.09}
\definecolor{SkyBlue}{rgb}{0.20,0.39,0.64}
\definecolor{Plum}{rgb}{0.46,0.31,0.48}
\definecolor{ScarletRed}{rgb}{0.80,0.00,0.00}

Note that this is just a part of the color definition. See the source for all available colors.

Now that we have defined the Tango colors, we can use them to highlight our source. Depending on the language that you are wishing to highlight, not all numbered keywords will be applicable. I use these different keywordstyles to highlight the above Smalltalk source.

\lstset{
	keywordstyle=[1]{\color{DarkSkyBlue}},
	keywordstyle=[2]{\color{DarkScarletRed}},
	keywordstyle=[3]{\bfseries},
	keywordstyle=[4]{\color{DarkPlum}},
	keywordstyle=[5]{\color{SkyBlue}},
	commentstyle={\color{Aluminium4}},
	stringstyle={\color{Chocolate}},
	basicstyle={\ttfamily},
}

And that’s all you need to use Tango colors for you syntax highlighting in LaTeX. Again, take a look at the source code to see the above code in full.

Tango Themed OS X Terminal

Monday, December 8th, 2008

I am not a fan of Gnome but ever since I installed an Ubuntu on my computer at work I have been a fan of using the Tango color theme for terminals. The colors feel smooth and work well in combination with semi-transparent terminal windows. I have applied the theme to other environments as well and when I recently started using Leopard on my new Macbook I realized I could not simply change the ANSI colors like I had previously on Tiger.

Turns out it is not so difficult on Leopard either, but you will need to install some additional software.

Tango Themed Terminal

So, to get Tango colors in your terminal, follow the following instructions:

  1. Download and install SIMBL which is a little hack to allow you to extend OS X applications.
  2. Unpack Ciarán Walsh’s SIMBL plugin that adds customizable ANSI colors to Terminal.
  3. Download and double click OS X Terminal Tango Theme.

Let me know if you have any comments.