带箭头的超长方程式操作

带箭头的超长方程式操作

我试图将这个方程式操作放入一个页面中,如 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}

问题 1: 使用包witharrows和命令显示的文本\Arrow[i]{...}超出了工作表的右边缘,而等式不是从左侧立即开始,而是从工作表的左中开始,因此它没有利用所有可用空间。

问题2: 我尝试使用该split环境,但效果不太好,因为有些方程式一开始与其他方程式不一致(我认为这是因为我没有正确使用它),而且由于问题 1,它的努力毫无用处。

如果我的描述不清楚,MWE 的输出会更清楚:

如果我的描述不清楚,MWE 的输出会更清楚

我该如何解决这些问题?

提前致谢!

答案1

问题1的解决方案:以 开始等式\begin{DispWithArrows*}[fleqn,mathindent=0pt]。这会将等式排版为向左对齐。请参阅包的文档witharrows以获取说明。

问题2的解决方案:split在环境行前面加上&。环境的第一列split右对齐,第二列左对齐。此外,添加\quad不以关系符号开头的行。

在此处输入图片描述

\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*}[fleqn,mathindent=0pt]
    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)+\\
        &\quad+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)+\\
        &\quad+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)+\\
      &\quad+\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}

答案2

好的,这是我的分析和解决方案建议。

首先,我通过宏引入了一些缩写,\def以便更好地了解你的结构。已经下文描述的改编如下:

% --- formulas ----------------------------------------------------
\def\ZA{E\left[\tilde{e}_x(t)\tilde{e}_x^T(t)\right]}
\def\ZB{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]}
\def\ZCa{\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)}
\def\ZCb{\big(I-K(t)C\big)P(t|t-1)\big(I-K(t)C\big)^T+K(t)R_vK^T(t)}
\def\ZD{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)}}
\def\AB{P(t|t-1)-K(t)CP(t|t-1)\Arrow[i]{factor out $P(t|t-1)$}}
\def\AA{P(t|t)&=\big(I-K(t)C\big)P(t|t-1)}
% --- split groups -------------------------------------------------------
\def\SG{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)}
\def\SH{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)}
\def\SK{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)}\times \\
    \times\big(CP(t|t-1)C^T+R_v\big)K^T(t)}
% --- arrow texts --------------------------------------------------------
\def\RA{$e_x$ is uncorrelated with\\ $v(t)$ collect\\ $E[e_x(t)e_x^T(t)]$ and\\ $E[v(t)v^T(t)]$}
\def\RB{in the 4th and 5th terms,\\factor out $K(t)$}
\def\RC{\eqref{eqn_kalman_filter_gain}}
% ------------------------------------

没有特别的命名。ZA..AB 只是你的公式,SG、SH 和 SK 在你的分割环境中,RA..RC 是箭头文本;&除了 之外,它们都不受 约束\underbrace。有了这个,你的方程组和你的结构就变成了:

\begin{DispWithArrows*}[format = ll]
    P(t|t)  &=\ZA\\
            &=\ZB \Arrow[i]{\RA}\\% \RA is too long
            &=\ZCa\\
            &=\ZCb\\
            &\begin{split}% line #5, continuing with '+'
                  =\SG
            \end{split}
            \Arrow[i]{\RB}\\
            &\begin{split}
                  =\SH
             \end{split}    
            \Arrow[i]{\RC}\\% unreferenced eqn, yields ??
            &\begin{split}
                =\SK
            \end{split}\\
            &=\ZD\\
            &=\AB\\
    \AA
\end{DispWithArrows*}

只需手动输入一些 '\' 换行符即可获得第一个箭头文本的解决方案,请参阅\def\RA.

\times对于问题 2,我建议按照所示分割线\def\SK,以便剩余的居中部分不会造成太大的干扰。

如您所见,我还在[format = ll]环境开头输入了语句DispWithArrows*,以确保对齐符合预期。因此%\noindent变得过时了...(完成)

仍然存在一些新问题,例如接触箭头#2 和#3。

至少编译两次后的结果

结果

完整代码,供大家参考

\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}

% --- formulas ----------------------------------------------------
\def\ZA{E\left[\tilde{e}_x(t)\tilde{e}_x^T(t)\right]}
\def\ZB{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]}
\def\ZCa{\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)}
\def\ZCb{\big(I-K(t)C\big)P(t|t-1)\big(I-K(t)C\big)^T+K(t)R_vK^T(t)}
\def\ZD{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)}}
\def\AB{P(t|t-1)-K(t)CP(t|t-1)\Arrow[i]{factor out $P(t|t-1)$}}
\def\AA{P(t|t)&=\big(I-K(t)C\big)P(t|t-1)}
% --- split groups -------------------------------------------------------
\def\SG{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)}
\def\SH{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)}
\def\SK{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)}\times \\
    \times\big(CP(t|t-1)C^T+R_v\big)K^T(t)}
% --- arrow texts --------------------------------------------------------
\def\RA{$e_x$ is uncorrelated with\\ $v(t)$ collect\\ $E[e_x(t)e_x^T(t)]$ and\\ $E[v(t)v^T(t)]$}
\def\RB{in the 4th and 5th terms,\\factor out $K(t)$}
\def\RC{\eqref{eqn_kalman_filter_gain}}
% ------------------------------------

\begin{document}
%\noindent
some words
\begin{DispWithArrows*}[format = ll]
    P(t|t)  &=\ZA\\
            &=\ZB \Arrow[i]{\RA}\\% \RA is too long
            &=\ZCa\\
            &=\ZCb\\
            &\begin{split}% line #5, continuing with '+'
                  =\SG
            \end{split}
            \Arrow[i]{\RB}\\
            &\begin{split}
                  =\SH
             \end{split}    
            \Arrow[i]{\RC}\\% unreferenced eqn, yields ??
            &\begin{split}
                =\SK
            \end{split}\\
            &=\ZD\\
            &=\AB\\
    \AA
\end{DispWithArrows*}
some other words

\end{document}

答案3

我提出这个代码,虽然不完美,但是使用fleqn选项并设置的值mathindent

我对代码进行了一些简化,将|条件概率的替换为\mid,这样间隔会更好。此外,出于同样的原因,将对替换为 。最后,我将\big( … \big)产生警告消息的环境替换为。\bigl(… \bigr)splitaligned

\documentclass[fleqn]{article}
\usepackage[a4paper, vmargin=2.5cm, hmargin=2cm, heightrounded, bindingoffset=5mm, showframe]{geometry}%
\usepackage{amsmath, cancel, witharrows}

\begin{document}

\noindent
some words
\begin{DispWithArrows*}[fleqn, mathindent=1em, wrap-lines, show-nodes]
    P(t\mid t)&=E\left[\tilde{e}_x(t)\tilde{e}_x^T(t)\right]\\
    &=E\left[\bigl((I-K(t)C)e_x(t)-K(t)v(t)\bigr)\bigl((I-K(t)C)e_x(t)-K(t)v(t)\bigr)^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)]$}}\\
    &=\bigl(I-K(t)C\bigr)E[e_x(t)e_x^T(t)]\bigl(I-K(t)C\bigr)^T+K(t)E[v(t)v^T(t)]K(t)\\
    &=\bigl(I-K(t)C\bigr)P(t\mid t-1)\bigl(I-K(t)C\bigr)^T+K(t)R_vK^T(t)\\
    &=\begin{aligned}[t]P(t\mid t-1) & -P(t\mid t-1)C^TK^T(t)-K(t)CP(t\mid t-1)+{\,}\\
        & +K(t)CP(t\mid t-1)C^TK^T(t)+K(t)R_vK^T(t)
    \end{aligned}
    \Arrow[i]{in the 4th and 5th terms,\\factor out $K(t)$}\\
    &=\begin{aligned}[t]P(t\mid t-1) & -P(t\mid t-1)C^TK^T(t)-K(t)CP(t\mid t-1)+{}\\
         & +K(t)\big(CP(t|t-1)C^T+R_v\big)K^T(t)
    \end{aligned}
    \Arrow[i]{\eqref{eqn_kalman_filter_gain}}\\
    &=\begin{aligned}[t]P(t &\mid t-1) -P(t\mid t-1)C^TK^T(t)-K(t)CP(t\mid t-1)+{}\\
     & +\underbrace{P(t\mid t-1)C^T\bigl(CP(t\mid t-1)C^T+R_v\bigr)^{-1}}_{=K(t)}\bigl(CP(t\mid t-1)C^T+R_v\bigr)K^T(t)
    \end{aligned}\\
    &=P(t\mid t-1)\cancel{-P(t\mid t-1)C^T K^T(t)}-K(t)CP(t\mid t-1)\cancel{+P(t\mid t-1)C^TK^T(t)}\\
    &=P(t\mid t-1)-K(t)CP(t\mid t-1)\Arrow[i]{factor out $P(t\mid t-1)$}\\
    P(t\mid t)&=\bigl(I-K(t)C\bigr)P(t\mid t-1)
\end{DispWithArrows*}
some other words

\end{document} 

在此处输入图片描述

相关内容