I'm trying to make continuous blocks of cells so that their background colors are the same, but without breaks of white space between them.
E.g.
After some recent digging, I found the option "Show Expression", which converts the cell to its explicit contents that Mathematica can interpret. For example, the third cell in the image can be created by writing
CellPrint[
Cell["Can we make all",
"Text",
Background->RGBColor[0.87,0.94,1]
]
]
Showing the expression gives more information than I need, which I've omitted in this example. (Things like CellChangeTimes
and expression for symbols like the apostrophes. There was also an option specifying the grouping.)
I'm wondering if there's a simple way to use this code to my advantage so I can format the cells so that the line break between stays the same color.
I realize that with text, I can just start a new paragraph by hitting Return a few times, but I'm trying to include examples of Mathematica code for plots and the like.
Edit: Using Stephen's suggestion from the comments, I'm running into some minor issues with my graphics, as in the pic below. A quick fix is to add Background->White
where appropriate. The top cell shows what happens when this option is left out, and the bottom shows when it's applied to GraphicsRow
. Another has to be added elsewhere (in my case, to Pane
) to remove the blue frame.
Answer
Here's one possible way of doing this.
Type some text into 2 successive text cells, then select the cell brackets, open the option inspector (Format / Option Inspector ...) and alter the values displayed at Cell Options / Display Options / CellMargins.
For instance, if the 2 text items are "Hello" and "World", then the resulting Cell expressions might be (Cell / Show Expression)
Cell["Hello", "Text", CellMargins->{{66, 10}, {0, 0}},
Background->RGBColor[0.87, 0.94, 1]]
and
Cell["World", "Text", CellMargins->{{66, 10}, {0, 0}},
Background->RGBColor[0.87, 0.94, 1]]
where I have set the top and bottom margins both to be 0.
Comments
Post a Comment