A similar question has been asked before, with no answers. I would love to have a way to easily reference objects associated with counters. To provide such a capability for things like figures, tables, etc., it would be great if it was possible to automatically create tags as part of a Stylesheet definition. Can this be done?
For example, I have a Stylesheet definition for my figure captions that reads like this:
Cell[StyleData["FigureCaption", StyleDefinitions -> StyleData["SmallText"]],
TextAlignment->Center,
TextJustification->0.,
CounterIncrements->"Figure",
MenuSortingValue->10000,
FontFamily->"Source Sans Pro",
FontSize->12,
FontWeight->"Plain",
FontSlant->"Plain",
FontVariations->{"StrikeThrough"->False,
"Underline"->False},
FontProperties->{"ScreenResolution"->Automatic}]
Is it possible to add to this some code that will automatically create a tag of the form, say, "figctr
", where ctr
would be the value of the counter associated with the caption?
CLARIFICATION: Suppose I have a document that includes many FigureCaption cells that reference the counter above. Is it possible to programmatically create CellTags that reference the current value of the counter on each of these cells?
For example, I would like the 5th FigureCaption cell in notebook to have the CellTag "fig'ctr'", where 'ctr' is 5.
I use CellTags for navigation in a lecture notebook. It would very helpful to have the ability to add and delete FigureCaption cells in the notebook and then have some code that would update the cell tags to their appropriate values. Here is a related question I asked.
Note: As outlined in my comment, updating cell tags after having inserted more figures cannot be done in isolation: If we update the tags, the question comes up as to what happens to links after you edit the notebook. The part that's problematic about this is of course not the updating of the CellTags, but the fact that if we simply update the tags so they correspond to the counters, then existing references will point to the wrong cells. This means that we also need to search for and update the references to all of the tags.
CellTags
? $\endgroup$