
Quero escrever uma equação em látex como a seguinte.
Mas não consigo alinhar completamente um conjunto de números com os coeficientes. Aqui está meu código:
\begin{equation}
\begin{aligned}
LNEP = & -0.23LNEER & +1.21LNCOST & +1.50LNFD & -1.03LNCP & -9.44 \\
& (0.12) & (0.13) & (0.27) & (0.37) & (1.33)
\end{aligned}
\end{equation}
Alguém poderia me ajudar, por favor? Muito obrigado.
Responder1
Você pode usar alignedat
.
\documentclass{article}
\usepackage{amsmath}
% Change the multiplication symbol to a centered dot.
\let\xtimes\times
\let\times\cdot
\begin{document}
\begin{equation}
\begin{alignedat}{5}
\mathrm{LNEP}
= -0&.23 \times \mathrm{LNEER} &{}
+ 1&.21 \times \mathrm{LNCOST} &{}
+ 1&.50 \times \mathrm{LNFD} &{}
- 1&.03 \times \mathrm{LNCP} &{}
- 9&.44 \\
(0&.12)&
(0&.13)&
(0&.27)&
(0&.37)&
(1&.33)
\end{alignedat}
\end{equation}
\end{document}
Por favor, não as alterações que fiz no seu código.
- Os nomes (se você tiver que usar variáveis com várias letras) devem estar no formato
\mathrm
. - Acho que a multiplicação implícita parece confusa com esses nomes, é melhor usá-la explicitamente.
- O
{}
entre&
e+
ou-
garante o espaçamento correto em torno dos operadores. - Ao contrário da sua imagem de exemplo, alinhei os números na vírgula decimal.
Responder2
Você esqueceu que n pontos de alinhamento requerem 2n – 1 e comercial. Proponho uma solução com alignedat{5}
, e outra, mais simples, com stackengine
, que não requer pontos de alinhamento:
\documentclass{article}
\usepackage{geometry}
\usepackage{mathtools}
\usepackage[usestackEOL]{stackengine}
\newcommand{\mystackunder}[2] {\stackMath\stackunder{#1}{\mathclap{#2}}}
\begin{document}
\begin{equation}
\begin{alignedat}[t]{5}
LNEP = -0.23&LNEER &{} +1.21 & LNCOST &{} +1.50 & LNFD &{} -1.03 & LNCP &{} -9.44 & \\
(0.12) & & (0.13) & & (0.27) & & (0.37) & & (1.33)
\end{alignedat}
\end{equation}
\bigskip
\begin{equation}%
LNEP = \mystackunder{-0.23}{(0.12)} LNEER +\mystackunder{1.21}{ (0.13)}LNCOST +\mystackunder{1.50}{(0.27)} LNFD -\mystackunder{1.03}{(0.37)} LNCP -\mystackunder{9.44}{(1.33)}
\end{equation}
\end{document}
Responder3
Mantenha juntos o coeficiente e a precisão. Isso permite que os parênteses tenham largura zero. Entre o coeficiente e a variável adicionei um espaço fino para melhor clareza.
\documentclass{article}
\usepackage{amsmath}
\newcommand{\cfac}[2]{% coefficient with accuracy
\begingroup\renewcommand{\arraystretch}{0.7}%
\begin{array}[t]{@{}r@{}}#1\\\makebox[0pt][r]{$($}#2\makebox[0pt][l]{$)$}\end{array}%
\endgroup
}
\newcommand{\tvar}[1]{\mathrm{#1}}
\begin{document}
\begin{equation}
\tvar{LNEP} =
\cfac{-0.23}{0.12}\,\tvar{LNEER} + \cfac{1.21}{0.13}\,\tvar{LNCOST} +
\cfac{1.50}{0.27}\,\tvar{LNFD} - \cfac{1.03}{0.37}\,\tvar{LNCP} - \cfac{9.44}{1.33}
\end{equation}
\end{document}