4

I have multiple equations with different labels (see below for MWE) that I would all like to align while being able to reference them separately. I have the following code:

\documentclass{article}
\usepackage{mathtools}

\begin{document}
    Equation \ref{eq:p1_m1} tests one model, equation \ref{eq:p1_m2} the extended model model and equation \ref{eq:p1_m3} a third one.
            \begin{align} \label{eq:p1_m1}
                ABC\textsubscript{n} &= \alpha\textsubscript{0} + \alpha\textsubscript{1} E\textsubscript{ij} + \alpha\textsubscript{2} E\textsubscript{ij} * F\textsubscript{i} + \varepsilon\textsubscript{i}
            \end{align}         
            \vspace{-.25cm}
            \begin{align} \label{eq:p1_m2}
                ABC\textsubscript{n} &=  \alpha\textsubscript{0} + \alpha\textsubscript{1} E\textsubscript{ij} + \alpha\textsubscript{2} E\textsubscript{ij} * F\textsubscript{i} \nonumber \\
                & \quad + \alpha\textsubscript{3} \Delta\textsubscript{G\textsubscript{ij}} + \varepsilon\textsubscript{i}
            \end{align}         
            \vspace{-.25cm}
            \begin{align} \label{eq:p1_m3}
            ABC\textsubscript{n} &=  \alpha\textsubscript{0} + \alpha\textsubscript{1} E\textsubscript{ij} + \alpha\textsubscript{2} E\textsubscript{ij} * F\textsubscript{i} \nonumber \\
            & \quad + \alpha\textsubscript{3} \Delta\textsubscript{G\textsubscript{ij}} + \alpha\textsubscript{4} E\textsubscript{ij} * G\textsubscript{nt} \nonumber \\
            & \quad + \alpha\textsubscript{5} E\textsubscript{ij} * F\textsubscript{i} * G\textsubscript{nt} + \alpha\textsubscript{6} \Delta\textsubscript{G\textsubscript{ij}} * G\textsubscript{nt} + \varepsilon\textsubscript{i}
            \end{align}
\end{document}

I would like (i) the equations to all align on the equal sign and (ii) be able to reference them as shown in the text. Additionally, I would like to be able to align all the \varepsilon signs in their respective columns. Can someone help me out and point me in the right direction?

3

To achieve the first part of your formatting objective, don't employ three independent align environments. Instead, employ a single align environment. (I must confess to not understanding the part about aligning the \varepsilon symbols.)

A separate comment/suggestion: You should not use \textsubscript to create subscripts in math mode. Instead, please use _.

I must further confess to not being sure what the * (asterisk) symbols are suppose to denote. If they denote multiplication, you should either replace them with \cdot symbols or, better still, just omit them entirely.

enter image description here

\documentclass{article}
\usepackage{mathtools}
\usepackage[noabbrev]{cleveref} % optional

\begin{document}
\Cref{eq:p1_m1} tests one model, \cref{eq:p1_m2} the extended model, and \cref{eq:p1_m3} a third one.
\begin{align}
     ABC_{n}
     &= \alpha_{0} + \alpha_{1} E_{ij} + \alpha_{2} E_{ij} * F_{i} + \varepsilon_{i}
     \label{eq:p1_m1}\\
     ABC_{n}
     &=  \alpha_{0} + \alpha_{1} E_{ij} + \alpha_{2} E_{ij} * F_{i} \nonumber \\
     &\quad + \alpha_{3} \Delta_{G_{ij}} + \varepsilon_{i}
     \label{eq:p1_m2}\\
     ABC_{n}
     &=  \alpha_{0} + \alpha_{1} E_{ij} + \alpha_{2} E_{ij} * F_{i} \nonumber \\
     &\quad + \alpha_{3} \Delta_{G_{ij}} + \alpha_{4} E_{ij} * G_{nt} \nonumber \\
     &\quad + \alpha_{5} E_{ij} * F_{i} * G_{nt} + \alpha_{6} \Delta_{G_{ij}} * G_{nt} + \varepsilon_{i}
     \label{eq:p1_m3}
\end{align}
\end{document}
2

Here is a proposition with alignat and \mathllap. I also suggest using _the commands from cleveref to save quite some typing with cross-references:

\documentclass{article}
\usepackage{mathtools}
\usepackage{cleveref}
\crefname{equation}{equation}{equations}

\begin{document}

            \Cref{eq:p1_m1} tests one model, \cref{eq:p1_m2,eq:p1_m3} the extended model and a third one respectively.



    \begin{alignat}{2} \label{eq:p1_m1}
                    ABC_{\mathrm{n}} &= \alpha_{0} + \alpha_{1} E_{\mathrm{ij}} + \alpha_{2} E_{\mathrm{ij}} * F_{\mathrm{i}} & &{} + \varepsilon_{\mathrm{i}}\\[1ex]
  \label{eq:p1_m2}
 ABC_{\mathrm{n}} &= \alpha_{0} + \alpha_{1} E_{\mathrm{ij}} + \alpha_{2} E_{\mathrm{ij}} * F_{\mathrm{i}} \notag \\
 & &\mathllap{{}+ \alpha_{3} \Delta_{G_{\mathrm{ij}}}} & + \varepsilon_{\mathrm{i}}\\[1ex]
      \label{eq:p1_m3}
 ABC_{\mathrm{n}} &= \alpha_{0} + \alpha_{1} E_{\mathrm{ij}} + \alpha_{2} E_{\mathrm{ij}} * F_{\mathrm{i}} \notag \\
 &\phantom{{}=} + \alpha_{3} \Delta_{G_{ij}} + \alpha_{4} E_{\mathrm{ij}} * G_{\mathrm{nt}} \notag\\
 & & \mathllap{{}+ \alpha_{5} E_{\mathrm{ij}} * F_{\mathrm{i}} * G_{\mathrm{nt}} + \alpha_{6} \Delta_{\mathrm{G_{\mathrm{ij}}}} * G_{\mathrm{nt}}} & {}+ \varepsilon_{\mathrm{i}}
                \end{alignat}

\end{document} 

enter image description here

3
  • +1. Do please replace all 41 instances of \textsubscript with _, though. – Mico Apr 27 '20 at 11:15
  • 1
    Yes, I wondered, as it was not directly related to the problem. Maybe the O.P. has some reason to have upright subscripts. – Bernard Apr 27 '20 at 11:20
  • 1
    @Mico: Even with regular expression, it was quite a job! – Bernard Apr 27 '20 at 11:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.