3

I'm trying write this two equations enter image description here

but I only get this: enter image description here

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

Bernard
  • 271,350
Walras
  • 31
  • 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. – MS-SPO Jul 11 '22 at 20:03
  • 2
    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: https://tex.stackexchange.com/q/45568 – barbara beeton Jul 11 '22 at 20:52

2 Answers2

4

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}

enter image description here

egreg
  • 1,121,712
  • Thanks you, I was getting crazy. Thanks a lot – Walras Jul 11 '22 at 21:05
  • In the question, the _2t and _3t are in different columns. (pedantic noodge.) – barbara beeton Jul 11 '22 at 21:11
  • @barbarabeeton Yeah, right! – egreg Jul 11 '22 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 – Walras Jul 11 '22 at 21:25
  • @Walras I fixed the alignment with both methods; if you need equation numbers, use alignat (no *). – egreg Jul 11 '22 at 21:26
  • @egreg Yes, I do that with alignat because I couldn't do with array. Thanks you a lot! You saved me – Walras Jul 11 '22 at 21:28
4

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}&amp; + \beta_{12}Y_{2t} &amp; &amp; + \gamma_{11} &amp; &amp; + \gamma_{12}X_{2t}&amp; &amp; &amp;{} + \gamma_{14}X_{4t} &amp; = \mu_{1t}\\
\beta_{21}Y_{1t} &amp;+ Y_{2t}&amp; &amp; + \gamma_{21} &amp; &amp; &amp; &amp; +\gamma_{23}X_{3t} &amp;{}+ \gamma_{24}X_{4t} &amp; = \mu_{2t}
\end{alignat*}

\end{document} 

enter image description here

Bernard
  • 271,350