1

How do I get \nicefrac or \xfrac work in \displaystyle, i.e., without reducing the font size?

2

As an alternative (since \nicefrac and \sfrac do not seem to be adjustable to representing digits in displaystyle)...

Adjusting my answer from Modifying fraction macro for in-line text and exponents, this will also set numerator and denominator as text if called in text mode, and as math in math mode.

\documentclass{article}
\usepackage{graphicx}

\newcommand{\altfrac}[2]{\ifmmode\def\tmp{$}\else\def\tmp{}\fi\mbox{%
    {\raisebox{.24\ht\strutbox}{\tmp#1\tmp}}%
    \kern-2.2pt\scalebox{1.6}[1.5]{/}\kern-1.8pt%
    {\tmp#2\tmp}%
    }}

\begin{document}
\parindent 0pt
This is \texttt{altfrac:}\qquad
\altfrac{12}{14} \altfrac{31415}{27182} \altfrac{abc}{def} \altfrac{Foo!}{Bar?}
\altfrac{\#\$\%+/<>=}{?\@[]\textbackslash\_|\{\}§†} 
\[\left(\frac{3x}{2y}\right)^{\altfrac{3}{2}}=\altfrac{\lambda}{2x}\]
\qquad And here is \altfrac{x}{y} versus $\altfrac{x}{y}$\\

\end{document}

enter image description here

WARNING: if used in inline mode, the size of the / will possibly cause the line spacing to temporarily adjust. While this can be eliminated by \smash'ing the \scalebox, that could result in glyph overlap.

|improve this answer|||||

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.