2

I am using \sfrac with the newtx font package, and I get a very ugly result:

enter image description here

WHat I am doing wrong?

MWE:

\documentclass{standalone}

\usepackage[osf]{newtxtext}
\usepackage{xfrac}

\begin{document}

\sfrac{$1$}{$2$}

\end{document}
2
  • How about $\sfrac{1}{2}$ instead? Old Style Figures (OSF) are not really intended for use in math constructs. In any event, I cannot reproduce your output. Feb 22, 2022 at 17:11
  • @StevenB.Segletes This is better, but I need \sfrac{$1$}{$2$}, because I have to use it in siunitx, command \DeclareSIPostPower\rooted{\text{\sfrac{1}{2}}}, see tex.stackexchange.com/questions/623172/…
    – Pygmalion
    Feb 22, 2022 at 17:20

1 Answer 1

5

use \usepackage{fix-cm} to remove the font warnings, and make sure you have the cm-super collection installed (it is installed by default in texlive but apparently not in miktex)

enter image description here

\documentclass{standalone}

\usepackage[osf]{newtxtext}
\usepackage{xfrac}
\usepackage{fix-cm}
\begin{document}

\sfrac{$1$}{$2$}

\end{document}

If you want to adjust the positioning specify the xfrac template parameters for this font family (there are lots, but this is a start)

enter image description here

\documentclass{standalone}

\usepackage[osf]{newtxtext}
\usepackage{xfrac}
\usepackage{fix-cm}
\DeclareInstance{xfrac}{ntxtosf}{text}
{
   numerator-top-sep = .1em,
   denominator-bot-sep = -.1em,
   slash-right-kern = -.06em,
   slash-left-kern = -.06em
}

\begin{document}

\sfrac{$1$}{$2$}

\end{document}
5
  • Thanks for the answer. However, the slash itself is not a major problem, the biggest problem is that numbers are so far away from the slash.
    – Pygmalion
    Feb 22, 2022 at 17:44
  • 1
    @Pygmalion that's probably just the nested math. you didn't say what you disliked I was so horrified by the pixelated slash in your image I didn't consider anything else Feb 22, 2022 at 17:57
  • If I turn off osf and remove $$, I still get the same spacing problem.
    – Pygmalion
    Feb 22, 2022 at 18:01
  • @Pygmalion see update Feb 22, 2022 at 19:01
  • @Pygmalion the spacing is font dependent and there is no way how xfrac could know what to do for each and every font (it knows for some but ...). So if you have "ugly outcome" you need to tell xfrac what it should use instead according to your taste. David now provided an example, but the documentation contains more details on how to set up instances Feb 23, 2022 at 20:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .