4
$\begingroup$

Consider the following:

FirstOutput=Style["Test", FontSize -> 20]

SetOptions[Style, FontSize -> 20];
SecondOutput=Style["Test"]

I would like the string "Test" to appear in SecondOutput as in FirstOutput. Why does SetOptions[Style, FontSize -> 20] not apply to SecondOutput?

Does anyone have an idea?

$\endgroup$
4
$\begingroup$

There are some functions that don't work with SetOptions. This Q&A provides a WRI tech support solution to finding functions that don't work with SetOptions but it appears that that method doesn't pick up Style (or StyleBox).

$\endgroup$
2
$\begingroup$

I think Mike Honeychurch has the gist of it. I don't know why Style doesn't use it's option values, but if you test it out, get display problems if you call

Style["test", Sequence @@ Options[Style]]

send the message:

The specified setting for the option OpenerBoxOptions, BaselinePosition cannot be used.

If you want something similar I suggest you simply define your own style call, which for the most case also nicely documents that you don't just want to call an empty Style[] on a piece of text, but want it to follow some personally defined styling.

Options[myStyle]={FontSize->20};
myStyle[a__,OptionsPattern[]]:=Style[a,Sequence@@Options[myStyle]]

I would personally expect Style["text"] to be the default style, which means that the call is redundant, since "text" in and of itself would have the default style.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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