Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm back with the labels and tags questions!

Here is my code:

mb = CreateDocument[Null, ShowCellTags -> True];

In the new document, I create a new cell, add some random code, and select the bracket of the cell. When I then process

SetOptions[NotebookSelection[mb], CellTags -> "tag test", 
 CellLabel -> "label test"]

I indeed see in the mb notebook the label and the label appear. Good. Now, I process the code (with the same selection: the cell bracket in the notebook mb)

Options[NotebookSelection[mb], {CellLabel, CellTags}]

and I get as output

 {CellLabel -> None, CellTags -> "tag test"}.

Why isn't the CellLabel showing up? I can't get my head around this one...

Thanks for all help, as always!

share|improve this question
up vote 2 down vote accepted

I do not full understand this behaviour but it seems that CellLabels are very sensitive on the lack of CellLabelAutoDelete->False.

So adding this is the fix.

mb = CreateDocument[Null, ShowCellTags -> True, CellLabelAutoDelete -> False];
SetOptions[NotebookSelection[mb], CellTags -> "tag test", CellLabel -> "label test"]

Options[NotebookSelection[mb], {CellLabel, CellTags}]
{CellLabel -> "label test", CellTags -> "tag test"}
share|improve this answer
@Gabriel well, I don't know what else can be said here but still it is good to hold on with the accept a little bit :) Maybe one can explain why the label is visible but not visible via Options. You can always upvote the answer you find useful :) – Kuba Sep 14 '13 at 11:39
Ok, good point! – Gabriel Sep 14 '13 at 12:04
This is exactly the issue. The way CellLabelAutoDelete works is that it prevents the CellLabel option from being serialized (either to disk or to MathLink). Internally, the Options code has significant overlap with the serialization code and, for better or worse, the decision on how to treat CellLabel is getting caught up in that. I won't necessarily defend this as the best and most correct way of doing things, but that's why it behaves the way it does. – John Fultz Sep 14 '13 at 17:01
I have the same issue, but even setting the options CellLabelAutoDelete->False, ShowCellTags->True, ShowCellLabel->True, at both notebook and cell's style levels, I still can't see the label on the cells having such style. Inside the stylesheet the cell label is shown, but not in the notebook. Does it means CellLabel cannot be used anymore? – bobknight Nov 12 '14 at 6:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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