Try setting TextPadding -> True
. It does more or less the same as the builtin ContentPadding
. It is described in SciDrawGuide.pdf.
What ContentPadding -> True
does, in simple terms, is that it makes the enclosing box have a vertical size equal to a full line height. Otherwise the box has the same height as the enclosed character/text. SciDraw positions textual elements wrapped in boxes. For good alignment it is necessary that all boxes have the same height. This is done by enforcing a minimum line height. MaTeX also has such an option, precisely for dealing with this kind of problem.
Example:
<< SciDraw`
labelFun[x_, _] :=
Module[{frac = Rationalize[x/Pi] Pi, num, den},
num = Numerator[frac];
den = Denominator[frac];
If[den == 1,
num,
StringForm["``/``", num, den]
]
]
Figure[
FigurePanel[{FigGraphics@Plot[Cos[ωt]^2, {ωt, 0, 2 π}];},
XPlotRange -> {0, 2 π},
XTicks -> LinTicks[-2 Pi, 2 Pi, Pi/2, 4, TickLabelFunction -> labelFun],
TextPadding -> True,
XExtendRange -> 0.02, YExtendRange -> 0.04
],
CanvasSize -> {5, 3}]
I'm not sure what the best way is to get correct spacing around the /
sign, but the following works: replace the string in StringForm
with "\!\(TraditionalForm\```/``\)"
. This is a string representation of boxes. I obtained it by writing a single character into a string, selecting it, then pressing Command-Shift-T to convert it to TraditionalForm. This created a traditional form environment within the string. Then I deleted the character and typed what I wanted instead.
To set things such as font size, etc. use options such as FontSize
, TickFontSize
, XTickFontSize
, etc., depending on how specific you want to be. It is not necessary to use Style
here. These can also be set at the level of the Figure
, as these options are inherited. Or you can use DefineStyle
and re-use it across several figures. That's what I usually do when using SciDraw.
You may also be interested in the *TextNudge
options, e.g. try XTickTextNudge -> -2
to position the ticks further from the frame. I tend to find the SciDraw default too tight.