By giving a cell the simple option CellOpen -> False
, it can be hidden from view.
But for inline cells (cell within a cell) this does not work.
An option Visible -> False
only seems to exist for notebooks, not for cells.
What to do?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityOne way is to go with stylesheets, you can set DefaultNewInlineCellStyle
option for StyleData["Notebook"]
and for this given style, a specific CellSize
, then you can proceed with toggling it. But it is messy and probably an overreaction.
I'd go with this simple procedure, you can put it as a MenuItem
, a new shortcut or whatever you find convenient. For simplicity let's create a quick palette:
So, first of all, from documentation of Cells[obj]
:
obj
may be aNotebookObject
or aCellObject
. Ifobj
is aCellObject
, thenCells
returns the inline cells in the specified cell.
CreatePalette[
Button[
"Toggle inline cells visibility",
Module[{inlineCells},
inlineCells = Cells /@ Cells @ InputNotebook[] // Flatten;
If[
CurrentValue[#, CellSize] === {1, 1},
SetOptions[#, CellSize -> Automatic],
SetOptions[#, CellSize -> {1, 1}]
] & /@ inlineCells
]
]
]
Size {0,0}
is not supported so we are using {1, 1}
which is small enough :)
Another way to hide inline cells is by wrapping them in a 0x0 Pane
or PaneBox
. This has the advantage of not requiring one to change the overall CellSize
, which can be useful in some niche use-cases (like I've run into) where perhaps you want to obtain the would-be-size of a cell without showing it. My use-case for this is a custom "ragged wrapped row/grid" package.
I'm also sharing my routine for obtaining a CellObject
for an inline cell in the most efficient way I know how to: using Initialization
. (In practice, using a module / Unique[]
instead of a global for cellTagObj
is advised)
RawBoxes@RowBox@
{
"some dummy contents",
PaneBox[
Cell[
BoxData@Table["aaaaabbbbbcccccddddd", {i, 1, 20}],
"Output",
CellMargins -> {{0, 0}, {0, 0}},
CellFrameMargins -> {{0, 0}, {0, 0}},
ImageMargins -> {{0, 0}, {0, 0}},
CellElementSpacings -> {"CellMinHeight" -> 0,
"ClosedCellHeight" -> 0},
RuleDelayed[Initialization, cellTagObj = EvaluationCell[]]
],
ImageSize -> {0, 0},
FrameMargins -> {{0, 0}, {0, 0}},
ImageMargins -> {{0, 0}, {0, 0}},
ContentPadding -> False
],
"some more dummy contents"
}
cellTagObj
AbsoluteOptions[cellTagObj, CellSize]
CellSize
option to the inline cell and toggle between{0,0}
andInherited
but this would be quite messy to implement I think. $\endgroup$