I was trying to fit this equation manipulation in a page as shown in the MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry} \geometry{a4paper,top=2.5cm,bottom=2.5cm,left=2cm,right=2cm,heightrounded,bindingoffset=5mm}
\usepackage{amsmath,cancel,witharrows}
\begin{document}
\noindent
some words
\begin{DispWithArrows*}
P(t|t)&=E\left[\tilde{e}_x(t)\tilde{e}_x^T(t)\right]\\
&=E\left[\big((I-K(t)C)e_x(t)-K(t)v(t)\big)\big((I-K(t)C)e_x(t)-K(t)v(t)\big)^T\right] \Arrow[i]{$e_x$ is uncorrelated with $v(t)$\\collect $E[e_x(t)e_x^T(t)]$ and $E[v(t)v^T(t)]$}\\
&=\big(I-K(t)C\big)E[e_x(t)e_x^T(t)]\big(I-K(t)C\big)^T+K(t)E[v(t)v^T(t)]K(t)\\
&=\big(I-K(t)C\big)P(t|t-1)\big(I-K(t)C\big)^T+K(t)R_vK^T(t)\\
&\begin{split}
=P(t|t-1)-P(t|t-1)C^TK^T(t)-K(t)CP(t|t-1)+\\
+K(t)CP(t|t-1)C^TK^T(t)+K(t)R_vK^T(t)
\end{split}
\Arrow[i]{in the 4th and 5th terms,\\factor out $K(t)$}\\
&\begin{split}
=P(t|t-1)-P(t|t-1)C^TK^T(t)-K(t)CP(t|t-1)+\\
+K(t)\big(CP(t|t-1)C^T+R_v\big)K^T(t)
\end{split}
\Arrow[i]{\eqref{eqn_kalman_filter_gain}}\\
&\begin{split}=P(t|t-1)-P(t|t-1)C^TK^T(t)-K(t)CP(t|t-1)+\\
+\underbrace{P(t|t-1)C^T\big(CP(t|t-1)C^T+R_v\big)^{-1}}_{=K(t)}\big(CP(t|t-1)C^T+R_v\big)K^T(t)\end{split}\\
&=P(t|t-1)\cancel{-P(t|t-1)C^T K^T(t)}-K(t)CP(t|t-1)\cancel{+P(t|t-1)C^TK^T(t)}\\
&=P(t|t-1)-K(t)CP(t|t-1)\Arrow[i]{factor out $P(t|t-1)$}\\
P(t|t)&=\big(I-K(t)C\big)P(t|t-1)
\end{DispWithArrows*}
some other words
\end{document}
Problem 1:
The text displayed with the package witharrows
and with the command \Arrow[i]{...}
falls off the right edge of the sheet, while the equation doesn't start immediately at left but in the center-left of the sheet, so it doesn't exploit all the available space.
Problem 2:
I tried to use the split
environment but it doesn't work very well because some equations don't start aligned with the others (I think it's because I don't use it properly) and because its efforts are useless due to problem 1.
If my description is not clear, the output of the MWE will be clearer:
How can I solve these problems?
Thanks in advance!
Best Answer
Solution to problem 1: Start the equation with
\begin{DispWithArrows*}[fleqn,mathindent=0pt]
. This typesets the equation flushed left. See the documentation of the packagewitharrows
for an explanation.Solution to problem 2: Precede the lines of the
split
environment with&
. The first column of asplit
environment is right-aligned, the second one left aligned. Moreover, add\quad
in lines that do not start with a relation symbol.