Make LaTeX source readable in TeXShop

TeXShop for the Mac is my source editor of choice for LaTeX files because it comes with the MacTex binary and can compile your document straight from the editor. With a dark background though – as I prefer when writing source files – the default colours for syntax highlighting are woefully unreadable because they’re designed for a lighter background.

TeX source unoptimised

TeX source with dark background without optimised colours

Having said that I like size 16 font, so maybe it’s just my eyes. In case it isn’t just me though, it’s a doddle to change the syntax colours. In Mac Terminal, run the following commands (copy all lines and paste in to terminal, then press enter just the once):

defaults write TeXShop commentblue 0.6
defaults write TeXShop commentred 0.6
defaults write TeXShop commentgreen 0.6
defaults write TeXShop markergreen 0.8
defaults write TeXShop markerblue 0.8
defaults write TeXShop markerred 0.3
defaults write TeXShop commandred 1.0
defaults write TeXShop commandgreen 0.5
defaults write TeXShop commandblue 0.2

As you can see, there are three types of syntax that are highlighted:

  • Comments
  • Markers
  • Commands

I’ve modified that colours so that comments are a light grey, markers a light green, and commands orange so that they stand out more clearly against the black background.

TeX source optimised

TeX source with dark background with higher contrast syntax highlighting

If you prefer different colours, each syntax type has three options to specify, each corresponding to a line of code:

  • Blue
  • Green
  • Red

They are like traditional rgb, except you specify them as a fraction between 0 and 1.0, where 1.0 is equivalent to 255 in traditional notation. You can therefore control the rgb parameters for each syntax type, using the codes above as a template, and make source editing with a dark background much easier to read.