I'm trying to change the CellLabel of Cells using

 SetOptions[Cell, CellLabel -> "test"]


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

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


1 Answer 1


To see what we are doing, use

SetOptions[EvaluationNotebook[], CellLabel -> True]


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.

  • $\begingroup$ 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! $\endgroup$
    – Gabriel
    Sep 9, 2013 at 9:08
  • $\begingroup$ @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. $\endgroup$ Sep 9, 2013 at 9:24
  • 1
    $\begingroup$ @ Jacob: sorry, I mistyped: I'm using NotebookRead! $\endgroup$
    – Gabriel
    Sep 9, 2013 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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