2
$\begingroup$

I have successfully created the meta data "Calculus I" for a notebook by executing the following code in the notebook.

SetOptions[InputNotebook[], 
 TaggingRules -> {"meta" -> {"Calculus I"}}]

I then placed the following in my private stylesheet for that notebook.

PageHeaders -> {{CurrentValue[
    InputNotebook[], {TaggingRules, "meta"}], None, 
   None}, {CurrentValue[InputNotebook[], {TaggingRules, "meta"}], 
   None, None}}

I am somewhat comfortable with Page Headers, but I'm not sure what I am doing wrong here. For some reason, the header does not appear on any of the pages when I go to print preview. Can you tell me what I am doing wrong here?

$\endgroup$
  • $\begingroup$ Okay, quick question, Let's say you add filler to your test notebook so that you have 2 pages on your print preview, is the header on the second page? $\endgroup$ – user6014 Oct 29 '16 at 2:50
  • $\begingroup$ No it is not. I made sure to check this. $\endgroup$ – Michael McCain Nov 1 '16 at 18:30
1
+50
$\begingroup$

I hope this will help. With the following I had the page headers you were looking for on all pages:

SetOptions[EvaluationNotebook[], 
 PrintingOptions -> {"FirstPageHeader" -> True}, 
 PageHeaders -> {{CurrentValue[
     EvaluationNotebook[], {TaggingRules, "meta"}], None, 
    None}, {CurrentValue[InputNotebook[], {TaggingRules, "meta"}], 
    None, None}}]

My initial guess is that your "FirstPageHeader" option was set to false and you weren't seeing what you were looking for, although I admit that I did not go so far as to try to incorporate the above into a stylesheet, so I cannot speak to whether or not it works in that setting. But perhaps the above will help you find the solution you were looking for. Let me know if you have further questions :)

$\endgroup$
  • $\begingroup$ Thank you. Your answer works by using an alternate method to style sheets. I didn't specifically ask to use the style sheet method so I'll award all points. However, I meant to ask specifically for the style sheet method as this is what I reallly need. Oops. I'm not sure why, but I can't get it to work using the code above. Any ideas? $\endgroup$ – Michael McCain Nov 1 '16 at 18:36
  • 1
    $\begingroup$ Can you describe how it doesn't work? If I evaluate SetOptions[InputNotebook[], TaggingRules -> {"meta" -> {"Calculus I"}}] followed by the above code in a fresh notebook, and then go to Print Preview, I reliably have "Calculus 1" on the top of the page. How is it not working for you? $\endgroup$ – user6014 Nov 1 '16 at 19:32
  • $\begingroup$ Thank you. Your SetOptions method which sets the page header option works great. However, I would like to achieve the same result by using the different method of applying a private stylesheet containing the page header option to the notebook. The stylesheet page header option in my post works without "current value" but when I include it, the functionality breaks. $\endgroup$ – Michael McCain Nov 1 '16 at 19:49
  • $\begingroup$ I think there should be a way to make this work. I can include counters in stylesheets which are a current value... so I think there should be a way to pull in current values of different types like meta data. I think it has something to do with how Mathematica handles headers. Does this make sense? $\endgroup$ – Michael McCain Nov 1 '16 at 19:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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