Normal numbers are superscripted when using \fontspec{<font name>}[Fractions=On]

This MWE produces superscripted numbers on my Windows machine.

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\noindent
\fontspec{Times New Roman}[Fractions=On]
Should not be superscript: 0123456789, normal period:.\\
Punctuation is superscripted, as well as 123 numbers! E.\,g.~the period.\ldots
\end{document}


It results in the following:

As you can see, all numbers are in superscript. When using Adobe Garamond Pro, my punctuation is raised too. What is causing this problem?

• It’s not a problem; it’s what you’re requesting when you activate that feature. Use the feature only when you want to create a fraction. – Thérèse Mar 24 '15 at 17:13
• @Thérèse - Ok, makes some sense, but then I don't understand when I'd use such a font feature if I can easily define a fraction macro (e.g. using the nicefrac package). I thought [Fractions=On] changed the numbers before a / to numerator height and after the / to denominator height, which simplifies writing fractions quite a bit. Looking at the fontspec manual section 9.6 and especially Example 23 on page 27, I concluded this was the expected behaviour, because the long fraction in that example "13579/24680" is not printed with higher or lower numbers! – Erik Mar 24 '15 at 17:20
• Additionally, it doesn't explain why the commas and periods used with Times New Roman aren't affected. This leads me to believe there is some unexpected or impractical behaviour of either the fontspec or the two fonts I used as an example. – Erik Mar 24 '15 at 17:27
• I don’t recall using nicefrac, but xfrac produces numbers that are too small and thin and whose kerning needs improvement, whereas the OpenType fraction feature gives numbers whose weight matches that of the font. It’s like the difference made by realscripts for footnote markers. But the results you get will depend on the font: some fonts can form arbitrary fractions, others can’t; some affect punctuation and plus or minus signs, others don’t. You have to study each font. – Thérèse Mar 24 '15 at 17:29
• @Thérèse - That would then be the answer to my question: the Fractions feature enables it for the entire font. Additionally, various fonts behave differently (maybe because Times New Roman is TrueType and Adobe Garamond Pro OpenType on my system?). A solution would be to create a macro, e.g. \newcommand*{\fraction}[1]{{\addfontfeature{Fractions=On}#1}} for fractions and let your OpenType fonts work their magic. According to Thérèse this produces better fractions than the xfrax package does. – Erik Mar 24 '15 at 17:43

When you turn turn on the frac feature, you’re telling fontspec that you want to create a fraction. It responds helpfully: it uses numerator glyphs, if they are present in the font, until you type a slash, it replaces the slash with U+2044 (the fraction slash), and it continues with denominator glyphs until you turn off the frac feature. It can’t know whether you intend to type a fraction unless you tell it (e.g., is 428/427 a fraction, or is it the year of Plato’s birth, with an indication that the ancient and the modern calendars can’t be lined up easily?). For this reason, you should not turn the feature on as a default feature for all fonts in the document or for the document’s main font; instead, add it only where you want a fraction.

If you do turn the feature on globally, the results will be harmless or more or less obviously wrong depending on the font. That has nothing to do with whether the font file ends in .ttf or .otf: there are TrueType “flavored” and PostScript “flavored” OpenType fonts (the former with quadratic Bézier curves, the latter with cubic Bézier curves). Your version of Times New Roman is OpenType, otherwise it would have ignored your invocation of an OpenType feature. So why do the results vary, as between your Times New Roman and Adobe Garamond Pro? It’s because the frac feature is not available in all fonts, and in those that do have it, some have a richer version of it than others:

1. Some offer only a few precomposed glyphs (e.g., typing {\addfontfeature{Fractions=On}1/2} produces the character whose code point is U+00BD).
2. Others allow for for making fractions with any numbers (e.g., 256/243, for which fonts are highly unlikely to provide a precomposed glyph, because this fraction, though dear to Pythagoreans, has no code point in UTF-8).
3. Still others allow for including some punctuation and symbols in fractions (e.g., $126,963.54/$1,750.18).

If a font doesn’t have the frac feature, turning it on will produce warnings in the log, and the compiled document will not have attractive fractions, but neither will it have stray glyphs leaping up off of the baseline. If you turn the frac feature on globally with a font of the first sort, then an approximate date such as 231/232 may come out as 23½32. And if you turn it on globally with fonts of the second or third sort, the results will be as conspicuous as pictured in the question.

Now, why is a frac feature desirable? I’m not a mathematician, so I won’t comment on whether and how mathematicians benefit, but let’s compare text using xfrac with the same text using the OpenType feature. (xfrac does offer an interface for advanced users, but it’s more work than using OpenType, so let’s leave it for non-OpenType fonts and try only the basic macro provided by xfrac.)

\documentclass[12pt,a5paper]{book}
\usepackage{fontspec,microtype,xfrac}
\setmainfont{EB Garamond}[
Contextuals=Alternate,
ItalicFeatures={Ligatures=Contextual}]
\AtBeginDocument{\setlength{\parindent}{1em}}
\setcounter{secnumdepth}{0}
\usepackage[it,md,small]{titlesec}
% shortcut; name the macro as you like, if the name isn’t already defined:
\begin{document}
\section{xfrac}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \sfrac{4}{3}, \sfrac{3}{2}, 2,
\sfrac{8}{3}, 3, 4, \sfrac{9}{2}, \sfrac{16}{3}, 6, 8, 9,
\sfrac{27}{3}, 18, and 27. Why do you suppose he did that?

\section{font feature}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \frc{4/3}, \frc{3/2}, 2,
\frc{8/3}, 3, 4, \frc{9/2}, \frc{16/3}, 6, 8, 9, \frc{27/3}, 18, and
27. Why do you suppose he did that?
\end{document}


Notice the differences: The numerators and denominators with xfrac are smaller than the real numerators and denominators: more fits onto the third line of the sample text. And the fractions made with xfrac look too small for the commas following them, whereas the OpenType fractions are of the right weight and size for the commas and the surrounding text. Also, with xfrac, the numerators 4 and especially 3 come too close to the slash. Overall, the OpenType fractions are clearer and easier on tired eyes.

We can improve the performance of xfrac a little, even without its advanced interface, by turning on lining figures, which are not the default in EB Garamond:

\documentclass[12pt,a5paper]{book}
\usepackage{fontspec,microtype,xfrac}
\setmainfont{EB Garamond}[
Contextuals=Alternate,
ItalicFeatures={Ligatures=Contextual}]
\AtBeginDocument{\setlength{\parindent}{1em}}
\setcounter{secnumdepth}{0}
\usepackage[it,md,small]{titlesec}
\begin{document}
\section{xfrac with lining figures}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \sfrac{4}{3}, \sfrac{3}{2}, 2,
\sfrac{8}{3}, 3, 4, \sfrac{9}{2}, \sfrac{16}{3}, 6, 8, 9,
\sfrac{27}{3}, 18, and 27. Why do you suppose he did that?}

\section{font feature}
In Plato’s \textit{Timaeus,} the demiurge gives the world-soul a
structure based on two geometrical proportions, their arithmetic
means, and their harmonic means: 1, \frc{4/3}, \frc{3/2}, 2,
\frc{8/3}, 3, 4, \frc{9/2}, \frc{16/3}, 6, 8, 9, \frc{27/3}, 18, and
27. Why do you suppose he did that?
\end{document}


Now the numerator 3 doesn’t run into the slash, but the numerator 4 is worse than before. The fractions no longer hang so far below the baseline, but they still end in the middle of the comma, not on the baseline as the OpenType fractions do. And they still look cramped compare to the OpenType fractions.

MORAL OF THE STORY: OpenType fonts are powerful, allowing us to achieve, with relative ease, typographic refinements which would be at least difficult without them. But that very power, if not handled with care, may produce a mess it would be difficult to “achieve” without them. So while it’s always necessary to examine the fonts you use, with OpenType fonts, expect to spend even more time studying their features, especially in the case of large and sophisticated font families like Garamond Pro.

By the way, extra attention is required not only by users but also by makers of OpenType fonts. I recently acquired a font whose feature file contained the rule sub \three \slash \four by \onehalf;. Such a mistake is easy to understand, because making feature files is tedious, so you copy and paste from one of your previous efforts and perhaps forget to make all necessary changes. The foundry produced a corrected version as soon as I pointed out the error, but the results may have been a spoiled dinner had I typeset a recipe without paying attention. Hot metal had inconveniences, but this particular kind of mistake would be difficult to imagine on a Monotype machine.

• Great answer! However, mathematicians stopped printing fractions that way a couple of centuries ago. My opinion is that this way of printing fractions is good for recipe books. – egreg Oct 16 '15 at 21:36

The Fractions feature enables fraction style numbers for all text until different features or fonts are selected. The demonstrated behaviour is not a bug, but actual functionality.

Additionally, various fonts behave differently (maybe because Times New Roman is TrueType and Adobe Garamond Pro OpenType on my system?). A solution would be to create a macro, e.g. \newcommand*{\fraction}[1]{{\addfontfeature{Fractions=On}#1}} for fractions and let your OpenType fonts work their magic. According to Thérèse in the comments under the question, this produces better fractions than the xfrac package does.

• Confusingly, some fonts actually behave intelligently: Adobe Jenson Pro, for example (with Fractions=On), will set numbers in isolation normally (eg. 123), but will set 11/2 as 1 plus a real 1/2 fraction. In many instances this is extremely convenient. So far, Adobe Jenson Pro is the only typeface that I have found that works this way. In most instances, however, the use of a macro (like \fraction suggested by Eric) is the only thing to do. The xfrac.sty package is intended as a workaround; good OT fonts have the formatting of fractions carefully worked out for the font. – sgmoye Oct 16 '15 at 11:54