我使用flalign
环境是因为我需要在一些方程式的左边添加一些文本(Level1、Level2)。现在,我想添加第三个方程式(β1j = γ10)。但是,这个方程式与前两个方程式不一致。
\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}
有什么想法可以让我使等式在等号处对齐,但仍然让文本位于前两个等式的左边?
谢谢
答案1
该&
字符用于对齐。我认为您希望在符号上对齐=
,因此您应该将“&”符号放在该位置:
\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}
生成:
答案2
你flalign
没有做任何真正有用的事情。
以下是两个认识:
\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}
随意选择。注意:showframe
仅用于显示文本块的边距。
以下是我希望看到的:
\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}