2

I have an aligned set of very long equations that are difficult to split or shrink. I have tried three methods

  • using \begin{split} inside \begin{align} with ={}& and & for alignment and splitting - this ends up aligned left and looks confusing.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, mathtools}
\usepackage{graphicx}

\begin{document}

Placeholder sentence to designate how long lines are and therefore indicate the correct placement of the equation labels.
\begin{align}
\begin{split}\label{eq:deltaPOverP}
\frac{\Delta P}{P(\mathbf{\Gamma}|\mathbf{d}^t)} ={}&
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} 
\left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t) \right. \right. \right. \\
& \left. \left. \left. 
- \sum_n A_{mn}\Gamma_n
\right)^2
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{split}\\
\begin{split}\label{eq:deltaPOverPExpanded}
={}&
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)^2 \right. \right. \right. \\
& \left. \left. \left.
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{split}\\
\begin{split}\label{eq:deltaPOverPFactored}
={}&
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left(
-\frac{1}{2} \sum_m \frac{d_m(t)^2}{C_{\mu|m}}
\right) 
\exp 
\left[
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}} \right. \right.\\
& \left. \left. \left( 
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{split} 
\end{align}

\end{document}

Equations using split and align - using \begin{multlined} inside \begin{align} to try and align the second line of each equation to the right - this seems to align the second line just to the right of the previous line, rather than to the right of the page.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, mathtools}
\usepackage{graphicx}

\begin{document}

Placeholder sentence to designate how long lines are and therefore indicate the correct placement of the equation labels.
\begin{align}
\frac{\Delta P}{P(\mathbf{\Gamma}|\mathbf{d}^t)} &=
\begin{multlined}[t]\label{eq:deltaPOverP}
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} 
\left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t) \right. \right. \right. \\
\left. \left. \left. 
- \sum_n A_{mn}\Gamma_n
\right)^2
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{multlined}\\
&=\begin{multlined}[t]\label{eq:deltaPOverPExpanded}
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)^2 \right. \right. \right. \\
\left. \left. \left.
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{multlined}\\
&=\begin{multlined}[t]\label{eq:deltaPOverPFactored}
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left(
-\frac{1}{2} \sum_m \frac{d_m(t)^2}{C_{\mu|m}}
\right) 
\exp 
\left[
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}} \right. \right.\\
\left. \left. \left( 
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 
\end{multlined} 
\end{align}

\end{document}

Equations using multlined and align - using \begin{align} inside of \scalebox{0.6}{\parabox{1.7\textwidth}} to keep the equations on a single line each, and shrink the equation text - by varying the \parabox scale, I can shift where the equation labels go, but it of course doesnt shift the left hand edge so alignment is very difficult. Furthermore, to fit it all on a line, the \scalebox scale needs to be so prohibitively small that the equation, and particularly the equation labels, become unreadable.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, mathtools}
\usepackage{graphicx}

\begin{document}

Placeholder sentence to designate how long lines are and therefore indicate the correct placement of the equation labels. \\
\scalebox{0.6}{\parbox{1.7\textwidth}{%
\begin{align}
\label{eq:deltaPOverP}
\frac{\Delta P}{P(\mathbf{\Gamma}|\mathbf{d}^t)} &=
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} 
\left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)  
- \sum_n A_{mn}\Gamma_n
\right)^2
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 \\
\label{eq:deltaPOverPExpanded}
&=
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left[ 
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)^2 
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1 \\
\label{eq:deltaPOverPFactored}
&=
\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \left\{ 
\exp 
\left(
-\frac{1}{2} \sum_m \frac{d_m(t)^2}{C_{\mu|m}}
\right) 
\exp 
\left[
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( 
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\right]
\middle/
P(\mathbf{d}(t))
\right\} - 1  
\end{align}
}}

\end{document}

Equations using scalebox

I cannot substitute any terms (very important for this bit). I should have each term labeled but I would settle for labeling this entire block only once as they are, in fact, the same equation every time, just expanded.

\scalebox is currently producing the best results, but with the text so small, I dont know if it can work. I also dont like that the equation labels are much smaller than the other ones in my work.

Currently, I think my next preference is for \split, but only because \multlined does not align the second line to the right of the page, but just to the right of the previous line. If that could be fixed, \multlined might jump to first place.

I also welcome other suggestions for how to present these equations, where best to split them, and if there are any general conventions I should be aware of.

1
  • You say you cannot substitute any terms, but why not \[\frac{\Delta P}{P(\mathbf{\Gamma}|\mathbf{d}^t)} =\prod_m \frac{1}{\sqrt{2 \pi C_{\mu|m}}} \exp\{E\}/P(\mathbf{d}(t))\] and then align the rest?
    – Teepeemm
    Jan 11, 2020 at 14:32

1 Answer 1

1

I would pull the exponential into its own expression:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

Placeholder sentence to designate how long lines are and therefore indicate the correct placement of the equation labels.
\[
\frac{\Delta P}{P(\mathbf{\Gamma}|\mathbf{d}^t)}
=\prod_m \frac{\exp\{E\}}{\sqrt{2 \pi C_{\mu|m}}P(\mathbf{d}(t))}-1
\]
where
\begin{align}
E&=
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)
- \sum_n A_{mn}\Gamma_n
\right)^2
\\
&=
-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( \vphantom{\sum_n}
d_m(t)^2
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\\
&\begin{aligned}
=
-\frac{1}{2} \sum_m & \frac{d_m(t)^2}{C_{\mu|m}}
\\
&-\frac{1}{2} \sum_m \frac{1}{C_{\mu|m}}
\left( 
- 2d_m(t)\sum_n A_{mn}\Gamma_n + \left[\sum_n A_{mn}{\Gamma_n}\right]^2
\right)
\end{aligned}
\end{align}
\end{document}

pdf output

This makes it far easier (to me) to realize that only the exponential is changing. This way the first two expressions are short enough for their own line, and there's plenty of room in the third. I used aligned and inserted an arbitrary & to push the second line to the right (I agree that multlined would be better if I knew how to get it to right align to the larger box). (I'm also not sure if $-1$ is supposed to be in the product or not; that could use some parentheses: $\prod(X-1)$ or $(\prod X)-1$.)

4
  • I'd not use \left \right for the 1st pair of parenthesis. Maybe \Bigl \Bigr would fit better.
    – Sigur
    Jan 11, 2020 at 19:05
  • Thanks. Its certainly something I will keep in my back pocket. And I might be able to substitute the exponential terms here (though I am reluctant to as I have been asked to produce this a certain way). Unfortunately, I might still need some way of answering my question without substitution. The upcomming page or 2 of equations are hierarchical and might need to be verbose. Jan 11, 2020 at 23:46
  • @AlexHoward The other trick I often resort to is similar to your first approach, but putting one or more \qquad between the & and the expression on the continuing line.
    – Teepeemm
    Jan 13, 2020 at 2:49
  • Thanks, that might well be what I need for the next set. It looks like in the hand written notes I am copying from, the next set of equations are broken already and I might be able to use the same linebreaks and \quad to keep it looking nice. Will mark your answer as correct pending further comments and answers. Yours will solve 99% of people's problems with this issue. Jan 13, 2020 at 13:27

You must log in to answer this question.

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