3
$\begingroup$

When thinking on the question

it crossed my mind that it may be possible to "intercept" one style ("Input") on the level of the Notebook's private stylesheet and replace it with definitions of another style ("Code") from the "Core.nb" stylesheet. Something like the following (it demonstrates the idea, but doesn't work):

Cell[StyleData["Input"], StyleData["Code", StyleDefinitions -> "Core.nb"]]]

The above line of code defines an "intercept" for the style "Input" on the level of the Notebook's private stylesheet. The second argument StyleData["Code", StyleDefinitions -> "Core.nb"] should "import" the complete definition for style "Code" from the "Core.nb" stylesheet, but it doesn't work as written. How should it be changed in order to achieve the desired goal?

$\endgroup$

1 Answer 1

0
$\begingroup$

Based on this answer by Carl Woll, the syntax should be:

Cell[StyleData["Input", StyleDefinitions -> StyleData["Code"]]]

Setting the option programmatically:

SetOptions[
    EvaluationNotebook[],
    StyleDefinitions -> Notebook[
        {
        Cell[StyleData[StyleDefinitions -> "Default.nb"]],
        Cell[StyleData["Input", StyleDefinitions -> StyleData["Code"]]]
        }
    ]
]

Checking:

screenshot

As one can see, the input cell is formatted as a "Code" cell, while in its definition it still has the style "Input". Done!

$\endgroup$

Your Answer

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

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