# handling whitespace in denominator of complex fraction

I have a paper where I need to format a series of ugly 'fraction expressions' -- ugly because the term in the numerator is (often) a complex sum or series, and in order to get it to fit', I usually have to break the expression in the numeratorover 2 or more lines. Typically, I accomplish this using \splitfrac. The denominator for these equations is often simple say, a single term, or single-line expression.

But, a challenge arises if I want (or, more often, need) to bracket the whole equation, using (say) \left( and \right), I end up with lots of extra whitespace around the denominator.

One approach tried was embedding everything in a pmatrix -- this gets rid of the whitespace in the denominator, but, I can't quite figure out how to centre a coefficient at the line separating the numerator and denominator (the vinculum, to be semantic about it ;-)

And that is what I'm hoping to be able to work out -- I have a number of equations that might require such 'centering'.

The following MWE shows both the 'ugly' and 'somewhat better' versions. Suggestions welcomed -- thanks in advance.

 \documentclass[11pt]{article}

% set up basic package list
\usepackage{amsmath,amstext,mathtools,amssymb}

\begin{document}

One form of the equation -- ugly white space in denominator

\begin{equation*}
D = -2 \left(\dfrac{
\splitfrac{ \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \text{Pois}(y_i | \exp(\beta_0^{(t)}}
{+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)} x_{p,i})\bigr)}
} {T}\right)
\end{equation*}

Better form (IMO) of the equation, using pmatrix trick', but coefficient (-2) not centered
on horizontal line separating numerating and denominator:

\begin{equation*}
D=-2\begin{pmatrix} \dfrac{
\splitfrac{ \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \text{Pois}(y_i | \exp(\beta_0^{(t)}}
{+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)} x_{p,i})\bigr)}
} {T}
\end{pmatrix}
\end{equation*}

\end{document}

• there is no reason to load amstext and amsmath here, mathools will include amsmath which includes amstext Commented May 3, 2022 at 14:44

You could do the second (perhaps with a custom size bigger than Bigg) but I would do the third

\documentclass[11pt]{article}

% set up basic package list
\usepackage{mathtools,amssymb}

\begin{document}

One form of the equation -- ugly white space in denominator

\begin{equation*}
D = -2 \left(\dfrac{
\splitfrac{ \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \mathrm{Pois}(y_i | \exp(\beta_0^{(t)}}
{+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)} x_{p,i})\bigr)}
} {T}\right)
\end{equation*}

\begin{equation*}
D = -2 \raisebox{10pt}{$\Biggl($}\dfrac{
\splitfrac{ \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \mathrm{Pois}(y_i | \exp(\beta_0^{(t)}}
{+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)} x_{p,i})\bigr)}
} {T}\raisebox{10pt}{$\Biggr)$}
\end{equation*}

\begin{equation*}
D = -2
\Bigl( \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \mathrm{Pois}(y_i | \exp(\beta_0^{(t)}
+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)} x_{p,i})\bigr)\Bigr) /T
\end{equation*}

\end{document}

• Sure, I actually prefer your option (3), but (i) the MS is 2-column (not a lot of horizontal space), and (ii) the editors tell me they don't 'care for' use of the 'solidus' to display fractions (said editors being the same people who enjoy musing over whether or not anal compulsive should be hyphenated - I digress). But, thanks for the 'raisbox' suggestion. Might do the trick. Commented May 3, 2022 at 15:30

I can't see a reason for not factoring the T term out of the big term. If you must split the big term across two rows (possibly because your document employs a two-column layout), I would still factor out the T term.

Do note the use of \bigm\vert instead of |. Not only is the vertical bar taller, it is also spaced better.

\documentclass[11pt]{article}
\usepackage{mathtools,amssymb}
\DeclareMathOperator{\Pois}{Pois}
\begin{document}

\begin{equation*}
D=-\frac{2}{T} \biggl(\,
\sum_{t=1}^T \sum_{i=1}^n \log \bigl[ \Pois \bigl(\,y_i
\bigm\vert \exp(\beta_0^{(t)} +\beta_1^{(t)} x_{1,i}
+ \dots + \beta_p^{(t)} x_{p,i}) \,\bigr) \bigr]
\biggr)
\end{equation*}

\begin{equation*}
\begin{aligned}
D= -\frac{2}{T} \biggl(
&\sum_{t=1}^T \sum_{i=1}^n \log \bigl[ \Pois \bigl(\,y_i
\bigm\vert \exp(\beta_0^{(t)} \\
&+\beta_1^{(t)} x_{1,i}
+ \dots + \beta_p^{(t)} x_{p,i}) \,\bigr) \bigr] \smash[t]{\biggr)}
\end{aligned}
\end{equation*}
\end{document}


One possible answer/solution, which is a tweak of the 'raisebox' suggestion, might suffice...

   \begin{equation*}
\raisebox{-12pt}{$D = -2$} \begin{pmatrix} \dfrac{
\splitfrac{ \sum_{t=1}^T \sum_{i=1}^n \log \bigl( \text{Pois}(y_i |
\exp(\beta_0^{(t)}} {+\beta_1^{(t)} x_{1,i} + \ldots + \beta_p^{(t)}
x_{p,i})\bigr)}
} {T}
\end{pmatrix}
\end{equation*}


• yes although this is aligning the fraction "by eye" whereas if you raise the () the fraction is aligned as normal on the math axis automatically (with the () raised by eye) whether that's better or worse not saying, but it's different:-) Commented May 3, 2022 at 18:10
• Indeed -- it is different. I very much agree with the various comments that suggest more elegant approaches (for example, factoring out T from the expression, as suggested), but I am (as is often the case) at the mercies of the editorial types, who in some instances are slavishly devoted to some historical 'style convention', regardless of how silly it might seem. And in this instance, I would submit (and agree with the general view) that trying to cobble together an expression with 'big ugly' in the numerator and T in the denominator verges on silly). Commented May 4, 2022 at 13:06