4
$\begingroup$

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?

$\endgroup$
2
  • $\begingroup$ One way would be to add a CellSize option to the inline cell and toggle between {0,0} and Inherited but this would be quite messy to implement I think. $\endgroup$ Oct 18, 2012 at 22:05
  • $\begingroup$ May be you can add an White color or Balck color or other color for all your inline cells and set the content unseen. $\endgroup$ May 8, 2013 at 6:31

2 Answers 2

2
$\begingroup$

One 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 a NotebookObject or a CellObject. If obj is a CellObject, then Cells 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 :)

$\endgroup$
0
$\begingroup$

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]

Output: enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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