Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

1 Answer 1

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
2  
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

Your Answer

 
discard

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.