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 trying to change the CellLabel of Cells using

 SetOptions[Cell, CellLabel -> "test"]

or

 SetOptions[NotebookRead[nb], CellLabel -> "test"]

if nb is the notebook, without success. How should this be done? Thanks, once again, for all help!

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

To see what we are doing, use

SetOptions[EvaluationNotebook[], CellLabel -> True]

Example:

Cell[BoxData[RowBox[{"1", "+", "2"}]], "Input", 
  CellLabel -> "blabla"] // CellPrint

This should print a cell, such that you can see its label to the left of the cell.

Anyway, we can now do

SetOptions[#, CellLabel -> "test"] & /@ Cells[]

giving all Cells CellLabel test.

share|improve this answer
    
Thanks a lot for your help. I am now trying to the following: Do[( NotebookWrite[nb, listOfCells[[i]]]; SetOptions[listOfCells[i],CellLabel->"blabla"; ), {i, Length[listOfCells]} ] where listOfCells is a list of cells read earlier from another document using DocumentRead[]. So, I'd like to add labels only in the new document, but not in the document from which these list of cells are read. How is this possible? Thanks! –  Gabriel Sep 9 '13 at 9:08
    
@Gabriel no problem. Hm are you sure that you are using DocumentRead? I cannot find it in the docs. I think using NotebookWrite here is a bit tricky, as it does not always move the cursor in the right way. Instead of using SetOptions here, I suggest using something like Append, to set the option in the Cell expression. But maybe you should take care to remove any existing CellLabel option. Also I got $Failed a few times, maybe you should made it handle that case specially as well. Anyway, feel free to start a new Q&A about this :). Maybe I can then provide more details. –  Jacob Akkerboom Sep 9 '13 at 9:24
1  
@ Jacob: sorry, I mistyped: I'm using NotebookRead! –  Gabriel Sep 9 '13 at 9:28
add comment

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.