I am creating multiple notebooks for a textbook that I would like to print with headers on every page. For example,

Notebook 1: Chapter 1, Section 1, "Addition"

Notebook 2: Chapter 1, Section 2, "Subtraction"

Notebook 3: Chapter 2, Section 1, "Multiplication"

Notebook 4: Chapter 2, Section 2, "Division"

Notebook 5: Chapter 2, Section 3, "Extra Stuff" . . .

The headers for each notebook will contain the chapter number, section number and Heading Name as shown above. I understand how to work with headers and private stylesheets and counters. I do not need help with that.

I would like to know how to programmatically set and access meta data for each notebook. I want the meta data to contains numbers (chapter number and section number) and a string (Heading Name). Can I store hidden meta data in a notebook somehow? If so, how is this done and how can I access it once I've done it?

If I can do this, then I can use a private stylesheet to pull this hidden meta data in from the notebook to place in the headers. Any ideas of how to store meta data like this in a notebook?


1 Answer 1


You can use TaggingRules. Once you have set the metadata it is embedded in the notebook. It can be retrieved at any time using CurrentValue. If the meta data changes it can be reset. Only one meta data object can be set per notebook so separate items should be put in a list.

metadata = {1, 2, 3};

SetOptions[EvaluationNotebook[], TaggingRules -> {"meta" -> metadata}]

metadata = CurrentValue[{TaggingRules, "meta"}]
  • $\begingroup$ sorry, your answer needs some more explanation for me to understand it. He said chapter number and title. How would you call them in your structure inside, for example, a text cell? $\endgroup$
    – Nicholas G
    Commented Oct 25, 2016 at 11:34
  • $\begingroup$ @NicholasG I've only answered the question regarding how to store meta data in a notebook. You can put anything in the variable, metadata. The list {1, 2, 3} is just for example. $\endgroup$ Commented Oct 25, 2016 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.