5

I am playing with a font (found here) that has sups/subs defined for figures but not for letters. If I don't enable them, I don't get them:

No proper sups/subs for figures

But if I \usepackage{realscripts} to enable them, I lose the ability to use letters as sub/superscripts at all:

with package realscripts

Is there a way for me to get the subs/sups figures while retaining the ability to use letters in sub/superscripts? Here is my code:

\documentclass{standalone}
\usepackage{fontspec}
\setmainfont{OFLGoudyStM}[
    Extension      = .otf,
    Ligatures      = {Common, TeX},
    ItalicFont     = OFLGoudyStM-Italic]
\usepackage{realscripts}

\begin{document}
\begin{tabular}{l}
  M\textsuperscript{abc0123456789def} \\
  M\textsubscript{abc0123456789def}
\end{tabular}
\end{document}
4

No, realscripts is only useful if all the glyphs you need to superscript or subscript are drawn specifically in the font. There's no way within XeTeX of detecting whether a given font feature will affect a particular glyph (or run of glyphs), so you can't even know until you typeset the document and inspect the output.

Well, in some cases you could make a box and compare its size before and after setting the font feature, but that method probably has edge-cases that would cause it to be occasionally unreliable.

Another option might be to inspect the contents of the \textsuperscript argument and branch according to the input. I.e.,

\textsuperscript{a1} -> 
\textsuperscript{a}\textsuperscript{1} ->
\fakesuperscript{a}\realsuperscript{1}

But this would look terrible because a and 1 would look very different, so it'd be better to use \fakesuperscript (i.e., don't like realscripts) in this case.

| improve this answer | |
  • I think I need \textsuperscript defined as realscripts does to get proper automatic behavior for footnotes. If I call realscripts, is there some way for me to manually specify a superscript with sups disabled? Say \textsuperscript{1} but \mysuperscript{a}, where mysuperscript has sups off? (You just answered this, I didn't know about \fakesuperscript.) – dedded Feb 13 '16 at 2:48
  • Of course. I wrote it in my answer already: \fakesuperscript. There's an unfortunate typo in the documentation, though. The first sentence of section 2 should read "The OLD commands are defined in starred form (e.g., \textsubscript*) for cases where the new commands are not appropriate.". – Will Robertson Feb 13 '16 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.