[Tex/LaTex] Fraction in Superscript

fractionssuperscripts

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{fontspec}

\setmainfont[Script=Devanagari]{Sanskrit 2003}
\newcommand\sufr[2]{\textsuperscript{$\frac{#1}{#2}$}}
  \begin{document}
text\sufr{1}{6}  

राम\sufr{1}{6}
  \end{document}

In the above example, I managed to get fraction in superscript. However did not like the place where the fraction appears. It can be seen in the Devanagari text that the output does not appear like a superscript.

How can I raise the fraction number.
enter image description here

Best Answer

Here is a modified version of \sufr that now takes an optional argument indicating the raise quantity:

enter image description here

\documentclass[a4paper]{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand\sufr[3][0pt]{$\rule{0pt}{\dimexpr#1+1.4ex\relax}^\frac{#2}{#3}$}
\begin{document}
text$^\frac{1}{6}$ \quad text\sufr{1}{6} \quad text\sufr[5pt]{1}{6} 
\end{document}
​

The example sets the regular sans-\sufr-style superscript fraction, followed by the regular \sufr, followed by a 5pt raise of the fraction. The default raise is 0pt, which is similar to a regular superscript fraction.

Take caution of possible line height imperfections with such use, as is shown in the following example:

enter image description here

\documentclass[a4paper]{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\newcommand\sufr[3][0pt]{$\rule{0pt}{\dimexpr#1+1.4ex\relax}^\frac{#2}{#3}$}
\begin{document}
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr[5pt]{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
The quick brown fox jumps over the lazy\sufr{1}{6} dog.
\end{document}

You could, of course, \smash the superscript, but that may cause overlay problems.

Related Question