1

I would like to learn how auto-program my document to display integrals with fractions nicely.

My MWE:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\int_{\frac{1}{2}}^{\frac{\pi}{10}} \frac{x^2+x+1}{e^x +3}$ \vspace{1cm}

$\frac{x^2+x+1}{e^x+\frac{3}{2}}$ \vspace{1cm}

\end{document}

The result of the above MWE is : Integral with fractions as limit "not so nice display" Fraction without integrals "not so nice display"

What I would like to know is how do I program it so that if you have a limits with fractions use \tfrac for the limits but if you have a fraction on it own, use \dfrac.

Desired result:

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$\displaystyle\int_{\tfrac{1}{2}}^{\tfrac{\pi}{10}} \dfrac{x^2+x+1}{e^x +3}$ \vspace{1cm}

$\dfrac{x^2+x+1}{e^x+\dfrac{3}{2}}$ \vspace{1cm}

\end{document}

Desired Result

Any direction/advice will be greatly appreciated.

6
  • With only few exceptions, using \dfrac in the denominator (or numerator) of a \dfrac expression is bound to look preposterous. (The present case isn't one of those exceptions...) Do you have a reason for not using inline-fraction notation, i.e., for not writing \frac{x^2+x+1}{e^x+3/2}? On a related subject, have you considered writing either \int_{1/2}^{\pi/10} or \int_{0.5}^{0.1\pi}?
    – Mico
    Commented Oct 24, 2020 at 5:56
  • I need it to look nice, that why i avoid using the inline \frac. As for using \int_{1/2}^{\pi/10} or \int_{0.5}^{0.1\pi} it doesn't look nice.
    – Alan Jones
    Commented Oct 24, 2020 at 9:07
  • So \dfrac{3}{2} in the denominator looks nicer than 3/2. As the old saying goes, there's no arguing about taste...
    – Mico
    Commented Oct 24, 2020 at 9:10
  • \frac{3}{2} in the denominator looks crammed. What about the fraction in the integrals? \dfrac{x}{y} makes it look big.
    – Alan Jones
    Commented Oct 24, 2020 at 9:17
  • It does not follow from "\frac{3}{2}in the denominator looks cram[p]ed" that the best remedy is to use \dfrac{3}{2} in the denominator. Do compare, say, the outputs of \dfrac{x^2+x+1}{e^x+\frac{3}{2}}, \dfrac{x^2+x+1}{e^x+\frac{3\mathstrut}{2}}, and \dfrac{x^2+x+1}{e^x+\dfrac{3}{2}}.
    – Mico
    Commented Oct 24, 2020 at 10:51

0

You must log in to answer this question.

Browse other questions tagged .