How can I set the style of one Output cell so it doesn't change after re-evaluating its Input cell?
I think you're on the right track with using a style sheet. I would just add a new "Input" type style as well (I will call it "Input2"), and give it your GeneratedCellStyles
option. To make it easy to switch between the "Input" and the "Input2" styles, I would also add a StyleKeyMapping
option. So, the style sheet would look like:
SetOptions[
EvaluationNotebook[],
Notebook[
{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Output2", StyleDefinitions -> StyleData["Output"]],
CellMargins->{{5,10},{5,10}},
ShowCellLabel->False
],
Cell[StyleData["Input2", StyleDefinitions -> StyleData["Input"]],
StyleKeyMapping -> {"Tab" -> "Input"},
Background -> GrayLevel[.9],
GeneratedCellStyles -> {"Output" -> "Output2"}
],
Cell[StyleData["Input"],
StyleKeyMapping -> {"Tab" -> "Input2"}
]
},
StyleDefinitions->"PrivateStylesheetFormatting.nb"
]
]
To show the difference between the "Input" and "Input2" cell styles, I gave the "Input2" cell style a gray background. Just remove the Background
option if it's not needed.
In the following animation, I use Tab at the start of the "Input" cell to toggle back and forth between the "Input" and the "Input2" cell styles. I also toggle the cell styles, and reevaluate the input with both cell styles:
For a one-off use I believe this should do what you want, using the existing Style Sheet definition.
CellPrint[
ExpressionCell[
Manipulate[Plot[Sin[x (1 + a x)], {x, 0, 6}], {a, 0, 2}],
"Output2"
]
]
There may be a more direct way using Style
but my skills are quite rusty at the moment, and I'd need to refresh and experiment.
Another approach I always use is to make the input cell that really created the interactive output Closed. When a cell is Closed it is very small and has a barely noticeable cell bracket. What you do it select the cell bracket on the right side of the notebook for the Input you don't want people to mess with. Then make the menu selection [Cell, Cell Properties, Open]. Once "Open" is not checked, the selected cell(s) will be Closed (barely noticeable).
Below the Input with Manipulate is Closed.
You can also have an Input cell just before the closed Input cell and make sure they are almost the same. Then you use the same menu to ensure the first Input cell is not Evaluatable.