From the Wolfram documentation, I understand that a cell dingbat (circle, square, …) is aligned with the first line in the cell (which makes sense for creating bullet points, for example).
I want to create a cell dingbat that contains text and I want to control the vertical alignment of the text in that cell. Here is the code I have so far:
This produces the dingbat with text still aligned with the first line in the cell:
I have tried numerous things, including setting the CellBaseline and adjusting the CellFrameMargins, but I can’t get the “Ex. 1” text to have more space between it and the top of the CellFrame. Note: I want to keep the current frame for the dingbat cell exactly as is (I want it aligned with the top of the main text in the cell), so increasing the CellFrameMargin for the TextCell is not a desired workaround.
Can someone explain how to achieve this spacing? Thanks.
I am not sure this code satisfies your desires that are somewhat unclear, but may be it will serve as a starting point to overcome the difficulty…
CellPrint[
TextCell["Some text for my cell Some text for my cell Some text for \
my cell Some text for my cell Some text for my cell Some text for my \
cell Some text for my cell Some text for my cell Some text for my \
cell Some text for my cell Some text for my cell Some text for my \
cell Some text for my cell Some text for my cell Some text for my \
cell Some text for my cell Some text for my cell Some text for my \
cell Some text for my cell Some text for my cell Some text for my \
cell ", CellDingbat ->
Cell[Column[{"Example 1.", "Vertical", "Alignment"}],
CellSize -> {80, 60}, CellFrame -> True,
CellMargins -> {{0, 0}, {0, 10}},
CellFrameMargins -> {{10, 0}, {0, 0}}, TextAlignment -> Left,
FontSlant -> Italic, FontWeight -> Bold,
Background -> GrayLevel[.9]], CellMargins -> {{400, 600}, {4, 4}},
CellChangeTimes -> {{3, 3}}]]
It’s close to a solution because it does put space between “Example 1.” and the top frame of the CellDingbat. However to achieve that, it seems you used:
CellMargins -> {{400, 600}, {4, 4}}
for the main cell that contains the CellDingBat cell. As you can see in your image, this causes the “Some text for…” to no longer to be aligned with the CellDingbat frame, which is reall what I want to achieve.
Another way of stating what I’m trying to do is no longer force “Example 1.” to be aligned with the first line of “Some text for my…”; that is, I want “Example 1.” to be lower than the first line of “Some text for my…”.
CellPrint[
TextCell[“Some text for my cell Some text for my cell Some text for
my cell Some text for my cell Some text for my cell Some text for my
cell Some text for my cell Some text for my cell Some text for my
cell Some text for my cell Some text for my cell Some text for my
cell Some text for my cell Some text for my cell Some text for my
cell Some text for my cell Some text for my cell Some text for my
cell Some text for my cell Some text for my cell Some text for my
cell “, CellDingbat →
Cell[Column[{””, “Example 1.”, “Vertical”, “Alignment”}],
CellSize → {80, 60}, CellFrame → True,
CellMargins → {{0, 0}, {0, 10}},
CellFrameMargins → {{10, 0}, {0, -20}}, TextAlignment → Left,
FontSlant → Italic, FontWeight → Bold,
Background → GrayLevel[.9]], CellMargins → {{400, 600}, {4, 4}},
CellChangeTimes → {{3, 3}}]]
This doesn’t have the top of the CellDingbat Cell aligned with the first line of text, so it doesn’t quite achieve what I’m looking for. I think the solution, which I will attempt later, is to nest a second cell (that contains the “Example” text) inside the main CellDingbat cell that has the frame and the gray background. The cell margins of that inner cell can be then used to position the text.
I have not yet found a solution, but here is a graphic that illustrates what I’m trying to achieve:
The best workaround I’ve managed is to adapt Valeriu’s code as shown below. It’s not a complete solution because there is no control over the vertical spacing (it’s fixed because it’s a blank line):
Not sure why CellFrameMargins don’t do the trick (it works for the left margin but not the top margin)I guess it has something to do with the way Mathematica has implemented the CellDingBat.