Currently, one may save notebooks as PDFs from the menu by Save As... and then selecting PDF (on a Mac, I imagine it is similar on other OSs). However, the resulting PDF does not have preserve the syntax highlighting of the code, even though things like plots are coloured. Printing to a PDF has the same effect (again, all this on a Mac).
Is there some way to save a notebook to PDF format so that syntax highlighting is preserved?
Here's an example of what I mean:
PDF:

on-screen (mathematica notebook, screenshot):

I feel that I am missing something obvious, but what?
Answer
The default style sheets set ShowSyntaxStyles -> False for the "Printout" environment.
You could change the notebook to use a style sheet that doesn't set this. Probably the easiest way is to copy the definition from Default.nb, and modify it:
Cell[StyleData[All, "Printout"],
ShowSyntaxStyles->True]
Comments
Post a Comment