2

Consider the following two equations:

\documentclass[a4paper,10pt,twoside]{article}
\usepackage{amsmath}
\begin{document}
\begin{alignat*}{3}
&\log(RT_{LKPijk}) &= &b_{0} + b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{5}x_{5i} + u_{ij} + w_{ik} + \epsilon_{ijk} \tag{1}\\
&\log(RT_{DCMPijk}) &= min[&b_{0} + b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{6}x_{6i} + u_{ij} + w_{ik} + \epsilon_{ijk}, \tag{2}\\
&&&b_{0} + b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{5}x_{5i} + \Delta p + u_{ij} + w_{ik} + \epsilon_{ijk}]
\end{alignat*}
\end{document}

I would like to align the log=-parts, the is equal symbols and the b_{1}. This is the best I achieved so far. But I cannot get it done. What am I doing wrong?

P.S.: How can I compile TeX-Code on tex.stackexchange?

enter image description here

Sebastiano
  • 54,118
hyhno01
  • 33

1 Answers1

2

Welcome to TeX SX! You must remember that 3 alignment points requires 5 ampersands: 1 for each alignment point, and 1 to introduce each column but the first. Also, your lines are a bit too long for the default layout, and I had to load geometry to have more decent margins. Last points: 10 pt is the default font size, and it is simpler to use alignat and \notag for the last line.

\documentclass[a4paper,twoside]{article}
\usepackage{amsmath}
\usepackage{geometry}

\begin{document}

\begin{alignat}{3} &\log(RT_{LKPijk}) & &= &b_{0} &+ b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{5}x_{5i} + u_{ij} + w_{ik} + \epsilon_{ijk} \[1ex] &\log(RT_{DCMPijk}) & &= \min[&b_{0} & + b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{6}x_{6i} + u_{ij} + w_{ik} + \epsilon_{ijk}, \ &&& & b_{0} & + b_{1}x_{1i} + b_{2}x_{2i} + b_{3}x_{3i} + b_{5}x_{5i} + \Delta p + u_{ij} + w_{ik} + \epsilon_{ijk}] \notag \end{alignat}

\end{document}

enter image description here

Bernard
  • 271,350