2

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]?

Alexey Popkov
  • 61,809
  • 7
  • 149
  • 368
vito
  • 8,958
  • 1
  • 25
  • 67
  • 1
    I guess this may be useful... http://mathematica.stackexchange.com/questions/9437/some-tutorials-on-formatting-notebook-for-exporting-to-pdf – Umberto May 16 '16 at 12:36

2 Answers2

5

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]
Michael E2
  • 235,386
  • 17
  • 334
  • 747
  • 1
    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). – Alexey Popkov May 16 '16 at 20:15
  • @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. – Michael E2 May 16 '16 at 20:20
4

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

SetOptions[InputNotebook[], CellLabelAutoDelete -> True];
vapor
  • 7,911
  • 2
  • 22
  • 55