0

I'm using the flalign environment because I need to have some text (Level1, Level2) to the left of some equations. Now, I'd like to add a third equation (β1j = γ10). However, this equation does not align with the first two equations.

\begin{flalign} \begin{aligned} & \hspace{-3cm} \text{Level1:} & yij = \beta_{0j} + \beta_{1} x_{ij} + \epsilon_{ij} & \label{eq:L1} &\\ & \hspace{-3cm} \text{Level2:} & \beta_{0j} = \gamma_{00} + \gamma_{01 } z_{j}+ U_{0j} &\\ & & \hspace{-3cm} \beta_{1j} = \gamma_{10} &\\ \end{aligned} \end{flalign} 

Right now it looks like this: enter image description here

Any idea on how I can make the equations aligned at the equal signs, but still have the text to the left of the first two equations?

Thanks

1
  • 1
    Please allow a few hours to one or two days before accepting a solution in order to give the chance for other contributors to provide their solutions. Thanks. Commented Aug 2, 2023 at 21:35

2 Answers 2

0

The & character is used for alignment. I think you're looking to align on the = sign, so that's where you should be placing the ampersands:

\begin{flalign} \begin{aligned} & \hspace{-3cm} \text{Level1:} & yij &= \beta_{0j} + \beta_{1} x_{ij} + \epsilon_{ij} \label{eq:L1} \\ & \hspace{-3cm} \text{Level2:} & \beta_{0j} &= \gamma_{00} + \gamma_{01 } z_{j}+ U_{0j} \\ && \hspace{-3cm} \beta_{1j} &= \gamma_{10} \end{aligned} \end{flalign} 

produces:

output of above latex code

2
  • Ah, I thought that the & were for separating... But that makes much more sense. Thanks! Commented Aug 2, 2023 at 21:21
  • The third \hspace{-3cm} doesn't do anything useful and should therefore be omitted. As there's a single numbered equation, there's no need for the outer flalign environment; I suggest you employ an equation number instead. Finally, it may be confusing that the \label instruction is stuck inside the align environment; I'd place it right after \begin{equation} and before \begin{aligned}. Commented Aug 3, 2023 at 4:02
1

Your flalign does nothing really useful.

Here are two realizations:

\documentclass{article} \usepackage{amsmath} \usepackage{showframe} \begin{document} Really flush left, but requires an odd number of lines to get the equation number centered \begin{flalign} &\text{Level 1:} & y_{ij} &= \beta_{0j} + \beta_{1} x_{ij} + \epsilon_{ij} & \notag\\ &\text{Level 2:} & \beta_{0j} &= \gamma_{00} + \gamma_{01 } z_{j}+ U_{0j} & \label{test} \\ & & \beta_{1j} &= \gamma_{10} & \notag \end{flalign} Not really flush left, adjust manually the dimension to suit your taste (here it is three centimeters) \begin{gather}\label{eq:L1} \begin{alignedat}{2} &\makebox[0pt][r]{\makebox[3cm][l]{Level 1:}} & y_{ij} &= \beta_{0j} + \beta_{1} x_{ij} + \epsilon_{ij} \\ &\makebox[0pt][r]{\makebox[3cm][l]{Level 2:}} & \beta_{0j} &= \gamma_{00} + \gamma_{01 } z_{j}+ U_{0j} \\ & & \beta_{1j} &= \gamma_{10} \end{alignedat} \end{gather} \end{document} 

Take your pick. Note: showframe is only used to display the margins of the text block.

enter image description here

The following is what I'd like to see:

\documentclass{article} \usepackage{amsmath} \usepackage{showframe} \begin{document} Not flush left, but probably clearer about your intentions \begin{gather}\label{eq:L1} \begin{alignedat}{2} \makebox[0pt][r]{Level 1:\quad} && y_{ij} &= \beta_{0j} + \beta_{1} x_{ij} + \epsilon_{ij} \\ \makebox[0pt][r]{Level 2:\quad} && \beta_{0j} &= \gamma_{00} + \gamma_{01 } z_{j}+ U_{0j} \\ && \beta_{1j} &= \gamma_{10} \end{alignedat} \end{gather} \end{document} 

enter image description here

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.