I have simple but annoying problem here. I guess it occurs to many Mathematica users.
The thing is that I wish to define a function to format the text in Mathematica. Yet, I don't know whether it is possible.
Say if I want to make a plot with FrameLabel set, like the following script:
Show[
Plot[x^2, {x, 0, 1}, PlotRange -> {{0, 1}, {0, 1}}], Frame -> True, AspectRatio -> 0.8,
FrameLabel -> {Style[ToExpression["x", TeXForm, HoldForm], 18,FontFamily -> Times, Bold],
Style[ToExpression["x^2", TeXForm, HoldForm], 18, FontFamily -> Times, Bold]},
RotateLabel -> False
]
which generate this plot
The thing is I have type this bothering format setting script again and again if I need to plot a lot, though the format I set every time is the very same.
Style[ToExpression["x^2", TeXForm, HoldForm], 18, FontFamily -> Times, Bold]}
Therefore, I am wondering if I can define a function to overpass such prolix script. For example,
SetStyle[input_] := Style[ToExpression[ToString[input, InputForm], TeXForm, HoldForm],18,FontFamily -> Times];
It works for superscript, but it fail in the most of the Latex input, like \\theta or \\frac{x}{2} and even just the subscript like x_0
anyone know how I can fix my code?
Thanks for your kind and generous suggestion.
st[txt_String] := Style[ToExpression[txt, TeXForm, HoldForm], 18, FontFamily -> Times, Bold]
and then the optionFrameLabel
look as follows:FrameLabel -> {st["x"], st["x^2"]}
. $\endgroup$