I want to make a notebook with the following special feature: some of its cells show up only when the notebook is opened in for instance versions 11 and 12, but are hidden if the notebook is opened in other versions. Is this possible to do?
1 Answer
$\begingroup$
$\endgroup$
You can use the approach from this question to get front-end-only version dependent styling of cells and combine it with this question to get invisible cells:
CellPrint@Cell[
BoxData["Only in 12.0+"],
"Text",
"Text",
CellElementSpacings ->
{"CellMinHeight" -> FEPrivate`If[
FEPrivate`Less[FEPrivate`$VersionNumber, 12],
0,
Inherited
],
"ClosedCellHeight" -> FEPrivate`If[
FEPrivate`Less[FEPrivate`$VersionNumber, 12],
0,
Inherited
]
},
CellMargins -> FEPrivate`If[
FEPrivate`Less[FEPrivate`$VersionNumber, 12],
-2,
Inherited
],
CellOpen ->
FEPrivate`Not@FEPrivate`Less[FEPrivate`$VersionNumber, 12],
ShowCellBracket ->
FEPrivate`Not@FEPrivate`Less[FEPrivate`$VersionNumber, 12]
]
CellPrint@Cell["All versions", "Text"]
The above cell will print two cells, the first one is only visible in version 12.0 and higher, in lower versions it will be completely invisible:
$VersionNumber
. $\endgroup$