1
$\begingroup$

I want to save a notebook file as PDF, but without cell numbers.

For instance, take this document,

Mathematica document

then select “save as PDF” and the result is,

PDF output

How can I remove the cell numbers In[14], In[16], and Out[16]?

$\endgroup$
2
$\begingroup$

What you want, I think, is the cell option ShowCellLabel -> False. You can edit the stylesheet to add the option to the styles "Input" and "Output" in the "Printout" environment. Or you can add them to a notebook, assuming it has the default style definitions, as follows:

SetOptions[EvaluationNotebook[], 
 StyleDefinitions -> 
  Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
    Cell[StyleData["Input", "Printout"], ShowCellLabel -> False], 
    Cell[StyleData["Output", "Printout"], ShowCellLabel -> False]}]]

As Alexey Popkov points out, it can be done more simply with

SetOptions[EvaluationNotebook[], ShowCellLabel -> False]

or for the current session (affecting all notebook temporarily) with

SetOptions[$FrontEndSession, ShowCellLabel -> False]
$\endgroup$
  • 1
    $\begingroup$ Actually the same can be achieved much simpler by setting the same option at the Notebook level: SetOptions[EvaluationNotebook[], ShowCellLabel -> False]. Note also that this option can also be set globally, for example SetOptions[$FrontEndSession, ShowCellLabel -> False] works (checked by saving as PDF with version 10.4.1). $\endgroup$ – Alexey Popkov May 16 '16 at 20:15
  • $\begingroup$ @AlexeyPopkov Well, what do you know. I'm sure I tried that and was surprised it didn't work. In fact the code is still in my scratch notebook. Works now, though. $\endgroup$ – Michael E2 May 16 '16 at 20:20
3
$\begingroup$

Evaluate this and then save as another nb, open the new nb file, and then save as PDF

SetOptions[InputNotebook[], CellLabelAutoDelete -> True];
$\endgroup$

Your Answer

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

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