0

I wanted to use some mixed numbers with slanted fraction in my text, so I used \sfrac or \nicefrac, as recommended by S. Kottwitz.

\documentclass{article}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{nicefrac}

\begin{document}
\noindent
A not slanted mixed number with \verb|\frac| : \(2\frac{1}{2}\), \(4\frac{3}{7}\)\\
A mixed number with \verb|\sfrac|: \(2\sfrac{1}{2}\), \(4\sfrac{3}{7}\)\\
A mixed number with \verb|\nicefrac|: \(2\nicefrac{1}{2}\), \(4\nicefrac{3}{7}\)
\end{document}

appearance of mixed numbers with traditional slanted fraction packages

But the visual results were not appealing to me. See on the picture how the numerators 1 of 1/2 and 3 of 3/7 look more like the exponents of 2 and 4 respectively. Admittedly, the \nicefrac outputs a nicer output than \sfrac, however not yet satisfying.

How can I improve the spacing of the mixed number with the slanted fraction so that the main number and the fraction's numerator look better?

2 Answers 2

1

If there is font feature +frac in used font then it is much better to use it instead of to crate a macro which build the fraction from slash and other components. The font designer implements better look of the fraction: suggests better size for numbers and creates (typically) another slant for slash.

Compare following example in Libertine font:

ff

This example was created by following code in OpTeX:

\fontfam[libertine]

\def\sfrac#1/#2 {\raise.75ex\hbox{$\scriptstyle #1\mkern-5mu$}/%
   \lower.35ex\hbox{$\scriptstyle\mkern-4mu#2$}}

fontfeature: {\setff{+frac}\rm 2\,1/2}

macro: $2\,\sfrac 1/2 $

\bye
2
  • Great! It looks much nicer with this +frac feature, sadly it is limited to ConTeXt or OpTeX. Is that right? Could you provide a translation for standard LaTeX (the one grandmas use ;))? Commented Mar 4, 2021 at 13:47
  • @loved.by.Jesus I don't use LateX but I hope that fontspec package for LuaLaTeX or XeLaTeX allows to set various font features including +frac. The main problem is if the used font supports such font feature.
    – wipet
    Commented Mar 4, 2021 at 15:32
0

To control the spacing in a mixed number, I add the math horizontal spacing \mspace{<number of mus>mu} to the mixed number with \sfrac (1mu = 1/18em).

My preferred look is adding 1mu extra space between number and slanted fraction, and -3mu extra space between numerator and the slash of the fraction. Thus, I define following command \mixednumber for "nicer" mixed numbers:

%needs packages 'xfrac' for \sfrac, 'amsmath' for \mspace
\newcommand*{\mixednumber}[3]{\ensuremath{#1\mspace{1mu}\sfrac{#2\mspace{-3mu}}{#3}}}

You can adapt the distances by accordingly changing 1mu or -3mu with the preferred spaces. You can even modify the spacing at the denominator by adding the corresponding \mspace before the #3 argument, though, for me, the denominator looks great. ;)

See the minimal example:

appearance of mixed numbers with the \mixednumber command

\documentclass{article}
\usepackage{amsmath}
\usepackage{xfrac}
\usepackage{nicefrac}

%needs packages 'xfrac' for \sfrac, 'amsmath' for \mspace
\newcommand*{\mixednumber}[3]{\ensuremath{#1\mspace{1mu}\sfrac{#2\mspace{-3mu}}{#3}}}

\begin{document}
\noindent
A not slanted mixed number with \verb|\frac| : \(2\frac{1}{2}\), \(4\frac{3}{7}\)\\
A mixed number with \verb|\sfrac|: \(2\sfrac{1}{2}\), \(4\sfrac{3}{7}\)\\
A mixed number with \verb|\nicefrac|: \(2\nicefrac{1}{2}\), \(4\nicefrac{3}{7}\)\\
A mixed number with \verb|\mixednumber|: \mixednumber{2}{1}{2}, \mixednumber{4}{3}{7}\\
\end{document}

You must log in to answer this question.

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