I believe this question could be a duplication, but I did some searches with the term "hide the input cell", but none answered me. Only inputs with this function.

I have several input cells using the MaTeX function of our colleague Szabolcs.

I am creating some PDF files using this function, but at the moment I was exporting to this type of format I would like these inputs to be hidden.

enter image description here

How should I proceed?

  • 1
    $\begingroup$ When I wrote a presentation where I relied a lot on MaTeX, I used AutoCollapse from this answer. After having appended it to each cell with MaTeX in them, the cells hid themselves after evaluation, which was really nice because then I could see immediately what the final presentation was going to look like. Others will have to answer how to hide cells only on export... $\endgroup$
    – C. E.
    Jun 28, 2017 at 19:23
  • $\begingroup$ Is temporarily helping me. I run the AutoCollapse in a Notebook (taking advantage of the memory) and I run in my main file. A little beginner but I'm enjoying it... $\endgroup$
    – LCarvalho
    Jun 28, 2017 at 19:50
  • $\begingroup$ @Mr.Wizard See Mr.Wizard's answer to How to Keep Input Cells Hidden After Evaluating Notebook where he defines an AutoCollapse[] function. $\endgroup$
    – Carl Woll
    Jul 6, 2017 at 23:56
  • $\begingroup$ @CarlWoll Really duplicate. Sorry. I expected Mr.Wizard to publish... $\endgroup$
    – LCarvalho
    Jul 7, 2017 at 0:07

1 Answer 1


For easy searching I copied the answer from Mr. Wizard

AutoCollapse[] function

Please try this code, based on Sasha's adaption of my own answer to this question.

AutoCollapse[] := (
  If[$FrontEnd =!= $Failed, 
   SelectionMove[EvaluationNotebook[], All, GeneratedCell];

Then in a new cell:

2 + 2

Always place AutoCollapse[] as the last line of an Input cell.


To get the behavior without having to include AutoCollapse[] in each cell you can use Stylesheets and CellEpilog. For example to create an InputHidden style use menu Format > Edit Stylesheet... and then add a Cell with the following code (use Ctrl+Shift+E to edit Cell code):

Cell[StyleData["InputHidden", StyleDefinitions -> StyleData["Input"]],
 CellEpilog :> (SelectionMove[EvaluationNotebook[], All, GeneratedCell]; 
 MenuSortingValue -> 1510
 , MenuCommandKey -> "8"

enter image description here

This creates a new style that behaves like Input but which auto-collapses when evaluated. MenuCommandKey -> "8" lets it be quickly applied using Alt+8; change or remove this line as desired.

I may be reading more into your question than is there. As Heike points you can close the input cells manually by deselecting menu Cell > Cell Properties > Open but I assumed you knew this already and provided the soluition(?) above. If all you need is a hidden cell that generates output, use the menu. If you need something a little more flexible that automatically hides after you make your changes I hope you will find the methods above useful.

  • $\begingroup$ I think it would be much better to reference Mr.Wizards answer rather than copying it verbatim here. $\endgroup$
    – Carl Woll
    Jul 6, 2017 at 23:56

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