# Continuous background color of adjacent cells

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.

• You can use the CellMargins option of Cell to do what you want. – Stephen Luttrell May 25 '15 at 19:42
• I'm not sure this answers my question... Could you perhaps give an example of the proper syntax? The documentation center doesn't quite address what I want to accomplish. – user170231 May 25 '15 at 21:15
• Cell["Hello", "Text", CellMargins->{{66, 10}, {0, 0}}, Background->RGBColor[0.87, 0.94, 1]] followed by Cell["World", "Text", CellMargins->{{66, 10}, {0, 0}}, Background->RGBColor[0.87, 0.94, 1]]. – Stephen Luttrell May 25 '15 at 22:13
• I achieved this result by typing Hello and World in 2 successive text cells, then I selected the cell brackets, opened the option inspector, then I altered the values displayed at Cell Options / Display Options / CellMargins. – Stephen Luttrell May 25 '15 at 22:17
• Ah perfect, thanks! I feel like there should be a more accessible way to accomplish this, perhaps through the Cell or Format toolbar. Fortunately, I only have to do this for a few cells (this time). – user170231 May 26 '15 at 0:50

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.