Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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). – R. M. Apr 2 '13 at 17:05
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. – R. M. Apr 2 '13 at 17:05
@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. – Leonid Shifrin Apr 2 '13 at 17:09
@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) – R. M. Apr 2 '13 at 17:13
@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 :). – Leonid Shifrin Apr 2 '13 at 17:17
up vote 15 down vote accepted

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]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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