Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
\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

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Oh, how I wish the math \fontdimens worked with XeTeX ;-) –  morbusg Feb 13 '12 at 21:14
    
awesome!!! thanks for offering me the flexibility by making the raise variable. –  Aku Feb 13 '12 at 23:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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