[✓] Cell tag containing a comma?

GROUPS:
 Imre Pázsit 1 Vote Is there a way to define a cell tag which contains a comma, so that the comma remains part of the cell tag, and not a separator which divides the tag into two different tags? The reason for the question is that in an article text I want to make references to the items in the bibliography/list of referenfces as hyperlinks which point to the corresponding items in the list of references. One can get the hyperlink into the text by clicking on the tag name. Now my references are in Harvard style, so the citation should be in the text something like "(Wolfram, 2017)". However, if I specify the cell tag as "(Wolfram, 2017)", then it becomes two tags, one is "(Wolfram" and the other "2017"). Thus, to get the citation into the text as a hyperlink, I need to create two hyperlinks, and connect them with a comma. I tried to embed the cell tag with the comma between citation marks, curly brackets, to precede the comma with a backslash etc., but nothing helped. Is there a way to get around this???
7 months ago
4 Replies
 Michael Rogers 3 Votes I don't know how to do it with the cell tags dialog, but you can add the option CellTags->{"(Wolfram, 2017)"} directly to a cell by editing the cell expression (menu Cell > Show Expression). Try it on a temp notebook first. If you accidentally mess up the editing, it can ruin the cell.The option CellTags does not seem to be available in the option inspector (menu Format > Option Inspector...).The only other way I can think of is to programmatically alter the cell in the notebook expression. For instance, write your own cell tag dialog. But that seems like it could be complicated.
 Michael Rogers 1 Vote No, I don't know of an easy way. I've done something like the following before to create random homework assignments from a template (before there was NotebookTemplate): nb = NotebookGet[....]; newnb = NotebookPut[nb /. "oldtag" -> "newtag"] This would work if "oldtag" appears only in CellTags and the hyperlink Button in the notebook expression. Since the notebook expression is a complicated mess of cells, boxes, etc., this is both rare (well, depending on the string "oldtag") and hard to know in advance, which is more worrisome. This may be more robust, although I don't know the range of forms for ButtonData. There is another form for linking to a cell in another notebook (and for URLs). nb = NotebookGet[....]; newnb = NotebookPut[nb /. { HoldPattern[CellTags -> "oldtag"] -> CellTags -> "newtag", HoldPattern[CellTags -> {a___, "oldtag", b___}] :> CellTags -> {a, "newtag", b}, HoldPattern[ButtonData -> "oldtag"] -> ButtonData -> "newtag" }] This creates a new, untitled notebook, which you can then save, either by hand or with NotebookSave[].