I have a large number of Mathematica notebooks which contain study notes for different topics (as opposed to actual Mathematica Code).
I'm trying to develop some code to randomly pull parts of a given notebook into the current notebook ... to use as a kind of flashcard system for reviewing notes.
I've gotten this far:
SetDirectory["/Users/Bill/Desktop/Notebooks"];
nb = NotebookOpen[FindFile["chemistry.nb"], Visible -> False];
sections = NotebookLookup[nb, "CellExpression", Cell[___, "Section", ___]];
NotebookWrite[InputNotebook[], RandomChoice[sections]]
This small amount of code, when evaluated, will write to the current notebook a random section heading cell, from the notebook chemistry.nb
.
This is great ... but what I actually want to is write to the current notebook the section heading cell, and all the content cells beneath it (Subsections, Items, ItemParagraphs, Text, etc).
Does anyone know how to do this? There seems to be no built in documentation for NotebookLookup
, I only discovered it when I came across this file: http://www.mathematica-journal.com/issue/v9i2/contents/AuthorTools/AuthorTools.pdf
"NotebookLookup"
there are Functions likeNotebookFind
andNotebookLocate
but in your case its better to work withCellObjects
as I just recently learned. See my answer for details and dont forget to accept the answer if it solves your problem. Thanks $\endgroup$<<AuthorTools`
$\endgroup$