I have a column consisting of strings and pictures, like this:

exp =  Column[{
          Style[ToString["\nInformation sheet\n"], Bold, Large],
          Style[ToString["\nPlots\n"], Italic],

but how can I export it such that it automatically inserts a page break after reaching the height of an A4, so that the exported PDF can be printed without hassle?

My own idea was to keep track of the cumulative height, and as soon as it reaches 294mm to create a new PDF and then merge them. *I used this approach and the answers below to get to the following solution, as good as it gets:

x = 1; y = x; l = Max[hs]; separated = {};

If[l <= a4y,

 While[y < Length[hs],

  While[Total[hs[[x ;; y]]] <= a4y,
   y = y + 1];
  AppendTo[separated, exp[[x ;; y - 1]]];
  x = y];

 AppendTo[separated, exp[[x ;; y]]];

 PrependTo[separated, {pre, mid1,
   meant1rhocol, mid2}];

pm = 72 {{0.5, 0.25}, {0.5, 0.3}};
cd = CreateDocument[
  Table[Column[separated[[file]], Alignment -> Left], {file, 
  "ShowPageBreaks" -> True,
  "PageSize" -> {0.5 a4x, a4y},
  "PaperSize" -> {a4x, a4y},
  ShowStringCharacters -> False,
  "PrintingMargins" -> pm,

  NotebookFileName -> "Lalala.nb"

Export[ "Lalala.pdf", 


where hs is a list of heights, a4y is the height of an A4, exp is a list of images/expressions to print, x and y are used for indexing and separated is a list of separated images*

Also, how large is the Large fontsize expressed in pts or mms? *EDIT: after some trial and error I found that for Fontsize, Small = 10 Smaller = Medium = 12 Larger = 16 Large = 24 *

  • 3
    $\begingroup$ This isn't really an answer, but it's all I can think of. I've never been happy with PDFs generated by Mathematica. You want to force the output to fit in A4 format, so go with LaTeX. You can export the figures as pdfs and use LaTeX to create the final document. You could even automate it, and have Mathematica generate and compile the TeX. $\endgroup$ – Jason B. Jul 14 '15 at 11:11
  • $\begingroup$ My workaround: Set up the output, print notebook and choose "save to PDF". Then the defaults for output are chosen (in my case A4 paper). $\endgroup$ – mgamer Jul 14 '15 at 21:04
  • 2
    $\begingroup$ Going through old posts on this site also seems to confirm what other commenters have said: there just isn't a good way to control the PDF layout upon export. That is really very unfortunate. A second best would be to create a new notebook, either by hand or programmatically with CreateDocument[exp], then print that notebook, as shown here. $\endgroup$ – MarcoB Jul 15 '15 at 6:39

Your Answer

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

Browse other questions tagged or ask your own question.