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!


1 Answer 1


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"}
  • $\begingroup$ @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 :) $\endgroup$
    – Kuba
    Commented Sep 14, 2013 at 11:39
  • $\begingroup$ Ok, good point! $\endgroup$
    – Gabriel
    Commented Sep 14, 2013 at 12:04
  • 2
    $\begingroup$ 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. $\endgroup$
    – John Fultz
    Commented Sep 14, 2013 at 17:01
  • $\begingroup$ 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? $\endgroup$
    – bobknight
    Commented Nov 12, 2014 at 6:53

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.