6

I have a case where I'm showing an integral of a fraction, but the integral sign doesn't stretch down to cover the entirety of the fraction:

incorrect

This results from the following MWE:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{equation*}
    \frac{3Q}{2\pi z^2} \displaystyle\int\frac{1}{\left( 1 + \dfrac{x^2 + y^2}{z^2} \right)^{\frac{5}{2}}}
\end{equation*}

\end{document}

The way I'm used to writing integrals looks more like this:

desired result

This question describes using packages like bigints and mtpro2 to scale the integral size. However, these appear to scale the integral sign relative to the location of the fraction's horizontal bar, which would not be the desired result here. Is there a way to get the integral to stretch to cover the entire fraction, as shown above? Also, I'd like to be able to set limits of the integration as well as the indefinite integral.

Note to the mathematicians out there - if I am violating some sort of typesetting convention with my request, please let me know. I'm not particularly well-versed with the convention used in mathematical circles for this sort of thing.

1

2 Answers 2

5

It is very uncharacteristic to typeset an integral sign uncentered at horizontal math axis. All variable-with math elements like braces, big operators etc are centered in traditional typography.

But if you wish such behaviour then, of course, it is possible. TeX is flexible. You can try the following macros, where \flexibleint macro is created. Usage is:

\flexibleint_a^b {integrand}   or    \flexibleint {integrand}

The integrand must be in braces.

\def\tmp#1 #2\relax{#1}
\setbox0=\hbox{$\xdef\intfont{%
    \expandafter\tmp\fontname\textfont3\expandafter\space\space\relax}$}
\font\tmp=\intfont\space at10pt\relax
\setbox0=\hbox{$\textfont3=\tmp \displaystyle \int$}
\dimen0=\ht0 \advance\dimen0 by\dp0 \divide\dimen0 by10 
\xdef\intsize{\the\dimen0}

\def\dividedimen (#1/#2){\expandafter\ignorept\the
   \dimexpr\numexpr\number\dimexpr#1\relax
   *65536/\number\dimexpr#2\relax\relax sp\relax
}
{\lccode`\?=`\p \lccode`\!=`\t  \lowercase{\gdef\ignorept#1?!{#1}}}

\def\flexibleint{\def\fxintL{}\def\fxintU{}\futurelet\next\fxintA}
\def\fxintA{\ifx\next_\expandafter\fxintB\else\expandafter\fxintC\fi}
\def\fxintB_#1{\def\fxintL{#1}\fxintC}
\def\fxintC{\futurelet\next\fxintD}
\def\fxintD{\ifx\next^\expandafter\fxintE\else\expandafter\fxintF\fi}
\def\fxintE^#1{\def\fxintU{#1}\fxintF}
\def\fxintF#1{\begingroup
   \setbox0=\hbox{$\displaystyle{#1}$}%
   \dimen0=\ht0 \advance\dimen0 by\dp0
   \setbox1=\hbox{$\vcenter{\copy0}$}%
   \font\tmp=\intfont\space at\dividedimen(\dimen0/\intsize)pt
   \lower\dimexpr\dp0-\dp1\hbox{%
      $\textfont3=\tmp \displaystyle\int_{\fxintL}^{\fxintU}$}
   \box0
   \endgroup
}

$$
  X = \sum_{i=0}^\infty 
      \flexibleint_a^b {u\over {\displaystyle v + {\strut x\over y}}}
$$

\bye

fxint

How it works: First, the fontname of \textfont3 (where \int sign is expected) is extracted at 10pt size (into \intfont) and the \int in \displaystyle at 10pt is measured (in \intsize).

Secondly, the scanning of _a or ^b is performed using auxiliary macros \fxintA to \fxintE.

Finally, the integrand in box is measured, its vertically different positions is compared using \box0 and \box1 (the second box is \vcentered), the font for \textfont3 scaled to desired size is temporary loaded and the flexible integral is typeset.

2
  • +1 for the preface, "It is very uncharacteristic to typeset an integral sign uncentered at horizontal math axis." Your screenshot confirms the wisdom of "conventional" typographic rules...
    – Mico
    Feb 28, 2018 at 11:20
  • Thanks. As I mentioned, I'm not familiar with typical typesetting practice, so it's nice to get advice from someone who is. I appreciate your thorough answer!
    – grfrazee
    Feb 28, 2018 at 11:49
8

While it's possible to make the integral symbol larger, I'd say that a much better solution would consist of making the denominator term smaller.

enter image description here

\documentclass{article}
\begin{document}
\[
\frac{3Q}{2\pi z^2} \int\frac{1}{[1+(x^2+y^2)/z^2{]}^{5/2}}
\]
\end{document}

Addendum: If it's important not to compresss the denominator material, consider using b^{-1} notation instead of \frac{1}{b} notation:

enter image description here

\documentclass{article}
\begin{document}
\[
\frac{3Q}{2\pi z^2} \int \biggl[ 1 + \frac{x^2 + y^2}{z^2} \biggr]^{-5/2}
\]
\end{document}
6
  • Thanks. Aside from the fact that it fits the integral sign better, is there any reason why this is "better?" I have other equations with much more complex fractions, so displaying it in this style won't be, in my opinion, very clear.
    – grfrazee
    Feb 26, 2018 at 7:29
  • But this is much more illegible for reader (I mean the compressed denominator). Typography may serve comfortable reading, not vice versa.
    – wipet
    Feb 26, 2018 at 7:32
  • @wipet - I've provided an addendum with an additional possible solution that doesn't require the integral symbol to be enlarged.
    – Mico
    Feb 26, 2018 at 8:23
  • @grfrazee - Depending on just how complicated the fractional expressions are, one may indeed have to enlarge the integral symbol. However, if the fractional expressions are (mostly) of the \dfrac{1}{<big long complicated expression>} form, rewriting them as [<big long complicated expression>]^{-1} may be the way to go. I've provided an addendum to illustrate how the resulting equation looks.
    – Mico
    Feb 26, 2018 at 8:39
  • 1
    @grfrazee In my opinion the integral sign should be vertically centered at the bar separating the numerator from the denominator. So you could use Mico's solution or an even larger integral sign. Feb 28, 2018 at 11:03

You must log in to answer this question.

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