# How use the align environment to do this

I'm trying write this two equations

but I only get this:

with this code:

\documentclass[a4paper, 11pt]{article}
\usepackage[top=3cm, bottom=3cm, left=3cm, right=3cm]{geometry}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}anglosajones
\usepackage[none]{hyphenat}
\usepackage{float}
\usepackage{changepage}
\usepackage{booktabs}
\usepackage{pgfplots}
\usepackage{layouts}
\usepackage{caption}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{listings}

\begin{document}

\begin{align*}
Y_{1t}& + \beta_{12}Y_{2t}& + \gamma_{11} &+ \gamma_{12}X_{2t}& &+ \gamma_{14}X_{4t} = \mu_{1t}\\ \beta_{21}Y_{1t}& + Y_{2t}& + \gamma_{21} & &+ \gamma_{23}X_{3t} &+ \gamma_{24}X_{4t} = \mu_{2t}
\end{align*}

\end{document}


Any one can help me, please? I wanna reduce the space between the terms. I few a lot of time trying and I do not get it

• Welcome. // Please add the missing minimal code, starting with \documentclass{ , finishing with \end{document} . Makes it easier for all of us, as many times answers depend on your preamble. Jul 11 at 20:03
• This is a situation where array is usually a more easily controlled alternative than align (or even alignat). Some suggestions are given in answers to this question: tex.stackexchange.com/q/45568 Jul 11 at 20:52

You could get away with alignat, but it's simpler with array. Anyway, I'll show both methods

With array I define 15 columns, right aligned ones alternate with centered ones with empty atoms at either end for the operation or relation symbols.

For alignat* the syntax is similar, but there are a few subtle points to consider.

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

\begin{document}

\begin{equation*}
\setlength{\arraycolsep}{0pt}% let TeX use the right spacing
\begin{array}{
r
*{7}{>{{}}c<{{}}r}
}
Y_{1t} &+& \beta_{12}Y_{2t} &+& \gamma_{11} &+& \gamma_{12}X_{2t} && &+& \gamma_{14}X_{4t} &=& \mu_{1t}
\\[1ex]
\beta_{21}Y_{1t} &+& Y_{2t} &+& \gamma_{21} && &+& \gamma_{23}X_{3t} &+& \gamma_{24}X_{4t} &=& \mu_{2t}
\end{array}
\end{equation*}

\begin{alignat*}{7}
Y_{1t} &+{}& \beta_{12}Y_{2t} &+{}& \gamma_{11} &+{}& \gamma_{12}X_{2t} && &+{}& \gamma_{14}X_{4t} &= \mu_{1t}
\\
\beta_{21}Y_{1t} &+{}& Y_{2t} &+{}& \gamma_{21} && &+{}& \gamma_{23}X_{3t} &+{}& \gamma_{24}X_{4t} &= \mu_{2t}
\end{alignat*}

\end{document}


• Thanks you, I was getting crazy. Thanks a lot Jul 11 at 21:05
• In the question, the _2t and _3t are in different columns. (pedantic noodge.) Jul 11 at 21:11
• @barbarabeeton Yeah, right! Jul 11 at 21:22
• @barbarabeeton Yeah, I notice but I could add the empty space with an extra &. Now I have a new problem... who add two diferrent referrer, one for each equation... Meaby I will use the alignat enviroment because I don't get it with array Jul 11 at 21:25
• @Walras I fixed the alignment with both methods; if you need equation numbers, use alignat (no *). Jul 11 at 21:26

A solution with alignat*. Note it is not necessary to load amsmathwhen you load mathtools , since the latter does it for you.

    \documentclass[a4paper, 11pt]{article}
\usepackage[top=3cm, bottom=3cm, left=3cm, right=3cm]{geometry}
\usepackage[spanish]{babel}
\usepackage[none]{hyphenat}
\usepackage{float}
\usepackage{changepage}
\usepackage{booktabs}
\usepackage{pgfplots}
\usepackage{layouts}
\usepackage{caption}
\usepackage{lscape}
\usepackage{rotating}
\usepackage{amssymb}
\usepackage{mathtools}
\usepackage{listings}

\begin{document}

\begin{alignat*}{5}
Y_{1t}& + \beta_{12}Y_{2t} & & + \gamma_{11} & & + \gamma_{12}X_{2t}& & &{} + \gamma_{14}X_{4t} & = \mu_{1t}\\
\beta_{21}Y_{1t} &+ Y_{2t}& & + \gamma_{21} & & & & +\gamma_{23}X_{3t} &{}+ \gamma_{24}X_{4t} & = \mu_{2t}
\end{alignat*}

\end{document}