7
$\begingroup$

In Mathematica, when an option is specified multiple times with different values, the first one will take precedence. This works with Cell and Background:

CellPrint@Cell["asd", "Text", Background -> Red, Background -> Blue]

Mathematica graphics

However, with the CellLabel option, the last one seems to take precedence. This is unique and unusual. Is this a bug, or intentional? Is there any reason why it should be like this? Are there other options with such behaviour?

CellPrint@Cell["asd", "Text", CellLabel -> "one", CellLabel -> "two"]

Mathematica graphics

$\endgroup$
  • $\begingroup$ Wanted to test this but coudln't because I usually hav switched off CellLabels but where to switch them on again? It used to be in the Preferences (like so) but it is not anymore. Where has that menu gone? $\endgroup$ – gwr Mar 25 '17 at 21:29
  • $\begingroup$ @gwr I am not sure, but I would try Option Inspector, Global Preferences (dropdown at top left), then search for ShowCellLabel. If it's False, set it to True. In 11.1, many options were removed from the Preferences GUI to simplify things. These are always retained in the Option Inspector, but may have a more technical name there. $\endgroup$ – Szabolcs Mar 25 '17 at 21:31
  • $\begingroup$ Thanks: SetOptions[EvaluationNotebook[], ShowCellLabel -> True] there we go. $\endgroup$ – gwr Mar 25 '17 at 21:38
  • 1
    $\begingroup$ Couldn't it be related to whether Association is used to represent large chunks of options internally: With Options usually a symbol is changed by a rule and therefore a later rule will not affect it anymore. With Association the last value given to a Key counts. $\endgroup$ – gwr Mar 25 '17 at 21:41
  • 1
    $\begingroup$ @gwr I don't think it is related to associations for two reasons: (1) It's the same in v9 (2) These options seem to be handled by the front end (not kernel), which probably doesn't know anything about associations. At first, I suspected that the front end is different from the kernel in that it always preserves the last (not first) option. But that is not the case as demonstrated with the Background option in the post. $\endgroup$ – Szabolcs Mar 26 '17 at 15:04

Your Answer

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

Browse other questions tagged or ask your own question.