# How do I set the fonts for Input and Output in my stylesheet?

I'd like to change the font that Mathematica uses for output by setting the font of the corresponding style in my stylesheet; bit simply overriding the default Output style with

Cell[StyleData["Output"],FontFamily->"Open Sans",FontSize->12]


seems to have no effect.

Is there a way to do this that I'm missing? Is the style used for output something different?

Note that this is not a duplicate of "Set default font for Output", despite the title.

-
@Mr.Wizard: If I understand that, I've got to change StandardForm, but that changes both Input and Output. Is there no way to change just Output? (And what's the Output style for if it has no effect on output?) –  raxacoricofallapatorius Nov 13 '12 at 22:24
I just read those answers and I too am dissatisfied with them. There are some surprising limitations of the system ("Undo" cough) but this doesn't appear to be one of them as you can select an Output cell and change the font family. I don't know why it is set up this way. –  Mr.Wizard Nov 13 '12 at 22:30
The earlier question did not concern output styles. The reason you can't do this easily is because Core.nb defines DefaultFormatType -> DefaultOutputFormatType for the output style and this is the StandardForm. You can set DefaultFormatType to some other *Form and change that instead, because modifying StandardForm will also change the input sytle. –  rm -rf Nov 13 '12 at 23:18
@rm-rf I'm sorry, I now realize that is true. I know I have seen the recommendation/instruction to change StandardForm to effect change in "Output" (and "Input") before; that is what I am dissatisfied with. Sorry for unintentionally disparaging your answer! –  Mr.Wizard Nov 14 '12 at 0:05
@rax I notice that you did not Accept an answer to this question. Did you find that the method I suggested has problems or limitations? Is there an issue I can attempt to address to improve my answer? –  Mr.Wizard Aug 14 '14 at 16:36

After a bit of style sheet spelunking I believe I have a solution.

One reads in Core.nb under the FormatType Styles section:

The cells below define styles that are mixed in with the styles of most cells. If a cell's FormatType matches the name of one of the styles defined below, then that style is applied between the cell's style and its own options. This is particularly true of Input and Output.

From this it becomes clear why the styles one creates for Input and Output are not respected. That leads me to my proposed method. The template for the private style sheet is as follows:

Key in the options for the top cell, placed above the base definitions cell, is:

FontFamily -> Inherited


However one should start with the original definition from Core.nb and add/change FontFamily -> Inherited or important settings such as InputAutoReplacements will be lost. You can use this code to generate the complete Cell needed:

CellPrint @ Cell[StyleData["StandardForm"], ##] & @@
(CurrentValue[{"StyleDefinitions", "StandardForm"}] /.
(FontFamily -> _) :> (FontFamily -> Inherited))


(Evaluate this in a standard Notebook, then copy and paste the result at the very top of the Style Sheet.)

This changes the way that the "Input" and "Output" styles work. Now you create font style cells for both, e.g.:

Cell[StyleData["Input"],
FontFamily -> "Courier"
]

Cell[StyleData["Output"],
FontFamily -> "Trajan Pro"
]


And prestidigitonium!

-
To make this robust it will at least be necessary to consider any other styles that rely on StandardForm and also the different Screen and Printing Environments. –  Mr.Wizard Nov 14 '12 at 0:01
+1 brilliant. Had forgotten about the ordering of cells in stylesheets. –  Mike Honeychurch Nov 14 '12 at 0:11
Addendum: this doesn't operate with quite the mechanism that I first thought, but I believe it still works. However, the content of the first cell should be the entire definition for "StandardForm" from Core.nb except for the FontFamily line, rather than the stub shown in this answer. I'll revisit this tomorrow and do some more testing, then update the post. –  Mr.Wizard Nov 14 '12 at 1:58
I had only done some toy testing and didn't notice any issues with it. What led you to write the addendum? –  Mike Honeychurch Nov 14 '12 at 2:10
@Mike on my system I'm losing some of the proper formatting of e.g. Input cells with the simple code shown in the post. (Put another way, not only is the font reset but so is everything else.) I can't rule out that I've just made a mistake but I'm too sleepy to work through it now. –  Mr.Wizard Nov 14 '12 at 2:13

Not sure if there is a straight forward way but here is one way that works.

Edit the private styles of your notebook as per these grabs:

And now your output is Comic Sans :)

You can also:

SetOptions[EvaluationNotebook[],
CommonDefaultFormatTypes -> {"Output" -> OutputForm}]


but you still need to make your changes to the OutputForm style.

-
+1 for CommonDefaultFormatTypes which I either haven't learned or forgot, but I recommend you use a custom style e.g. "MyOutput" instead of OutputForm or you get the ugly 2D text formatting. –  Mr.Wizard Nov 13 '12 at 23:16
-1 for Comic Sans, +2 for a good solution. :) –  rcollyer Nov 13 '12 at 23:23
Hm... I see that my recommendation is not valid. That makes this answer significantly less useful IMHO unless there is another work-around to avoid the text-terminal 2D output. –  Mr.Wizard Nov 13 '12 at 23:23
@rcollyer I'm not sure it's really a solution (yet?); I don't think people want to have to use OutputForm -- at least I don't. –  Mr.Wizard Nov 13 '12 at 23:24
@Mr.Wizard correct me if I'm wrong, isn't OutputForm the default for output cells? –  rcollyer Nov 13 '12 at 23:25