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 6386947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:05:28+00:00 2026-05-25T03:05:28+00:00

This post derives from my question extending cell definition to cellframelabels . I’ve been

  • 0

This post derives from my question extending cell definition to cellframelabels. I’ve been playing around with CounterIncrements and I’m not obtaining what I’m expecting.

As Simon did in his answer to the post I mentioned we start by producing a counter.

CellPrint[Cell["Setting the counter", "Text", 
  CounterAssignments -> {{"MyCounter", 0}}]]

Now we print this counter.

CellPrint[Cell[
  TextData[RowBox[{"MyCounter ", CounterBox["MyCounter"]}]], "Text"]]

The result of this will be:

MyCounter 0

To increase the counter we can use the option CounterIncrements as follows:

CellPrint[Cell[TextData[RowBox[{"MyCounter ", CounterBox["MyCounter"]}]], 
 "Text", CounterIncrements -> "MyCounter"]]

This will give you:

MyCounter 1

You can enter that as many times as you want and you will see that the counter increases.

Since CounterIncrements is an option for a cell I said to myself: “Well, What if I make a cell within a cell and I set this option there?”. Since I’m making a cell with this option I would expect for the counter to increase. Does this happen?

CellPrint[
 Cell[TextData[
   RowBox[{"MyCounter ", CounterBox["MyCounter"], 
    Cell[TextData[RowBox[{"[InlineCell]"}]], "Text", 
  CounterIncrements -> "MyCounter"]}]], "Text"]]

The output is:

MyCounter 1[InlineCell]

I was expecting the output to be MyCounter 2[InlineCell] because I told the cell within the cell to increase the counter but it didn’t do it.

The documentation says that CounterIncrements “has not been fully integrated into the long-term Mathematica system, and is subject to change” but I think the Information there is somewhat misleading.

The reason I want this is so that I can define a style that increases a counter every time it is used. But this style will be used to a cell that is within another cell. Does someone have an idea about what is happening here? I’m using MMA8 in Mac OS X.

  • 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-25T03:05:29+00:00Added an answer on May 25, 2026 at 3:05 am

    My guess is that counters are only counted if they are in a proper (not inline) cell.
    This is fine, since inline cells are only really meant for formatting purposes and not for document structure.

    The counter increase works fine if you move it to the outer cell. Modifying your code above:

    CellPrint[Cell["Setting the counter to 0", "Text", 
      CounterAssignments -> {{"MyCounter", 0}}]]
    
    (* Prints a cell containing: Setting the counter to 0 *)
    
    CellPrint[Cell[
      TextData[RowBox[{"MyCounter ", CounterBox["MyCounter"], 
         Cell[TextData[RowBox[{"[InlineCell]"}]], "Text"]}]], "Text", 
      CounterIncrements -> "MyCounter"]]
    
    (* Prints a cell containing: MyCounter 1[InlineCell] *)
    

    Is this for something like your previous “Definition” style? If so, then why don’t you have the inline cell as a plain (unstyled) cell which inherits its style from the outer cell. Then just have the counter increment in the “Definition” style, i.e. in the stylesheet?
    As I said above, the non-inline cell should be the one which is styled (as a “Definition”, “Chapter”, “Section”, etc..), as that is the one that determines the document structure.


    Edit in response to comments:

    Here’s a palette that will create new chapter cells and new definition cells.
    The latter with the built-in, non-editable counter.
    Note that most of the styling should be moved into the stylesheet.

    CreatePalette[With[{nb = InputNotebook[]}, {
     Button["New Chapter", SelectionMove[nb, After, Cell];
      NotebookWrite[nb, Cell["New Chapter", "Chapter" (* Styling is in stylesheet*)]]],
     Button["New Definition", SelectionMove[nb, After, Cell];
      NotebookWrite[nb, Cell[TextData[RowBox[
       {Cell[TextData[
         StyleBox[#, FontWeight -> "Bold"] & /@ {
           "Definition ", CounterBox["Chapter"], ".", CounterBox["Definition"], ":  "}],
         Editable -> False, Selectable -> False, Deletable -> False],
         "New definition"}]], "Definition", CounterIncrements -> "Definition",
        CellFrame -> {{1, 1}, {0, 2}}, CellMargins -> {{30, 24}, {6, 6}}, 
        CellFrameColor -> RGBColor[0, 0, 1], Background -> RGBColor[0, 1, 1]]]
     ]}], WindowTitle -> "Document writing palette"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This post reference to the One Definition Rule. Wikipedia is pretty bad on explaining
This post asks this question but doesn't really give an answer, so I thought
This post started as a question on ServerFault ( https://serverfault.com/questions/131156/user-receiving-partial-downloads ) but I determined
From this post . One obvious problem is scalability/performance. What are the other problems
Before answering this question, understand that I am not asking how to create my
This is my first post, I'm new to this site, but I've been lurking
This post on SO answers most of the questions I have (much thanks to
This post relates to this: Add row to inlines dynamically in django admin Is
This post is incorrectly tagged 'send' since I cannot create new tags. I have
So this post talked about how to actually implement url rewriting in an ASP.NET

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.