# Aligning equations with unequal amount of elements

I have the following code:

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


Now, I would like to have the variables on the 4th until 6th equation to be aligned in the same column as done in the first three equations (so GDP underneath the GDP column, FFR underneath the FFR column etc.) .

I am not sure how this is done when the equations do not have the same amount of elements.

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


Here is a way with a 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}


• Thank you very much. – Matthew Dec 11 '19 at 14:49

You can use a standard array; the intercolumn space is set to zero; with >{{}}c<{{}} the spacing around the operation signs is set to the normal one.

I used a few \multicolumn command to avoid holes.

For multiletter variables it's better to use \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}


However, for this particular structure, the input can be simplified.

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


A variant using alignat with only 4 columns, and some mathrlap from 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}