2
$\begingroup$

I have a long Mathematica notebook where some cells on multiple levels are closed for clarity.

When I export the notebook as a PDF via Print or Save as, the print only contains the opened cells.

I want to be able to print all cells - even the closed ones - into the PDF.
When I open them via Cell -> Grouping -> Open all Subgroups my actual notebook is changed destructively, and I have to re-close certain groups by hand because there's no proper undo.

Did I miss any option?

$\endgroup$
3
  • 4
    $\begingroup$ Quick an dirty: save your notebook in the desired state, open all cells, print and then revert to the saved notebook? $\endgroup$
    – Yves Klett
    Jul 1, 2014 at 14:36
  • $\begingroup$ @YvesKlett Pity, that you didn't put your comment as an answer :) $\endgroup$
    – eldo
    Jul 1, 2014 at 14:55
  • $\begingroup$ Thank you for your answer! I hoped there was a much more elegant solution to this - I don't have the feeling that I'm trying to achieve something extravagant here. Hopefully Mathematica 10 will improve this. $\endgroup$ Jul 1, 2014 at 17:18

1 Answer 1

3
$\begingroup$

Another quick(?) and dirty way:

Let nb be the notebook to be printed. E.g., execute nb = EvaluationNotebook[] in the notebook you would like. Then execute

NotebookPrint[NotebookGet@nb /. CellGroupData[data_, Closed] :> CellGroupData[data, Open]]

or

Export["/tmp/foo.pdf", 
 NotebookGet@nb /. CellGroupData[data_, Closed] :> CellGroupData[data, Open]]

One potential drawback is that NotebookGet essentially creates a copy of the notebook (I assume).

There is probably a way to make it more automatic. Others here are more fluent in manipulating notebooks than I am. I have had this problem, but I cannot find or recall how I dealt with it. Perhaps as Yves suggested in a comment: save the notebook, open all cells, print, and revert to saved.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.