# How can I make an invisible Cell?

Notebooks have a Visible option, but Cell // Options doesn't mention any equivalent for Cells. Can you suggest a workaround?

• Select the cell to be "hidden" and use the menu command Cell | Cell Properties | Open (for "hidden" cell Open should then be unchecked). Apr 29 '16 at 4:20
• Thanks for your reply ! This problem is that this cell still takes its spaces: Cell[BoxData["a"], "Input", Background->Hue[.8], CellMargins->0, CellOpen->False, CellFrameMargins -> 0, CellFrame->False, FontSize->1 ShowCellBracket->False ] Apr 29 '16 at 4:29

## UPDATE

As Kuba correctly notes in the comment, with negative CellMargins we can make the cell height to be effectively zero:

CellPrint@Cell[BoxData["a"],
CellElementSpacings -> {"CellMinHeight" -> 0, "ClosedCellHeight" -> 0},
Background -> Hue[.8], CellMargins -> -2, CellOpen -> False, CellFrame -> 0,
ShowCellBracket -> False]


For the check we can add another "Input" cell after our zero-height cell, take a screenshot, then delete our cell programmatically and take a screenshot again, then compare the screenshots. Here are the two screenshots taken with 100% global Magnification setting, at the first im1 only the first two "Input" cells are evaluated (the invisible cell is printed), at the second im2 the Notebook is completely evaluated (as seen from the cell labels; the invisible cell is deleted):

im1 = Import["http://i.stack.imgur.com/jQ2kx.png"];
im2 = Import["http://i.stack.imgur.com/cVLJJ.png"];
ImageAssemble[{{im1, im2}}]


Now compare specifically the distances between the first and the second "Input" cells:

{i1, i2} = ImageTake[#, {216, 250}, {489, 515}] & /@ {im1, im2}


i1 === i2

True


They are identical! Indeed we have made a zero-height completely invisible Cell!

It seems to be impossible to create a Cell which takes zero space in the Notebook, but with CellElementSpacings you can minimize its height:

CellPrint@Cell[BoxData["a"],
CellElementSpacings -> {"CellMinHeight" -> 0, "ClosedCellHeight" -> 0},
Background -> Hue[.8], CellMargins -> 0, CellOpen -> False, CellFrame -> 0,
ShowCellBracket -> False]


The above screenshot is taken with global Magnification set to 150%, the generated Cell has height 3 pixels on the screen. If we set Magnification to 100%, the height becomes 2 pixels:

Of course you can make the Cell invisible by giving it transparent Background:

CellPrint@Cell[BoxData["a"],
CellElementSpacings -> {"CellMinHeight" -> 0, "ClosedCellHeight" -> 0},
Background -> GrayLevel[0, 0], CellMargins -> 0, CellOpen -> False, CellFrame -> 0,
ShowCellBracket -> False]


(for some reason Background -> Opacity[0] is forbidden but Background -> GrayLevel[0, 0] works).

• Such settings of Background are forbidden: "The specified setting for the option Background cannot be used." Apr 29 '16 at 6:20
• @Rom38 Thank you, I have corrected the code: Background -> GrayLevel[0, 0] works. Apr 29 '16 at 6:23
• You can use negative Margins to get rid of those 2 pixels, e.g.: CellMargins -> -2 they do this for "SlideShowHeader" style. (Core.nb)
– Kuba
Apr 29 '16 at 8:49
• @Kuba Thank you, it indeed allows to make a zero-height Cell, please see the "UPDATE" section. Apr 29 '16 at 10:16
• @mitochondrial TaggingRules seem to be convenient for storing information inside of Notebook, see for example this answer. Apr 29 '16 at 14:24