# How to prevent inline math equation from being stretched?

I am working with a multicolumn document, in which I write a set of equations, and my tex file is producing equation that is stretched as follows

$(\int\limits_{-\infty}^\infty e^{-ax^2 + bx + c} =\sqrt{\dfrac{\pi}{a}} e^{b^2/4a + c})$


The length of the equation is exactly the width of the column. There are more equation that become stretched this way.

I do not have a minimum working example as I have discarded the original file and can't reproduce the condition for when it happened, but is there a general method for dealing with when an equation becomes stretched as above?

• it appears that the line that this expression was in was terminated abruptly immediately after the end of the math. in such a case it is not easily possible to keep it from stretching except by packing it in a box -- \mbox{...} would take care of that, but it would leave you with a short line and a warning about an underfull box. also, if the expression occurred near the end of a line, and might have been broken to allow justification of the line, it wouldn't break, and you would instead get an overfull box warning. unfortunately, without seeing the code, it's impossible to say more. Oct 15 '17 at 3:04
• Off-topic: You shouldn't be using \dfrac in an inline-math formula.
– Mico
Oct 15 '17 at 3:53
• I am unable to reproduce the issue you've encountered using solely the information provided so far. Please tell us which document class you employ and how wide the textblock is (in centimeters or inches).
– Mico
Oct 15 '17 at 3:57
• Summarizing some of the comments and answers: think more first about what your readers would find easiest before focussing on typesetting details. In general, the more TeX defaults you use the better, since Knuth designed TeX do do the right thing for most mathematics with not tinkering. In this case a displayed equation and \exp would probably be best. Oct 15 '17 at 12:51

There is a simple mechanism for this provided by TeX itself - just put {...} around the math expression (inside the dollars) that should not be broken or stretched.

\documentclass[twocolumn]{article}

\usepackage{amsmath}

\setlength\parindent{0pt}

\begin{document}

\emph{Original form}

aaaaaa aaaaaa
$(\int\limits_{-\infty}^\infty e^{-ax^2 + bx + c} =\sqrt{\dfrac{\pi}{a}} e^{b^2/4a + c})$
aaaaaa aaaaa aaaaa

\bigskip
\emph{New version}

aaaaaa aaaaaa
${(\int\limits_{-\infty}^\infty e^{-ax^2 + bx + c} =\sqrt{\dfrac{\pi}{a}} e^{b^2/4a + c})}$
aaaaaa aaaaa aaaaa

\end{document}


Whether this is good style in this example is another matter. In general you should be prepared to make larger math expressions into displays, particularly when the spacing in text is bad.

• After decades of using (fighting with?) latex... how did I not know this?? Thanks for the clear explanation. Apr 1 '20 at 17:57

It's not good typographic practice to use \int\limits and \dfrac in inline-math formulas. I would also use \exp(....) notation instead of e^{....} notation, and I would use inline-fraction notation instead of \frac (let alone \dfrac. I'm pretty sure your readers will agree. :-)

I've tried to approximate the narrow-column issue (and related stretching issue) you mentioned by using the document class option twocolumn and by surrounding the formulas with unbreakable letter combinations. Observe that \allowbreak may be used to indicate to TeX where additional line break possibilities should be entertained. Unfortunately, your original formula really only allows one interior line break possibility, and that's not enough to avoid severe overstretching.

\documentclass[twocolumn]{article}
\usepackage{amsmath} % for "\dfrac" macro
\setlength\parindent{0pt}
\begin{document}
\emph{Original form}

aaaaaa aaaaaa
$(\int\limits_{-\infty}^\infty e^{-ax^2 + bx + c} =\sqrt{\dfrac{\pi}{a}} e^{b^2/4a + c})$
aaaaaa aaaaa aaaaa

\bigskip
\emph{Alternative form}

aaaaaa aaaaaa
$\bigl(\int_{-\infty}^\infty \exp(-ax^2 + bx + c) =\allowbreak \sqrt{\pi/a}\cdot \allowbreak \exp(b^2/4a + c)\bigr)$
aaaaa aaaaa aaaaa
\end{document}

• @Sebastiano - Thanks!! (I'm pretty sure that both upvotes and downvotes are anonymous, i.e., the identity of the voter(s) is not revealed to the recipient.)
– Mico
Oct 16 '17 at 12:51
• My compliments for all. The upvote are gratis. :-) I vote always everybody because is important the help bad or good. Greetings. Oct 16 '17 at 20:36

If you have so bad line, the following:

$(\int\limits_{-\infty}^\infty e^{-ax^2 + bx + c} =\sqrt{\dfrac{\pi}{a}} e^{b^2/4a + c})$\hfill


at least moves undesired spaces to the end of line.

• The \hfill method doesn't always work. E.g., if one were to use it in the example given in my answer, the overstretching issue would persist.
– Mico
Oct 15 '17 at 4:29