5
$\begingroup$

I have a stylesheet that works as expected in Mathematica 8. It does not work as expected in Mathematica 9.

In the stylesheet I have set FontColor to RGBColor[0.501961, 0, 0] for ItemParagraph. DisplayFormula and InlineFormula have FontColor set to Automatic (I've also tried Inherited).

When I press Ctrl+( to start a formula from within an ItemParagraph the color is the same as for my Text cell (black). The FontColor option for Text is Automatic.

Interesting behavior. When I type EscinttEsc the font color is RGBColor[0.501961, 0, 0] and it creates an inline formula region (or is it displayformula?). When I type Ctrl+/ it creates an inline formula region but the color is black.

I have both Mathematica 8 and Mathematica 9 installed and the behavior does not exist on Mathematica 8.

$\endgroup$
5
  • $\begingroup$ I don't have 9 installed but there has been some discussions about the default stylesheet changing in 9. I'd guess that this change is the source of the problem. $\endgroup$ Dec 18, 2012 at 1:00
  • $\begingroup$ That's certainly possibly the reason for the behavior. Any ideas on what I would change in the Defaul.nb? $\endgroup$
    – user246
    Dec 18, 2012 at 1:02
  • $\begingroup$ Unfortunately no because I do not know what changes were made to the default style in 9. However you could try making your style sheet inherit from Default_8.nb instead of Default.nb. I believe -- stand corrected -- that in 9 Default_8.nb is the V8 default stylesheet. $\endgroup$ Dec 18, 2012 at 1:05
  • $\begingroup$ I can't reproduce the behavior you described in V9. The color of the InlineFormula in an ItemParagraph cell is the same with the stylesheet setting (RGBColor[0.501961, 0, 0]). $\endgroup$
    – Silvia
    Dec 19, 2012 at 3:28
  • $\begingroup$ What about for DisplayFormula? InlineFormula should work since in Default.nb it's font color is set to Automatic. I'm not sure what the difference between DisplayFormula and InlineFormula are. $\endgroup$
    – user246
    Dec 20, 2012 at 0:02

2 Answers 2

6
$\begingroup$

The problem you've been having trying to override this is that style inheritance is additive by default. You can change an option setting like FontColor, but what you can't do (easily) is to modify the style to be just like the original one, but as if there were no FontColor setting at all.

Inherited doesn't work because it just tells the style cell to look at the style that it's inheriting from. Automatic doesn't work because, for purposes of foreground color options, Automatic is synonymous with RGBColor[0, 0, 0, 0].

You could copy it, though. So here's the original DisplayFormula style as it exists in v9:

(*In*) CurrentValue[{StyleDefinitions, "DisplayFormula"}]

(*Out*) {CellMargins -> {{66, Inherited}, {Inherited, Inherited}}, 
 StripStyleOnPaste -> True, 
 DefaultFormatType -> DefaultInputFormatType, 
 "HyphenationOptionsHyphenationCharacter" -> "\[Continuation]", 
 LanguageCategory -> "Formula", ScriptLevel -> 0, 
 SingleLetterItalics -> True, MenuSortingValue -> 1700, 
 FontFamily -> "Arial", FontSize -> 14, FontColor -> GrayLevel[0.2], 
 UnderoverscriptBoxOptionsLimitsPositioning -> True}

What we want is exactly that style, but as if FontColor had never been set. We could synthesize a new style cell by selective copy/paste/typing, but let's write a program to do it. That's more fun. :)

Run this code in a notebook whose stylesheet if Default.nb (not your customized version).

NotebookWrite[EvaluationNotebook[], 
 FlattenAt[
  Cell[StyleData["DisplayFormula", StyleDefinitions -> None], 
   DeleteCases[CurrentValue[{StyleDefinitions, "DisplayFormula"}], 
    FontColor -> _]],
  2]]

Working our way from the inside out, we start with the current definition of DisplayFormula. We strip the FontColor setting using DeleteCases. We put it in a StyleData cell with StyleDefinitions -> None. This tells the FE that, for purposes of style inheritance, this style cell should not be merged with any parent style at all. Finally, we flatten the list into a sequence, which now gives us a proper cell expression to write into the notebook.

From there, copy and paste it into your custom stylesheet and you're golden.

$\endgroup$
2
$\begingroup$

In Mathematica 8 Default.nb has the FontColor option in DisplayFormula set to Automatic. In Mathematica 9 this is set to GrayLevel[0.2]. I have not figured out a way to change this to Automatic but this is the reason for the strange behavior.

$\endgroup$
2
  • $\begingroup$ (+1) Does this work: CurrentValue[{StyleDefinitions, "DisplayFormula", "FontColor"}] = Automatic? $\endgroup$
    – kglr
    Dec 18, 2012 at 7:26
  • $\begingroup$ No. In the local definitions for FontColor for DisplayFormula I can set it to the color I want but this is over ridden by Default.nb. My stylesheet inherits from Default.nb. This appears to be a bug in Mathematica 9. $\endgroup$
    – user246
    Dec 18, 2012 at 15:45

Your Answer

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