TransWikia.com

How to set a background color for a cell style via a command?

Mathematica Asked by AMA on June 23, 2021

I want to set different background colors for various cell styles (e.g. Section, Text), so that whenever I choose a specific style for some cell in the notebook, it automatically gets colored accordingly. Is this possible to do via evaluating a single simple command inside the notebook?

I’ve tried, for example, Cell[StyleData["Text"], Background -> Gray], but it doesn’t work at all. Is there a way to use SetOptions for this?

2 Answers

Undoubtedly, there are commands to specify background colors for Default styles, but I found creating Private Style Definitions to be easy and convenient. With an open notebook, open the Format menu and choose Edit Stylesheet ... to create

enter image description here

Then choose styles from the dropdown menu at the left and format them from the Format menu, in this case by choosing Background colors. For instance,

enter image description here

To save the result, choose Install Stylesheet at the right and follow the instructions. Then, close the notebook. In the future, when opening a notebook, open the Format menu, choose Stylesheet, and select the private stylesheet created earlier. Styles will have the backgrounds as defined, for instance.

enter image description here

Correct answer by bbgodfrey on June 23, 2021

you can use this command which makes the whole notebook light gray. But I don't know how to change the background of a single cell. SetOptions[EvaluationNotebook[], Background -> LightGray]

Answered by PooryWan on June 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP