# Hiding inputs with specific function [duplicate]

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.

How should I proceed?

## marked as duplicate by Carl Woll, Community♦Jul 7 '17 at 0:04

• 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... – C. E. Jun 28 '17 at 19:23
• 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... – LCarvalho Jun 28 '17 at 19:50
• @Mr.Wizard See Mr.Wizard's answer to How to Keep Input Cells Hidden After Evaluating Notebook where he defines an AutoCollapse[] function. – Carl Woll Jul 6 '17 at 23:56
• @CarlWoll Really duplicate. Sorry. I expected Mr.Wizard to publish... – LCarvalho Jul 7 '17 at 0:07

For easy searching I copied the answer from Mr. Wizard

## AutoCollapse[] function

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


Then in a new cell:

2 + 2
AutoCollapse[]


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

## Stylesheets

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];
FrontEndTokenExecute["SelectionCloseUnselectedCells"]),

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.