I have a neurological disorder which causes me to have migraines if I look at a white computer screen. To combat this, I have put the following at the top of all of my Mathematica notebooks:

Background -> RGBColor[0.0, 0.0, 0.0],
FontColor -> RGBColor[1.0, 1.0, 1.0],
FontSize -> 16

This turns the background black and the letters white. However, Mathematica's built-in Syntax highlighting does not change. In order to read the Syntax Highlighing I have to manually go into:

In Edit -> Preferences -> Syntax Coloring -> Other:

  • Comments -> Megenta
  • Strings -> Light Yellow
  • Global -> Bright Blue

In Edit -> Preferences -> Syntax Coloring -> Local Variables;

  • The local variables of Module With -> Bright Green;
  • Function arguments and patter names -> Bright Green;
  • Variables made special by use in arguments -> Sky Blue;

The above commands permanently change the syntax highlighting. If possible, I would like to be able make the above changes in the Mathematica Notebook so that the changes only affect the notebook I am working in. So, my question is...

QUESTION: Rather than do the above steps manually, is there a command I can put at the top of the file that will make these changes for me?

  • 2
    $\begingroup$ You can create a stylesheet with your preferred colors and then apply it to individual notebooks (or set it for all notebooks). See my answer here that should show you the way. There's no one-step solution; there's some effort involved, but it'll be one time. I personally do most of my Mathematica programming in vim, which allows me to use my favourite theme (it looks like this). $\endgroup$
    – rm -rf
    Commented Apr 2, 2013 at 17:05
  • 1
    $\begingroup$ I also once made a half-complete port of the solarized theme to a Mathematica stylesheet. The nice thing about solarized (there are a few others like this) is that you can keep the colors the same and simply switch the background from light to dark and it still looks good. You can try downloading that and changing the background colors and text to suit your needs (if that theme is to your tastes). If I find some time later today, I'll perhaps do that, if you haven't done so yourself by then. $\endgroup$
    – rm -rf
    Commented Apr 2, 2013 at 17:05
  • 1
    $\begingroup$ @rm-rf You have a very nice color scheme, it seems. I have played with the color schemes in WB, but my current one is not as nice. $\endgroup$ Commented Apr 2, 2013 at 17:09
  • $\begingroup$ @LeonidShifrin That's the solarized dark palette (it's available for WB too), but the vim syntax highlighting (which is up-to-date for system functions in v9.0.1) is my own plugin and so are the choice of colors. I have the same in WB too, if you want it I can export my settings (I'll have to figure out how first), but I'm not sure if I can export just the colorscheme alone (lest the rest overrides yours) $\endgroup$
    – rm -rf
    Commented Apr 2, 2013 at 17:13
  • $\begingroup$ @rm-rf If you could export those, that would be nice. You do it by File -> Export -> General -> Preferences. Don't worry about exporting color settings only - I am used to work with the settings file, so I can figure out the color part on my own and update my settings. There is no hurry with this, anyway. Thanks :). $\endgroup$ Commented Apr 2, 2013 at 17:17

1 Answer 1


You can do this using the following code:

   {AutoStyleOptions, "UndefinedSymbolStyle"}] = {FontColor -> RGBColor[0.5`, 0.173`, 0.765`]}

More style options (other than "UndefinedSymbolStyle") that can be set are:

{"CommentStyle", "EmphasizedSyntaxErrorStyle", "ExcessArgumentStyle", 
"FormattingErrorStyle", "FunctionLocalVariableStyle", 
"FunctionNotebookStyle", "GlobalSymbolStyle", 
"GraphicsCompatibilityProblemStyle", "LocalScopeConflictStyle", 
"LocalVariableStyle", "MissingArgumentStyle", 
"MissingArgumentTemplateStyle", "MisspelledWordStyle", 
"NoKernelPresentStyle", "OrderOfEvaluationConflictStyle", 
"PatternVariableStyle", "StringStyle", "SymbolContextStyles", 
"SymbolShadowingStyle", "SyntaxErrorStyle", "UndefinedSymbolStyle", 
"UnknownOptionStyle", "UnwantedAssignmentStyle"}

You can check the current settings with:

Options[EvaluationNotebook[], AutoStyleOptions]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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