# Typesetting superscripts and subscripts with system fonts in Xelatex

My document is required to be typeset in a font called DINPro. I need to use both subscripts and superscripts within the text. I would like to use \textsubscript and \textsuperscript, howerver \textsuperscript doesn't change scaling or position of affected text. \textsubscript changes position properly but does not scale.

As an alternative I have tried using math mode like BASE$_{SUBSCRIPT}$. It scales and positions nicely, but it uses roman/italic. Is there any way to use either of these methods with my font to get properly scaled and positioned sub/superscripts in my required font? MWE:

\documentclass[a4paper,12pt]{article}
\usepackage{xltxtra}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=NoCommon, SizeFeatures = {Size=12}}
\newfontfamily\BodyFont{DINPro-Light}[SizeFeatures = {Size=11}]
\begin{document}
\begin{tt}
{\bf Testing textsubscript and text superscript with tt font:} \newline
BASE\textsuperscript{SUPERSCRIPT} \newline
BASE\textsubscript{SUBSCRIPT} \newline
Note that the sub/superscript is smaller than the base and centered respectively with  the lower and upper edges of the base. \newline
\noindent\makebox[\linewidth]{\rule{\textwidth}{0.4pt}}
\par
\end{tt}

\begin{BodyFont}
{\bf Testing textsubscript and text superscript with DINPro-Light, Size 11, downloaded from internet:} \newline
BASE\textsuperscript{SUPERSCRIPT} \newline
BASE\textsubscript{SUBSCRIPT} \newline
1)Boldface reverts to roman font. \newline2)DINPro font  textsuperscript doesn't work at all. \newline  3)textsubscript works but the subscript font size is the same as the base. \newline Question:  Is this an issue  with the font I used?  DINPro is the required font for my document so I need to figure out how to make it work.\newline
\noindent\makebox[\linewidth]{\rule{\textwidth}{0.4pt}}
\par

{\bf Alternative question: Testing math mode subscript  andsuperscript with DINPro-Light, Size 11, downloaded from internet:} \newline
BASE$^{SUPERSCRIPT}$ \newline
BASE$_{SUBSCRIPT}$ \newline
This looks much better, however the math mode font is roman and italic.  Is there any way to prevent transiton  roman and italic in math mode?
\end{BodyFont}
\end{document}

• Welcome to TeX SX! As a workaround, try \textsubscript{\scriptsize …} and similarly for the superscript. – Bernard Jun 13 '19 at 22:19
• try without the xltxtra package (which load the realscript package, and if your font doesn't have them it can harm). – Ulrike Fischer Jun 13 '19 at 22:27
• When I comment out \usepackage{xltxtra}, the \textsuperscript and \textsubscript both position correctly relative to the base but they still do not scale to a smaller size. – Sammy Jun 13 '19 at 22:39
• remove the SizeFeatures settings. – Ulrike Fischer Jun 13 '19 at 23:40
• @Bernard, I think \scriptsize is not working for me because I am explicitly defining the size in the \newfontfamily definitions. But it leads me to a work around. I just use \newfontfamily to dfine a 7pt version of DINPro called ScriptFont. Then the sub/superscritp lines become BASE\textsubscript{{\ScriptFont SUBSCRIPT}}\newline. It doesn't scale automatically, but it looks okay with the range of font sizes I will use and I can change the size globally from the preamble if I need to. – Sammy Jun 14 '19 at 4:56