Can you extract the Style attributes from a variable. For example:
var = Style["aString", Bold, 24]
You can get back "aString" by using ToString[var] but I am not able to get the attributes {Bold, 24}.
Examine its FullForm
:
var = Style["aString", Bold, 24];
var // InputForm
(* Out: Style["aString", Bold, 24] *)
Exactly as you typed in. You can manipulate it just as you would any Mathematica expression. For example:
List @@ Rest[var]
(* Out: {Bold, 24} *)
Style["aString", Bold, 24]
and Style["aString", FontWeight -> Bold, FontSize -> 24]
...
$\endgroup$
var2 = Style["aString", Bold, 24]; var1 = Style["aString", FontWeight -> Bold, FontSize -> 24]; OrderedQ[{var2, var1}]
returns a reasonable result. Do you want var1
and var2
to be the same?
$\endgroup$
Commented
Dec 27, 2013 at 1:33
SameQ
is False
... I was just surprised that both forms didn't have the same underlying representation (I thought Style["aString", FontWeight -> Bold, FontSize -> 24]
would auto-evaluate to Style["aString", Bold, 24]
or something like that).
$\endgroup$
Equal[var2,var1]
to evaluate to True
in the same way that Equal[1,1.0]
evaluates. I can see that. But, are there other situations where Equal[a,b]
evaluates to True
where a
and b
are non-identical, non-numeric expressions? I'm not sure off the top of my head, but I haven't been thinking about code so much lately. It's a little far afield of the OP's intention, perhaps. :)
$\endgroup$
Commented
Dec 27, 2013 at 1:53