2
$\begingroup$

For input cells and output cells, there are automatic,natural numbering.

In[1] 2+2
Out[1] 4

I mean In[1] and Out[1].

For text cell, there is no automatic numbering, and I do not know how to give it.

I make a text cell by mouse right click - insert new cell - text.

Q1) Numbering possible for text cell ?
Q2) automatic numbering possible?

$\endgroup$

1 Answer 1

1
$\begingroup$

The 'labels' for input and output are generated upon evaluation by the kernel and are not notebook specific. I do not think that this is what OP is after with text cells (I might be wrong). I would assume the question is about notebook/cell specific CellFrameLabels like the ones used by DisplayFormulaNumbered. An alternative approach I will not discuss here would be to set CellLabel manually (this is done for Input and Output cells automatically by the kernel/frontend).

Regarding Q1: I am not sure how to archive this but it might be possible to set CellFrameLabels manually.

I have however an answer for Q2: one can archive this quite easily be replicating the the cell style of DisplayFormulaNumbered. Here is an example for a style definition TextCellNumbered inheriting from Text and using a counter similar to the one used by DisplayFormulaNumbered:

Cell[StyleData["TextCellNumbered", StyleDefinitions -> StyleData["Text"]],
   MenuSortingValue->1401,
   CounterIncrements->"TextCellNumbered",
   CellFrameLabels->{{None,Cell[TextData[{"(",CounterBox["TextCellNumbered"],")"}],"TextCellNumber"]}, {None, None}}
]

If one places this into a style sheet or embedded notebook style definitions (The simplest way to do so is to use the menu "Format->Edit Stylesheet", then use "Customize Inherited Style" or "Add a New Style" to create a Cell in the style sheet and then mark the cell and use STR+SHIFT+E or the menu "Cell->Show Expression" to edit/paste the code given above directly into the cell expression. To apply the edited changes to the cell revert "Cell->Show Expression") one can use TextCellNumbered to get something like

Numbered Text

Some possible extensions and improvements could involve: assigning a MenuCommandKey to this style to insert it with a shortcut (ALT+Number) or to change the appearance/style of the label in CellFrameLabels with other brackets or to include the chapter number in the label with CounterBox["Chapter"] (and setting CounterAssignments->{{"TextCellNumbered", 0}} in the style for Chapter).

$\endgroup$
1
  • $\begingroup$ ((("Format->Edit Stylesheet", then use Customize Inherited Style or Add a New Style))) <- where is Customize Inherited Style or Add a New Style? My version is v12.2 $\endgroup$
    – imida k
    Commented May 2, 2022 at 13:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.