Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6528455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:32:10+00:00 2026-05-25T09:32:10+00:00

I’m in the process of creating a notebook that contains a style to write

  • 0

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].

Chapter

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:

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:

Desired Output

I have made the “label” bold font and blue. This is something that the user should not be able to modify.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:32:10+00:00Added an answer on May 25, 2026 at 9:32 am

    I don’t think that it’s possible to do in the way you want. CellLabels can only be text, while both CellDingbat and CellFrameLabels can be arbitrary cell expressions.

    Both CellDingbat -> ... and CellFrameLabels -> {{...,None},{None,None}} work if the cell is only a single line long. But do not automatically resize for multiple line cells (at least as far as I could tell). For example:

    Cell["Abcdefg", "Text",
     CellFrame->{{0, 1}, {0, 2}},
     CellMargins->{{30, 24}, {6, 6}},
     CellFrameMargins->0,
     CellFrameColor->RGBColor[0, 0, 1],
     CellFrameLabels->{{Cell[" Definition 1.1  ", "Text", 
       CellFrame -> {{2, 0}, {0, 2}}, CellFrameMargins -> 0], None}, {None, None}},
     CellFrameLabelMargins->0,
     Background->RGBColor[0, 1, 1]]
    

    cellframelabel on left

    Putting a CellFrameLabel on the top does not have this problem, but I don’t know how to align it to the left…

    Cell["Abcde", "Text",
     CellFrame->{{1, 1}, {0, 2}},
     CellMargins->{{30, 24}, {6, 6}},
     CellFrameMargins->0,
     CellFrameColor->RGBColor[0, 0, 1],
     CellFrameLabels->{{None, None}, {None, 
        Cell[" Definition 1.1 ", "Text", 
         CellFrame -> {{2, 2}, {0, 2}}, CellFrameMargins -> 0]}},
     CellFrameLabelMargins->0,
     Background->RGBColor[0, 1, 1]]
    

    cellframelabel at top

    I think that maybe the best looking solution would be to include the “Definition ch.def:” in the cell contents.

    Cell[TextData[{
     Cell["Definition 1.1:   ", Editable->False, Selectable->False, Deletable->False],
     "Abcdefg"}], "Text",
     CellFrame->{{1, 1}, {0, 2}},
     CellMargins->{{30, 24}, {6, 6}},
     CellFrameColor->RGBColor[0, 0, 1],
     Background->RGBColor[0, 1, 1]]
    

    from above

    Make it so that it’s not deletable by the average user and it is probably almost as good as a cell(frame)label. It can include counters so that it automatically shows the correct numbering. The only problem is that it does not appear automatically, but if you just copy a pre-existing cell, then that’s not too much of a problem.


    Edit: Adding an input alias that creates the non-deletable counter

    First we get the current input aliases,

    oldAliases = InputAliases /. Options[EvaluationNotebook[], InputAliases];
    

    then replace any existing alias EscdefEsc with our new one:

    newAliases = 
      Append[DeleteCases[oldAliases, "def" -> _], 
       "def" -> Cell[TextData[
         RowBox[StyleBox[#, FontWeight->"Bold", FontColor->Blue]&/@{"Definition ", 
          CounterBox["Chapter"], ".", CounterBox["Definition"], ":   "}]],(*"Text",*)
         Editable -> False, Selectable -> False, Deletable -> False]];  
    SetOptions[EvaluationNotebook[], InputAliases -> newAliases]
    

    Since I don’t have your style sheet, I need to set a couple of counters:

    CellPrint[Cell["Setting the counters", "Text", 
      CounterAssignments -> {{"Chapter", 2}, {"Definition", 3}}]]
    

    Now I can use the alias in an existing cell – it inherits the styling of the parent cell (unless otherwise specified):

    add defn


    Another option is to make a palette to go with your stylesheet. This would be useful since there’s only a limited number of MenuCommandKey values that you can use for your new styles (n.b. overwriting the default ones will just confuse people). See this answer for an example of such a palette.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.