与文本对齐

与文本对齐

我在对齐环境中输入了一些方程式,我想在它们下面写一些东西。但同时也希望它们对齐。特别是想象一下我想要或者我可以这样做

\begin{align}
\mathrm{E_{0}\sum_{t=0}^{\infty}} & \beta^t U(c_{it}) \;\;  \\
c_{it} + d_{it+1} + x_{it} & = y_{it} - w_tl_{it} + (1+r_t)d_{it}  \\ 
 \text{The budget constraint & of the entrepreneur} \nonumber \\
y_{it} & = f(k_{it}, l_{it}, z_{it})  \\
 \text{The technology that &  the entrepreneur operates} \nonumber \\
k_{it+1} & = x_{it} - (1-\delta)k_{it}  \\
\text{the linear technology &that transforms final goods to investment goods} \nonumber\\
d_{it} & \leq \theta k_{it} \\
\text{collateral & constraint} \nonumber \\
z_{it} & \sim \text{exogenous random process drawn from} \;\; \psi(z)
\end{align} 

当然,LaTeX 会给出错误,因为我在 \text{} 里面有 &。有人能提出一个 LaTeX 可以产生的替代方案吗?

答案1

您确定使用\intertext(或\shortintertext) 命令不是更好的选择吗?我看不出您的文本中需要对齐什么。无论如何,这是我的建议:

\documentclass{article}
\usepackage{mathtools}

\begin{document}

\begin{align}
    \mathrm{E_{0}\sum_{t=0}^{\infty}}  &  \beta^t U(c_{it}) \;\;  \\
    c_{it} + d_{it+1} + x_{it} & = y_{it} - w_tl_{it} + (1+r_t)d_{it}  \\
     \intertext{The budget constraint  of the entrepreneur}
    y_{it} & = f(k_{it}, l_{it}, z_{it})  \\
     \intertext{The technology that  the entrepreneur operates}
    k_{it+1} & = x_{it} - (1-\delta)k_{it}  \\
    \intertext{the linear technology that transforms final goods to investment goods}
    d_{it} & \leq \theta k_{it} \\
    \intertext{collateral constraint}
    z_{it} & \sim \text{exogenous random process drawn from} \;\;\psi(z)
\end{align}

\end{document} 

在此处输入图片描述

\shortintertext

在此处输入图片描述

答案2

\intertext命令就是您想要的。您可以将方程式保持在=~符号处对齐,而文本则位于它们之间。以下是 MWE 来说明\intertext命令的用法:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{align}
1 &=2\\
\intertext{aaa}
a+b&=c+d\\
\intertext{dont't forget that \begin{equation}1=1\end{equation}}
0.5&=\frac{1}{2}
\end{align}

\end{document}

输出为:

在此处输入图片描述

如果您也需要将文本居中,只需将其放在\centering括号内即可\intertext{\centering .....}

答案3

解决这个问题的一种方法是\text在 之前结束命令&并在 之后开始一个新命令&

为了使空格正确,请在新内容开头加\text{}一个空格。即\text{ text}。您的代码(使用测试pdflatex)将如下所示:

\begin{align}
    \mathrm{E_{0}\sum_{t=0}^{\infty}} & \beta^t U(c_{it}) \;\;  \\
    c_{it} + d_{it+1} + x_{it} & = y_{it} - w_tl_{it} + (1+r_t)d_{it}  \\ 
\text{The budget constraint} &\text{ of the entrepreneur} \nonumber \\
    y_{it} & = f(k_{it}, l_{it}, z_{it})  \\
\text{The technology that} &\text{ the entrepreneur operates} \nonumber \\
    k_{it+1} & = x_{it} - (1-\delta)k_{it}  \\
    \text{the linear technology} &\text{ that transforms final goods to investment goods} \nonumber\\
    d_{it} & \leq \theta k_{it} \\
\text{collateral} &\text{ constraint} \nonumber \\
    z_{it} & \sim \text{exogenous random process drawn from} \;\; \psi(z)
\end{align} 

相关内容