Is there a simple way to export all open notebooks to pdfs? Also, when I export notebooks the font looks too big / the margins are too big. Can I change these settings when exporting?
2 Answers
This could be a basic code for this:
(* SetDirectory[] ??? Here you could set a directory to write the files... *)
Do[
name=Check[NotebookFileName[nb], "NotSaved.nb", NotebookFileName::nosv];
(* Set the stylesheet that fit your needs *)
iniStyle = StyleDefinitions /. Options[nb];
SetOptions[nb,StyleDefinitions->"Default.nb"];
Export[FileBaseName[name],nb,"PDF"];
SetOptions[nb,StyleDefinitions->iniStyle];
,{nb,Notebooks[]}
]
-
$\begingroup$ How do I change the font size? And this looks like it will change my working notebook styles. I don't want to change those. I just want the font size smaller in the exported pdf, but not in the actual notebook while I am working in mathematica. $\endgroup$– nullUserDec 4, 2013 at 17:42
-
$\begingroup$ I edited the code so that leaves the initial stylesheet. I don't know the exact style that you want to modify. The easy way could be edit the actual stylesheet a save as new one (you should change "Default.nb" for this) a edit the "printout" style that you need. $\endgroup$ Dec 4, 2013 at 18:16
If you evaluate this:
SetOptions[EvaluationNotebook[],
StyleDefinitions ->
Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData[All, "Printout"], Magnification -> 1,
FontSize -> 12]},
StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]
You can adjust magnification and font size accordingly (and include cell margins if needed). For this to work you need to have your printing environment set to "Printout". The fact that your fonts are too big makes me think your printing environment is set to another mode. Ideally your would adjust this in your stylesheet.