I am preparing lecture notes in Mathematica for students, which consist of several tens of notebooks. From time to time I face a necessity in one notebook to give a reference to some formula of another notebook. The formula in such a case is given in a DisplayFormulaNumbered
cell, and this cell is tagged.
Now comes my question.
How can I programmatically open the notebook with the formula, such that this cell will be on the screen, possibly, selected, and ready to be seen by the reader?
I will then package this code into a button to put it at the reference, ready to open and look. The best solution would be, if the all CellGroups
existing in the document would be collapsed, except for the one containing the tagged cell in question.
To be specific, and to enable one to try, here is a code creating a notebook with three groups of Section/TextCell/TextCell/DisplayFormulaNumberedCell
. The cells with the formula are tagged by "L1", "L2"
and "L3"
correspondingly:
nb = CreateDocument[{CellGroup[{TextCell["The head1", "Section"],
TextCell["First text cell"], TextCell["Second text cell"],
TextCell["x+y", "DisplayFormulaNumbered", CellTags -> {"L1"}]}],
CellGroup[{TextCell["The head2", "Section"],
TextCell["First text cell"], TextCell["Second text cell"],
TextCell["a+b", "DisplayFormulaNumbered", CellTags -> {"L2"}]}],
CellGroup[{TextCell["The head3", "Section"],
TextCell["First text cell"], TextCell["Second text cell"],
TextCell["u/v", "DisplayFormulaNumbered", CellTags -> {"L3"}]}]
}]
Let us try, say, to open it programmatically from another notebook with the "L2"
cell selected, while the CellGroups
which do not contain "L2"
- collapsed.
nb = NotebookOpen["filePath"];
in front of your code to complete it. Why do not you formulate it as a regular answer? $\endgroup$