2

I want a fraction of derivatives, so I use this code:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xfrac}
\begin{document}
    Good: $\sfrac{4}{5}$
    
    Not good: $ \sfrac{\dfrac{dy}{dt}}{\dfrac{dx}{dt}} $
\end{document}

As you can see, the result is not very beautiful:

enter image description here

At the first fraction 4 is in a higher level than 5. But it is the opposite at the second fraction.

How can I solve this problem?

Thanks in advance!

1
  • 1
    \sfrac uses \scriptstyle, while \dfrac uses \displaystyle. The other two sizes are \textstyle and \scriptscriptstyle. Feb 22 at 15:28

1 Answer 1

7

The sole purpose of using \sfrac is to typeset fractions more compactly than is possible with \frac. Using \dfrac in the arguments of \sfrac flies in the face of using \sfrac to begin with.

If you simply must use fractional expressions in the arguments of \sfrac, do give \sfrac{\frac{dy}{dt}}{\frac{dx}{dt}} a try, i.e., use \frac (or \tfrac) instead of \dfrac. However, just omitting the \sfrac wrapper and thus writing \frac{dy}{dt} \big/ \frac{dx}{dt} would appear to be a better alternative.

enter image description here

\documentclass{article}
\usepackage{amsmath,xfrac,array}
\begin{document}
\renewcommand\arraystretch{2}

\begin{tabular}{l >{$}l<{$}}
 Sort of OK     & \sfrac{4}{5} \\
 Terrible       & \sfrac{\dfrac{dy}{dt}}{\dfrac{dx}{dt}} \\
 Still not good & \sfrac{\frac{dy}{dt}}{\frac{dx}{dt}} \\
 Better         & \frac{dy}{dt} \big/ \frac{dx}{dt}
\end{tabular}

\end{document}
1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .