2
$\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$
1

2 Answers 2

5
$\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$
2
  • 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$ May 16, 2016 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, 2016 at 20:20
4
$\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 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.