Tentei criar 2 eqnarray
s, mas as equações nesses 2 eqnarray
s não se alinham. Aqui está o código:
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{txfonts}
\begin{document}
\begin{eqnarray}
\label{eq1}
&& diag\frac{\partial P}{\partial \theta}=
diag(-diag(V)[Gdiag(V)\sin(Abus)^{T}-Bdiag(V)cos(Abus)^{T}]
\nonumber\\
&& -diag(V).^{2}diag(diag(B)))) \\
\label{eq2}
&& nondiag\frac{\partial P}{\partial \theta}=
VV^{T}.* G .* \sin(Abus) -VV^{T}.*B .* \cos(Abus)
\end{eqnarray}
Replace the diagnol elements of the (\ref{eq2}) with the elements of the
(\ref{eq1}), we will get the complete $\partial P/\partial \theta$
\begin{eqnarray}
\label{eq3}
&& diag\frac{\partial P}{\partial V}=
diag(Gdiag(V)\cos(Abus)^{T}+Bdiag(V)sin(Abus)^{T}
\nonumber\\
&& +diag(V)diag(diag(G)))) \\
\label{eq4}
&& nondiag\frac{\partial P}{\partial V}=
diag(V)G .* \cos(Abus) + diag(V)B .* \sin(Abus)
\end{eqnarray}
Replace the diagnol elements of the (\ref{eq4}) with the elements of the
(\ref{eq3}), we will get the complete $\partial P/\partial V$
\end{document}
E o resultado é: podemos ver que as posições iniciais da equação (1),(2) e da equação (3),(4) são diferentes. Como posso resolver esse problema? Obrigado.
Responder1
Substituir eqnarray
pelo align
resultado não está perfeitamente alinhado, mas parece que está e acho melhor do que com eqnarray
.
Seguindo a sugestão de Ian diag
e nondiag
são declarados operadores matemáticos. Também os tamanhos dos parênteses foram ajustados.
Após o comentário do Mico, um novo comando dotstar
foi declarado. Não está claro para mim o que isso faz.
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{txfonts}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\nondiag}{nondiag}
\newcommand\dotstar{\mathbin{.*}}
\begin{document}
\begin{align}
\label{eq1}
\diag\frac{\partial P}{\partial \theta} & =
\diag\left(-\diag(V)\left[Gdiag(V)\sin(Abus)^{T}-B\diag(V)cos(Abus)^{T}\right]\right.
\nonumber\\
&\quad \left.-\diag(V).^{2}\diag\left(\diag(B)\right)\right) \\
\label{eq2}
\nondiag\frac{\partial P}{\partial \theta} & =
VV^{T}\dotstar G\dotstar\sin(Abus)-VV^{T}\dotstar B\dotstar\cos(Abus)
\end{align}
Replace the diagnol elements of the (\ref{eq2}) with the elements of the
(\ref{eq1}), we will get the complete $\partial P/\partial \theta$
\begin{align}
\label{eq3}
\diag\frac{\partial P}{\partial V} & =
\diag\left(G\diag(V)\cos(Abus)^{T}+B\diag(V)sin(Abus)^{T}\right.
\nonumber\\
&\quad +\Bigl.\diag(V)\diag\left(\diag(G)\right)\Bigr) \\
\label{eq4}
\nondiag\frac{\partial P}{\partial V}&=
\diag(V)G\dotstar\cos(Abus) + \diag(V)B\dotstar\sin(Abus)
\end{align}
Replace the diagnol elements of the (\ref{eq4}) with the elements of the
(\ref{eq3}), we will get the complete $\partial P/\partial V$
\end{document}
Mas se você quiser que todas as equações estejam perfeitamente alinhadas, insira o parágrafo do meio dentro de um \intertext
comando.
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{txfonts}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\nondiag}{nondiag}
\newcommand\dotstar{\mathbin{.*}}
\begin{document}
\begin{align}
\label{eq1}
\diag\frac{\partial P}{\partial \theta} & =
\diag\left(-\diag(V)\left[Gdiag(V)\sin(Abus)^{T}-B\diag(V)cos(Abus)^{T}\right]\right.
\nonumber\\
&\quad \left.-\diag(V).^{2}\diag\left(\diag(B)\right)\right) \\
\label{eq2}
\nondiag\frac{\partial P}{\partial \theta} & =
VV^{T}\dotstar G\dotstar\sin(Abus)-VV^{T}\dotstar B\dotstar\cos(Abus)
%\end{align}
\intertext{Replace the diagnol elements of the (\ref{eq2}) with the elements of the
(\ref{eq1}), we will get the complete $\partial P/\partial \theta$}
%\begin{align}
\label{eq3}
\diag\frac{\partial P}{\partial V} & =
\diag\left(G\diag(V)\cos(Abus)^{T}+B\diag(V)sin(Abus)^{T}\right.
\nonumber\\
&\quad +\Bigl.\diag(V)\diag\left(\diag(G)\right)\Bigr) \\
\label{eq4}
\nondiag\frac{\partial P}{\partial V}&=
\diag(V)G\dotstar\cos(Abus) + \diag(V)B\dotstar\sin(Abus)
\end{align}
Replace the diagnol elements of the (\ref{eq4}) with the elements of the
(\ref{eq3}), we will get the complete $\partial P/\partial V$
\end{document}
Responder2
Nunca use eqnarray
(vejaeqnarray vs alinhar)
Aqui a combinação de align
com split
parece ser a melhor maneira de resolver o problema.
\documentclass{article}
\usepackage{mathtools}
\usepackage{newtxtext,newtxmath}
\DeclareMathOperator{\diag}{diag}
\DeclareMathOperator{\nondiag}{nondiag}
\newcommand{\dotstar}{\mathbin{.{*}}}
\newcommand{\Abus}{\mathit{Abus}}
\begin{document}
\begin{align}
\begin{split}
\diag\frac{\partial P}{\partial \theta} & =
\diag\bigl(-\diag(V)[G \diag(V)\sin(\Abus)^{T}-B\diag(V)\cos(\Abus)^{T}]\\
&\qquad -\diag(V)^{2}\diag(\diag(B))\bigr)
\end{split}
\label{eq1} \\
\nondiag\frac{\partial P}{\partial \theta} & =
VV^{T}\dotstar G\dotstar \sin(\Abus)-VV^{T}\dotstar B\cos(\Abus)
\label{eq2}\\
\intertext{%
By replacing the diagonal elements of the (\ref{eq2}) with the elements of
equation~\eqref{eq1}, we will get the complete $\partial P/\partial \theta$}
\begin{split}
\diag\frac{\partial P}{\partial V} & =
\diag\bigl(G\diag(V)\cos(\Abus)^{T}+B\diag(V)\sin(\Abus)^{T} \\
&\qquad +\diag(V)\diag(\diag(G))\bigr)
\end{split}
\label{eq3}\\
\nondiag\frac{\partial P}{\partial V}&=
\diag(V)G\dotstar \cos(\Abus) + \diag(V)B\dotstar \sin(\Abus)
\label{eq4}
\end{align}
By replacing the diagonal elements of equation~\eqref{eq4} with the elements of
equation~\eqref{eq3}, we will get the complete $\partial P/\partial V$
\end{document}
Substituí txfonts
por newtxtext
e newtxmath
(as fontes matemáticas são melhores e os pacotes são mantidos ativamente).
Se você adicionar a tbtags
opção à amsmath
equação, o número ficará alinhado com a linha inferior das split
peças.
Eu removi tudo \left
e \right
isso não serviu para nada (eles apenas adicionaram espaço horizontal indesejado). \big
São necessários apenas alguns pares.
Responder3
Usar intertexto em um ambiente de alinhamento obtém o alinhamento:
\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{txfonts}
\begin{document}
\begin{align}
\label{eq1}
& diag\frac{\partial P}{\partial \theta}=
diag(-diag(V)[Gdiag(V)\sin(Abus)^{T}-Bdiag(V)cos(Abus)^{T}]
\nonumber\\
& -diag(V).^{2}diag(diag(B)))) \\
\label{eq2}
& nondiag\frac{\partial P}{\partial \theta}=
VV^{T}.* G .* \sin(Abus) -VV^{T}.*B .* \cos(Abus)
\intertext{Replace the diagnol elements of the (\ref{eq2}) with the elements of the
(\ref{eq1}), we will get the complete $\partial P/\partial \theta$}
\label{eq3}
&diag\frac{\partial P}{\partial V}=
diag(Gdiag(V)\cos(Abus)^{T}+Bdiag(V)sin(Abus)^{T}
\nonumber\\
& +diag(V)diag(diag(G)))) \\
\label{eq4}
& nondiag\frac{\partial P}{\partial V}=
diag(V)G .* \cos(Abus) + diag(V)B .* \sin(Abus)
\end{align}
Replace the diagnol elements of the (\ref{eq4}) with the elements of the
(\ref{eq3}), we will get the complete $\partial P/\partial V$
\end{document}