I'm in the process of creating a notebook that contains a style to write documents. I would like Mathematica to behave similar to LaTeX in the sense that when I write a "Definition"
cell then it will write "Definition [Chapter#].[Definition#]"
.
To see what I mean do the following. In an empty notebook create a cell and modify the style to "Chapter"
. You can do this by selecting the cell and the going to Format->Style->Other
, enter "Chapter"
.
Now go to Format->Edit StyleSheet...
. Enter Chapter
in the input box. This will generate a cell labeled Chapter. Select that cell, and click on Cell->Show Expression
. At this point select all that text that you see there and replace it with the following:
Cell[StyleData["Chapter"],
CellFrame->{{0, 0}, {0, 0}},
ShowCellBracket->Automatic,
CellMargins->{{42, 27}, {10, 30}},
CounterIncrements->"Chapter",
CounterAssignments->{{"Section", 0}, {"Definition", 0}},
FontFamily->"Verdana",
FontSize->24,
FontWeight->"Bold",
CellFrameLabels->{{
Cell[
TextData[{
"Chapter ",
CounterBox["Chapter"]
}], "ChapterLabel", CellBaseline -> Baseline], Inherited}, {
Inherited, Inherited}},
FontColor->RGBColor[0.641154, 0.223011, 0.0623026]]
This will change the style of how a chapter cell is displayed. I changed the color and font. The most important thing to me is the CellFrameLabels
. Noticed that I have made it so that every time you create a chapter cell it will display: Chapter [Chapter Number]
.
In the picture above I have created several chapter cells and I have added the text: ": Title of Chapter #"
.
This is simple enough, we can create any cell, apply a definition and take advantange of counters to label the cells.
I have noticed how some books have definitions enclosed in box. So in this case I would like to create a box that contains Definition
. Here is my lame attempt with the definition of the cell "Definition"
.
Cell[StyleData["Definition"],
CellFrame->{{0, 0}, {0, 2}},
ShowCellBracket->Automatic,
CellMargins->{{27, 27}, {0, 8}},
PageBreakWithin->False,
CellFrameMargins->16,
CellFrameColor->RGBColor[0.641154, 0.223011, 0.0623026],
Background->RGBColor[0.963821, 0.927581, 0.844465],
FontFamily->"Verdana",
CounterIncrements->"Definition",
FontSize->12,
CellFrameLabels->{{
Cell[
TextData[{
"Definition ",
CounterBox["Chapter"], ".",
CounterBox["Definition"]
}], "DefinitionLabel", CellBaseline -> Baseline], Inherited}, {
Inherited, Inherited}},
]
Here is how it looks in the notebook:
Here is the question: Is there a way to make the CellFrameLabels
part of the cell? I want the label to have the same background and to be inline with the other text. Here is a screen shot of how I want it to look:
I have made the "label" bold font and blue. This is something that the user should not be able to modify.