Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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).

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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