对齐元素数量不等的方程式

对齐元素数量不等的方程式

我有以下代码:

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb,amsmath,bm}

\begin{document}

        \begin{align*}
        \beta_{1t} &= \mu_1 + f_{11}\beta_{1,t-1} &+ f_{14}GDP_t + f_{15}FFR_t + f_{16}CPI_t + \eta_{1t}  \\
        \beta_{2t} &= \mu_{2,S_t} &+ f_{24}GDP_t + f_{25}FFR_t + f_{26}CPI_t + \eta_{2t} \\
        \beta_{3t} &= \mu_3 + f_{33}\beta_{3,t-1} &+ f_{34}GDP_t + f_{35}FFR_t + f_{36}CPI_t + \eta_{3t} \\
        GDP_t      &= &f_{44}GDP_{t-1} + \eta_{4t}  \\
        FFR_t      &= &f_{55}FFR_{t-1} + \eta_{5t}  \\
        CPI_t      &= &f_{66}CPI_{t-1} + \eta_{6t}  
        \end{align*}

\end{document} 

现在,我想将第 4 个到第 6 个方程中的变量排列在与前三个方程相同的列中(因此 GDP 位于 GDP 列下方,FFR 位于 FFR 列下方,等等)。

当方程式不具有相同数量的元素时,我不确定如何做到这一点。

答案1

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb, amsmath, bm}
\begin{document}
        \begin{alignat*}{8}
        \beta_{1t} &= \mu_1 + f_{11}\beta_{1,t-1} &{}+{}& f_{14}GDP_t 
                   &{}+{}& f_{15}FFR_t &{}+{}& f_{16}CPI_t &{}+{}& \eta_{1t}  \\
        \beta_{2t} &= \mu_{2,S_t} &{}+{}& f_{24}GDP_t &{}+{}& f_{25}FFR_t 
                   &{}+{}& f_{26}CPI_t &{}+{}& \eta_{2t} \\
        \beta_{3t} &= \mu_3 + f_{33}\beta_{3,t-1} &{}+{}& f_{34}GDP_t 
                   &{}+{}& f_{35}FFR_t &{}+{}& f_{36}CPI_t &{}+{}& \eta_{3t} \\
        GDP_t      &= && f_{44}GDP_{t-1} && &&&{}+{}& \eta_{4t}  \\
        FFR_t      &= && &&f_{55}FFR_{t-1}&& &{}+{}& \eta_{5t}  \\
        CPI_t      &= && && &&f_{66}CPI_{t-1} &{}+{}& \eta_{6t}  
        \end{alignat*}
\end{document} 

在此处输入图片描述

以下是使用 TABstack 的一种方法:

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb, amsmath, bm}
\usepackage{tabstackengine}
\TABstackMath
\begin{document}
\[
\setstackaligngap{0pt}
\TABbinary
\setstackgap{L}{1.2\baselineskip}
\alignCenterstack{
        \beta_{1t} &= \mu_1 + f_{11}\beta_{1,t-1} &+& 
                    f_{14}GDP_t &+& f_{15}FFR_t &+& f_{16}CPI_t &+& \eta_{1t}  \\
        \beta_{2t} &= \mu_{2,S_t} &+& f_{24}GDP_t &+& 
                    f_{25}FFR_t &+& f_{26}CPI_t &+& \eta_{2t} \\
        \beta_{3t} &= \mu_3 + f_{33}\beta_{3,t-1} &+& 
                    f_{34}GDP_t &+& f_{35}FFR_t &+& f_{36}CPI_t &+& \eta_{3t} \\
        GDP_t      &= && f_{44}GDP_{t-1} && &&&+& \eta_{4t}  \\
        FFR_t      &= && &&f_{55}FFR_{t-1}&& &+& \eta_{5t}  \\
        CPI_t      &= && && &&f_{66}CPI_{t-1} &+& \eta_{6t}  
}
\]
\end{document} 

在此处输入图片描述

答案2

您可以使用标准array;列间距设置为零;>{{}}c<{{}}操作符号周围的间距设置为正常间距。

我使用了一些\multicolumn命令来避免漏洞。

对于多字母变量最好使用\mathit

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath,array}

\newcommand{\var}[1]{\mathit{#1}}

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{1.5}
\newcommand{\mc}[1]{\multicolumn{3}{l}{#1}}
\begin{array}{ r *{6}{ >{{}}c<{{}} l } }
\beta_{1t}  &=& \mu_1 &+& f_{11}\beta_{1,t-1} &+& f_{14}\var{GDP}_t          &+& f_{15}\var{FFR}_t &+& f_{16}\var{CPI}_t &+& \eta_{1t}  \\
\beta_{2t}  &=& \mc{\mu_{2,S_t}}              &+& f_{24}\var{GDP}_t          &+& f_{25}\var{FFR}_t &+& f_{26}\var{CPI}_t &+& \eta_{2t} \\
\beta_{3t}  &=& \mu_3 &+& f_{33}\beta_{3,t-1} &+& f_{34}\var{GDP}_t          &+& f_{35}\var{FFR}_t &+& f_{36}\var{CPI}_t &+& \eta_{3t} \\
\var{GDP}_t &=&       & &                     & & \mc{f_{44}\var{GDP}_{t-1}}                       & &                   &+& \eta_{4t}  \\
\var{FFR}_t &=&       & &                     & & \mc{f_{55}\var{FFR}_{t-1}}                       & &                   &+& \eta_{5t}  \\
\var{CPI}_t &=&       & &                     & & \mc{f_{66}\var{CPI}_{t-1}}                       & &                   &+& \eta_{6t}  
\end{array}
\end{equation*}

\end{document} 

在此处输入图片描述

然而,对于这种特殊的结构,输入可以简化。

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath,array}

\newcommand{\var}[1]{\mathit{#1}}

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}
\renewcommand{\arraystretch}{1.5}
\begin{array}{ r *{3}{ >{{}}c<{{}} l } }
\beta_{1t}  &=& \mu_1 + f_{11}\beta_{1,t-1} &+& f_{14}\var{GDP}_t + f_{15}\var{FFR}_t + f_{16}\var{CPI}_t &+& \eta_{1t}  \\
\beta_{2t}  &=& \mu_{2,S_t}                 &+& f_{24}\var{GDP}_t + f_{25}\var{FFR}_t + f_{26}\var{CPI}_t &+& \eta_{2t} \\
\beta_{3t}  &=& \mu_3 + f_{33}\beta_{3,t-1} &+& f_{34}\var{GDP}_t + f_{35}\var{FFR}_t + f_{36}\var{CPI}_t &+& \eta_{3t} \\
\var{GDP}_t &=&                             & & f_{44}\var{GDP}_{t-1}                                     &+& \eta_{4t}  \\
\var{FFR}_t &=&                             & & f_{55}\var{FFR}_{t-1}                                     &+& \eta_{5t}  \\
\var{CPI}_t &=&                             & & f_{66}\var{CPI}_{t-1}                                     &+& \eta_{6t}  
\end{array}
\end{equation*}

\end{document} 

答案3

仅使用 4 列的变体alignat,其中一些mathrlap来自mathtools

\documentclass[11pt,a4paper]{article}
\usepackage{amssymb, mathtools, bm}

\begin{document}

    \begin{alignat*}{4}
         \beta_{1t} &= \mu_1 & + f_{11}\beta_{1,t-1} &{}+ f_{14}GDP_t & & + f_{15}FFR_t & & + f_{16}CPI_t + \eta_{1t} \\
         \beta_{2t} &= \mathrlap{\mu_{2,S_t}} & &{}+ f_{24}GDP_t & & + f_{25}FFR_t & & + f_{26}CPI_t + \eta_{2t} \\
         \beta_{3t} &= \mu_3 & + f_{33}\beta_{3,t-1} &{}+ f_{34}GDP_t & & + f_{35}FFR_t & & + f_{36}CPI_t + \eta_{3t} \\
         GDP_t &= & &\phantom{{}+{}} f_{44}\mathrlap{GDP_{t-1}+\eta_{4t}} \\
         FFR_t &= & & & & \phantom{{}+{}}f_{55}\mathrlap{FFR_{t-1} + \eta_{5t}} \\
         CPI_t &= & & & & & & \phantom{{}+{}} f_{66}CPI_{t-1} + \eta_{6t}
    \end{alignat*}

\end{document} 

在此处输入图片描述

相关内容