6
$\begingroup$

I sometimes need to print hard copies of my notebooks, but I really like having a background color to make the notebooks easier on my eyes. Is it possible to automatically remove the background color before sending to a printer? I couldn't find it on the options inspector. Thanks!

$\endgroup$

1 Answer 1

8
$\begingroup$

Printing uses the "Printout" screen environment. So, you can control this behavior automatically with a stylesheet. Something like:

SetOptions[
    EvaluationNotebook[],
    StyleDefinitions -> Notebook[
        {
        Cell[StyleData[StyleDefinitions->"Default.nb"]],
        Cell @ CellGroupData[
            {
            Cell[StyleData["Notebook"],Background->RGBColor[0.9, 1, 1]],
            Cell[StyleData["Notebook","Printout"],Background->None]
            },
            Open
        ]
        },
        StyleDefinitions->"PrivateStylesheetFormatting.nb"
    ]
]

ought to do it. Change the background as appropriate.

Check by toggling the ScreenEnvironment setting in the Format menu.

Addendum

If you want to make this change "permanent":

NotebookSave[
    Notebook[
        {
        Cell[StyleData[StyleDefinitions->"Default.nb"]],
        Cell @ CellGroupData[
            {
            Cell[StyleData["Notebook"],Background->RGBColor[0.9, 1, 1]],
            Cell[StyleData["Notebook","Printout"],Background->None]
            },
            Open
        ]
        },
        StyleDefinitions->"PrivateStylesheetFormatting.nb"
    ],
    FileNameJoin[
        {$UserBaseDirectory,"SystemFiles","FrontEnd","StyleSheets","Default.nb"}
    ]
]

and then the next time you open Mathematica you should see a blue screen. Just delete the file to return to the default behavior.

$\endgroup$
2
  • $\begingroup$ Beautiful. Thank you. Does this SetOptions[] method have a simple global implementation? $\endgroup$ Oct 9, 2018 at 18:36
  • $\begingroup$ @thejacksonjive You could save the stylesheet in FileNameJoin[{$UserBaseDirectory, "SystemFiles", "FrontEnd", "StyleSheets"}]. If it has the name "Default.nb", it should be the default style sheet used from then on. If it doesn't have the name "Default.nb", than you would need to change the DefaultStyleDefinitions option (use the option inspector or CurrentValue[$FrontEnd, DefaultStyleDefinitions] = name) to point to it. $\endgroup$
    – Carl Woll
    Oct 9, 2018 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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