# Fitting unbreakable large equation on one line in a twocolumn layout

I have an equation in my document which is unbreakable and does not fit on one line using the twocolumn global option. Am I forced to shrink the text size here? And how do I go about doing it? \resizebox does not function in math mode.

\documentclass[twocolumn]{ltxdoc}
\usepackage{amsmath}
\begin{document}
$$\sum_{q_\mathrm{total}=0}^{q_A+N_A+q_B+N_B-2}\left(\sum_{q_A=0}^{q_\mathrm{total}}\left(\binom{q_A+N_A-1}{q_A}\binom{q_B+N_B-1}{q_B}\right)\right)x^{q_\mathrm{total}}$$
\end{document}

-
You can use \small or whatever works before the equation, or just simply introduce variables for the subterms so it fits –  David Carlisle Aug 20 '14 at 14:24

## 3 Answers

Resizebox should work.

\documentclass[twocolumn]{ltxdoc}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage{graphics}
\begin{document}
\lipsum[1]
$$\resizebox{0.5\textwidth}{!}{\sum_{q_\mathrm{total}=0}^{q_A+N_A+q_B+N_B-2}\left(\sum_{q_A=0}^{q_\mathrm{total}}\left(\binom{q_A+N_A-1}{q_A}\binom{q_B+N_B-1}{q_B}\right)\right)x^{q_\mathrm{total}}}$$
\lipsum[2-4]
\end{document}


Or maybe consider splitting your equation.

-
It's what the OP asked for, but arbitrarily scaling text so it fits in a space is so evil :-( –  David Carlisle Aug 20 '14 at 14:45
@DavidCarlisle From a typographic-aesthetic point of view? Or personal preference? –  1010011010 Aug 20 '14 at 19:25
@1010011010 All of above. It shouts as hey I couldn't fit it here so I scaled it, deal with it. Valid but says much about you instead of the equation :P –  percusse Aug 20 '14 at 19:54
@1010011010 just ask yourself how many professionally typeset works you have seen where text elements are using arbitrarily scaled fonts to make the element fit the space rather than one of a limited number of matched design sizes. –  David Carlisle Aug 20 '14 at 20:04
@1010011010 Not really. There is always a better way. Logical argument chain is never too complicated to state concisely. Similar to what @tohecz said, define n=q_a+N_A-1 and m=q_b+N_B-1 then you only need n and m for the sum limits and binomials (or whatever single letter abbreviation you wish). It should then fit. –  percusse Aug 20 '14 at 21:09

The cuted package (from the sttools bundle) can temporarily leave two columns mode with its strip environment. An example with the equation entered in the second column:

\documentclass[twocolumn]{ltxdoc}
\usepackage{mathtools, cuted}
\usepackage{lipsum, color}

\begin{document}
\lipsum[1-2]

\lipsum[1]

\textsf{\color{red}Equation entered here: }

\begin{strip}
$$\sum_{q_\mathrm{total}=0}^{q_A+N_A+q_B+N_B-2}\left(\sum_{q_A=0}^{q_\mathrm{total}}\left(\binom{q_A+N_A-1}{q_A}\binom{q_B+N_B-1}{q_B}\right)\right)x^{q_\mathrm{total}}$$
\end{strip}

Text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

\lipsum[3-5]
\end{document}


-
this example shows the wide display entered in the first column. the original question shows it occurring in the second column. can you adjust your example to reproduce that situation? –  barbara beeton Aug 20 '14 at 15:54
@barbara beeton: see my updated answer. –  Bernard Aug 20 '14 at 16:15

I don't think you have a much better option than this. Btw, you seem to use q_A for two different things.

\documentclass[twocolumn]{ltxdoc}
\usepackage{amsmath}
\begin{document}
$$\sum_{q_\mathrm{tot}=0}^{Q_A+Q_B-2}\sum_{q_A=0}^{q_\mathrm{tot}}{\textstyle\binom{Q_A-1}{q_A}\binom{Q_B-1}{q_B}}x^{q_\mathrm{tot}},$$
where $Q_A=q_A+N_A$ and $Q_B=q_B+N_B$.
\end{document}

-
@Mico Well, it doesn't hurt :p But you're right that it should not be there. Thanks for pointing out :) –  yo' Aug 20 '14 at 21:13