We have two questions: 1) How to make a PDF from a grid of graphics (output of Plot
), and 2) How to make a PDF for a whole notebook.
For the second question... Here's a way to make a PDF of a whole notebook including inputs and outputs. NotebookPrint
saves a print-ready form of a notebook to a file in the format indicated by a file extension. First, open a notebook as a NotebookObject
with NotebookOpen
, then use the file.ext option of NotebookPrint
to make a PDF file. For example:
file = FileNameJoin[{$WolframDocumentsDirectory, "notebook.nb"}];
nb = NotebookOpen[file];
NotebookPrint[nb, "notebook.pdf"];
For the grid of graphics, use CreateDocument
to make a new notebook from an expression or expressions. Using the example from your question:
nb = CreateDocument[{f[a_, b_, d_] := (a + b)/(a - b) d;
tup1 = Tuples@{{1, 0, 0, 1}, {2, 1, 0, 3}};
Quiet@
Check[t =
Plot[{f[##, d], 1}, {d, 0, 1}, ImageSize -> 1000,
PlotLabel -> Style[StringForm["a= `` b= ``", ##]]]; t,
Nothing[]] & @@@ tup1 // Flatten //
Partition[#, 2, 2, {1, 1}, {}] & // Grid}];
NotebookPrint[nb, "plots.pdf"];
I tried several detailed notebooks with mixed graphics, inputs and outputs. NotebookPrint
created PDFs that scaled large graphics to a single page (graphics are not split at page breaks, although I found a large, rasterized image that worked better with smaller dimensions). Inputs and outputs are formatted to closely match the notebook appearance.
Export["test.pdf",%]
? $\endgroup$