I love the way that Mathematica allows me to type in of formulas. It is really easy to type complicated expressions with shortcuts on the keyboard. It would be great if I could use Mathematica completely to publish my articles. The biggest reason I don't already do this is:

I can't find the proper tutorial for styling notebooks for PDF export. How is it possible to deal with page numbering, headers, footers, page breaks, or placing graphs in specific positions, instead of being limited to line by line text? Is this possible? I believe it is -- I'm fascinated with Mathematica's capabilities, but I don't yet have the skills to take advantage of all the features it offers.

If someone would write tutorial on styling notebooks, formatting, and exporting to PDF, I believe that it would be appreciated by many others. I have seen some texts where it's emphasized that they are written totally in Mathematica (and they are really styled well).

Thank you for any tips, ways of accomplishing these tasks and for sharing your experience.

  • $\begingroup$ Did you know you can export formulas to LaTeX? $\endgroup$
    – CHM
    Aug 14, 2012 at 22:11
  • $\begingroup$ Yes I know that, and that's what I do. But I think if MMA have this options adjustable life would be much easier. Not to take formula by formula and import them in your designing software (InDesign, Quarkxpress...) $\endgroup$
    – balboa
    Aug 14, 2012 at 22:18
  • $\begingroup$ Which Latex editor do you use? $\endgroup$
    – balboa
    Aug 14, 2012 at 22:26
  • $\begingroup$ As for LaTeX, I also used Scientific Word (expensive) but upgrade costs eventually caused me to move to using Lyx (free, and very good indeed) - BTW it also runs on OS X. For "live" documents the best approach seems to be Wolfram's CDF. $\endgroup$ Aug 14, 2012 at 23:05
  • 1
    $\begingroup$ You may look around items under File menu -> Printing Settings. btw I use Kile for LaTeX editor, it feels like programming and has both Linux version and Windows version. $\endgroup$
    – Silvia
    Aug 15, 2012 at 6:35

2 Answers 2


You can adjust page size, page number style, headers, footers, etc from items under File -> Printing Settings menu. Or you can programmatically modify them by manipulating Notebook's options: PrintingCopies, PrintingStartingPageNumber, PrintingPageRange, PageHeaderLines, PageFooterLines, PrintingOptions.

Mathematica graphics

Mathematica graphics

Note: It seems "PaperSize" and "PrintingMargins" are calculated using a DPI value of 72, which I guess is not the DPI of the monitor but that of the default printer.

Graphics, more generally, nearly any Cell expression, can be used in header and footer. One way is copy the entire Cell:

Mathematica graphics

then paste into the Headers and Footers palette:

Mathematica graphics

A Simple Program Example

A sample Notebook(Sorry I didn't find a convenient place to store large texts..):

notebookStr = Uncompress["1:eJztWI1u2zYQ7jvsBTgBA5LN9fRrWd1QoE3qNkOcBLbRYbCMmZYYm4hCGhKVJf\

nbcontent = notebookStr // ToExpression // InputForm;

Define a function for display the headers and footers setting:

HeaderFooterSettingView[nbcontent_] :=
    Cases[nbcontent, (hf -> expr_) :> expr, \[Infinity]] //
      If[# === {},
        {{None, None, None}, {None, None, None}},
        #[[1]]] & //
        Style[ToString[hf] <> " Settings:", 20],
           Map[If[# === None,
               Item[Spacer[20], Background -> LightBlue],
               Style[InputForm@#, 8]] &, #, {2}]\[Transpose],
           Item[#, Background -> LightYellow] & /@
            {"Right page", "Left Page"}
         Dividers -> {
           {False, Black, GrayLevel[.8], GrayLevel[.8]},
           2 -> Directive[Black, Thick]}]
        }] &] /@ {PageHeaders, PageFooters} //
  Column[#, Frame -> All, FrameStyle -> GrayLevel[.8]] &


enter image description here

Here the light-blue cells indicate empty slots for headers/footers.

Now we insert a Graphics at the right corner footer of right pages:

nbcontentNew = nbcontent /.
   (PageFooters -> expr_) :>
    (PageFooters -> ReplacePart[expr,
       {1, 3} ->
           Graphics[{Circle[], Inset[x^2 + y^2 == r^2, {0, 0}]},
            Frame -> True, ImageSize -> 100]

nbNew = nbcontentNew[[1]] // NotebookPut

NotebookPrint gave a terrible result on my computer, so I manually selected the virtual pdf printer from Print dialog in the File menu to print the generated Notebook:

enter image description here

  • $\begingroup$ Thank you Silvia, and now this is really useful. I don't get the Simple Program Example, but as I understand it's just way how to do upper part of answer, by code. Or is it? I mean the result is same or does this "code approach" add any new capabilities. (I'm asking this because I'm not MMA expert so it's not easy task for me to analyze this code, but if it's useful I certainly will). And once again thank you for your explanations. $\endgroup$
    – balboa
    Aug 15, 2012 at 19:12
  • $\begingroup$ @balboa You're welcome:) Sorry for the unclearness in my post. Yes I tried to demonstrate how to do similar thing programmatically. I think sometimes it may feel more flexible and explicit than using the GUI. $\endgroup$
    – Silvia
    Aug 16, 2012 at 5:06
  • $\begingroup$ @balboa In case you care about only how to specify the headers and footers, it's safe to skip the HeaderFooterSettingView function, concern only the code which converts nbcontent to nbcontentNew. $\endgroup$
    – Silvia
    Aug 16, 2012 at 5:15

It is easier to create a notebook object and set options. For example, if I want a PDF with some plots and an equation and save it as a PDF in Landscape form (so its not cut off):

newbook = CreateDocument[{plot1, plot2, plot3, equations1}]

     PrintingOptions -> {"PaperOrientation" -> "Landscape"}]

Export[NotebookDirectory[] ~~ "myfile.pdf", newbook]

(The export command puts the new PDF in the same directory as the notebook with all theses commands.) You can get any number of notebook options by going to the "Format->option inspector" choose your notebook, find the option you want, change it, then view as text or do a


and see what option was added (and do a copy and paste)

Once you determine what options you want, you can programmatically set all aspects of the new notebook (Headers, Footers, etc.) and then save it as a PDF. I think this is the easiest approach to doing this.


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.