Um método universal para alinhamento à esquerda de uma sequência de igualdades

Um método universal para alinhamento à esquerda de uma sequência de igualdades

Com este código

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools, mathrsfs}

%% Code for '\widebar' macro is courtesy of
%% https://tex.stackexchange.com/a/60253
\makeatletter
\let\save@mathaccent\mathaccent
\newcommand*\if@single[3]{%
  \setbox0\hbox{${\mathaccent"0362{#1}}^H$}%
  \setbox2\hbox{${\mathaccent"0362{\kern0pt#1}}^H$}%
  \ifdim\ht0=\ht2 #3\else #2\fi
  }
%The bar will be moved to the right by a half of \macc@kerna, which is computed by amsmath:
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
%If there's a superscript following the bar, then no negative kern may follow the bar;
%an additional {} makes sure that the superscript is high enough in this case:
\newcommand*\widebar[1]{\@ifnextchar^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}
%Use a separate algorithm for single symbols:
\newcommand*\wide@bar[2]{\if@single{#1}{\wide@bar@{#1}{#2}{1}}{\wide@bar@{#1}{#2}{2}}}
\newcommand*\wide@bar@[3]{%
  \begingroup
  \def\mathaccent##1##2{%
%Enable nesting of accents:
    \let\mathaccent\save@mathaccent
%If there's more than a single symbol, use the first character instead (see below):
    \if#32 \let\macc@nucleus\first@char \fi
%Determine the italic correction:
    \setbox\z@\hbox{$\macc@style{\macc@nucleus}_{}$}%
    \setbox\tw@\hbox{$\macc@style{\macc@nucleus}{}_{}$}%
    \dimen@\wd\tw@
    \advance\dimen@-\wd\z@
%Now \dimen@ is the italic correction of the symbol.
    \divide\dimen@ 3
    \@tempdima\wd\tw@
    \advance\@tempdima-\scriptspace
%Now \@tempdima is the width of the symbol.
    \divide\@tempdima 10
    \advance\dimen@-\@tempdima
%Now \dimen@ = (italic correction / 3) - (Breite / 10)
    \ifdim\dimen@>\z@ \dimen@0pt\fi
%The bar will be shortened in the case \dimen@<0 !
    \rel@kern{0.6}\kern-\dimen@
    \if#31
      \overline{\rel@kern{-0.6}\kern\dimen@\macc@nucleus\rel@kern{0.4}\kern\dimen@}%
      \advance\[email protected]\dimexpr\macc@kerna
%Place the combined final kern (-\dimen@) if it is >0 or if a superscript follows:
      \let\final@kern#2%
      \ifdim\dimen@<\z@ \let\final@kern1\fi
      \if\final@kern1 \kern-\dimen@\fi
    \else
      \overline{\rel@kern{-0.6}\kern\dimen@#1}%
    \fi
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
%The following initialises \macc@kerna and calls \mathaccent:
  \if#31
    \macc@nested@a\relax111{#1}%
  \else
%If the argument consists of more than one symbol, and if the first token is
%a letter, use that letter for the computations:
    \def\gobble@till@marker##1\endmarker{}%
    \futurelet\first@char\gobble@till@marker#1\endmarker
    \ifcat\noexpand\first@char A\else
      \def\first@char{}%
    \fi
    \macc@nested@a\relax111{\first@char}%
  \fi
  \endgroup
}
\makeatother
%% End of code block for \widebar macro


\begin{document}
\[
\begin{aligned}
\mathscr F(\bar{r}(t))&=& \int_a^{b} L dt& =&\int_a^{b} \left[L \frac{dt}{d\tau}\right]d\tau=\\
=\int_a^{b} \Bigl[-mc^2-q\varphi\dfrac{1}{\sqrt{1-\dfrac{u^{2}}{c^{2}}}}+q\frac{\bar{u}\cdot \widebar{A}}{\sqrt{1-\dfrac{u^{2}}{c^{2}}}}\Bigr]  d\tau=& &&&\\
=\int_a^{b} \left[-mc^2+q\,\boldsymbol{\mathcal{U}}\cdot \boldsymbol{\mathcal{A}}\right] d\tau&&&&\\
\end{aligned}
\]
\end{document}

Eu tenho esta saída:

insira a descrição da imagem aqui

Porém, gostaria de ter o seguinte alinhamento conforme a imagem abaixo:

insira a descrição da imagem aqui

Nos últimos dias fiz vários testes mas não obtive sucesso. Para outras fórmulas o alinhamento à esquerda é muito bom. Com esta fórmula não consigo.

Por último, como posso melhorar a forma da integral da segunda linha onde os dois retângulos verdes estão destacados? Os colchetes não respeitam o comprimento do símbolo integral.

Responder1

Os olhos do meu matemático sangram quando vejo algo como

\frac{<whatever}{\sqrt{1-\dfrac{u^2}{c^2}}

aparecendo mais de uma vez; Eu acho que no seu documento aparecemuitosvezes.

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools, mathrsfs,bm}

\makeatletter
%<...long code omitted for brevity...>
\makeatother

\begin{document}
\[
\begin{aligned}
\mathscr F(\bar{r}(t))
&= \int_a^{b} L dt = \int_a^{b} \left[L \frac{dt}{d\tau}\right]\,d\tau=\\
&=\int_a^{b} [-mc^2-q\varphi\gamma(u)+q\bar{u}\cdot \widebar{A}\gamma(u)] \,d\tau=\\
&=\int_a^{b} [-mc^2+q\,\bm{\mathcal{U}}\cdot \bm{\mathcal{A}}] \,d\tau\\
\end{aligned}
\]
where
\[
\gamma(u)=\left(1-\frac{u^2}{c^2}\right)^{-1/2}
\]
\end{document}

Deveria haver umsolteiro &por linha.

Também corrigi o uso de \lefte \rightcarregado bmque tem melhor desempenho que amsbsyseu \boldsymbolcomando, substituído por \bm(mas \boldsymboltambém funciona).

insira a descrição da imagem aqui

Responder2

Aqui estão algumas sugestões:

insira a descrição da imagem aqui

\documentclass{article}

\usepackage{mathtools,mathrsfs,bm,bigints}

\begin{document}

\[
  \begin{aligned}
    \mathscr{F}(\bar{r}(t)) &= \int_a^b L \,\mathrm{d}t = \int_a^b \left[L \dfrac{\mathrm{d}t}{\mathrm{d}\tau} \right] \,\mathrm{d}\tau = \\
      &= \bigint_a^b \left[ -m c^2 - q \varphi \dfrac{1}{\sqrt{1 - \dfrac{u^2}{c^2}}} + 
        q \frac{\bar{u} \cdot \bar{A}}{\sqrt{1 - \dfrac{u^2}{c^2}}} \right] \,\mathrm{d}\tau = \\
      &= \int_a^b \bigl[ -m c^2 + q\,\bm{\mathcal{U}} \cdot \bm{\mathcal{A}} \bigr] \mathrm{d}\tau
  \end{aligned}
\]

\begin{align*}
  \mathscr{F}(\bar{r}(t)) &= \int_a^b L \,\mathrm{d}t = \int_a^b \left[L \dfrac{\mathrm{d}t}{\mathrm{d}\tau} \right] \,\mathrm{d}\tau = \\
    &= \int_a^b \bigl( -m c^2 - q \varphi / \sqrt{1 - u^2 / c^2} + 
      q (\bar{u} \cdot \bar{A}) / \sqrt{1 - u^2 / c^2} \,\bigr) \,\mathrm{d}\tau = \\
    &= \int_a^b \bigl( -m c^2 + q\,\bm{\mathcal{U}} \cdot \bm{\mathcal{A}} \bigr) \,\mathrm{d}\tau
\end{align*}

\end{document}

A primeira sugestão usa uma integral estendida debigints, mas coloca uma ênfase visual muito grande. Daí a segunda sugestão, e usar uma fração menos intrusiva da forma a/b.

Responder3

Primeiro você tinha e comerciais desnecessários e outros estavam faltando.

Para deixar algumas equações alinhadas à esquerda, a maneira mais simples é usar o fleqn ambiente de nccmath. Além disso, melhorei o layout da linha do meio, usando o \mfraccomando ( medium-sizedfrações) em vez de \dfrac.

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools, mathrsfs, nccmath}
\usepackage[showframe]{geometry}
\makeatletter
\let\save@mathaccent\mathaccent
\newcommand*\if@single[3]{%
  \setbox0\hbox{${\mathaccent"0362{#1}}^H$}%
  \setbox2\hbox{${\mathaccent"0362{\kern0pt#1}}^H$}%
  \ifdim\ht0=\ht2 #3\else #2\fi
  }
%The bar will be moved to the right by a half of \macc@kerna, which is computed by amsmath:
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
%If there's a superscript following the bar, then no negative kern may follow the bar;
%an additional {} makes sure that the superscript is high enough in this case:
\newcommand*\widebar[1]{\@ifnextchar^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}
%Use a separate algorithm for single symbols:
\newcommand*\wide@bar[2]{\if@single{#1}{\wide@bar@{#1}{#2}{1}}{\wide@bar@{#1}{#2}{2}}}
\newcommand*\wide@bar@[3]{%
  \begingroup
  \def\mathaccent##1##2{%
%Enable nesting of accents:
    \let\mathaccent\save@mathaccent
%If there's more than a single symbol, use the first character instead (see below):
    \if#32 \let\macc@nucleus\first@char \fi
%Determine the italic correction:
    \setbox\z@\hbox{$\macc@style{\macc@nucleus}_{}$}%
    \setbox\tw@\hbox{$\macc@style{\macc@nucleus}{}_{}$}%
    \dimen@\wd\tw@
    \advance\dimen@-\wd\z@
%Now \dimen@ is the italic correction of the symbol.
    \divide\dimen@ 3
    \@tempdima\wd\tw@
    \advance\@tempdima-\scriptspace
%Now \@tempdima is the width of the symbol.
    \divide\@tempdima 10
    \advance\dimen@-\@tempdima
%Now \dimen@ = (italic correction / 3) - (Breite / 10)
    \ifdim\dimen@>\z@ \dimen@0pt\fi
%The bar will be shortened in the case \dimen@<0 !
    \rel@kern{0.6}\kern-\dimen@
    \if#31
      \overline{\rel@kern{-0.6}\kern\dimen@\macc@nucleus\rel@kern{0.4}\kern\dimen@}%
      \advance\[email protected]\dimexpr\macc@kerna
%Place the combined final kern (-\dimen@) if it is >0 or if a superscript follows:
      \let\final@kern#2%
      \ifdim\dimen@<\z@ \let\final@kern1\fi
      \if\final@kern1 \kern-\dimen@\fi
    \else
      \overline{\rel@kern{-0.6}\kern\dimen@#1}%
    \fi
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
%The following initialises \macc@kerna and calls \mathaccent:
  \if#31
    \macc@nested@a\relax111{#1}%
  \else
%If the argument consists of more than one symbol, and if the first token is
%a letter, use that letter for the computations:
    \def\gobble@till@marker##1\endmarker{}%
    \futurelet\first@char\gobble@till@marker#1\endmarker
    \ifcat\noexpand\first@char A\else
      \def\first@char{}%
    \fi
    \macc@nested@a\relax111{\first@char}%
  \fi
  \endgroup
}
\makeatother

\begin{document}

\begin{fleqn}
\begin{align*}
\mathscr F(\bar{r}(t))&= \int_a^{b} L dt =\int_a^{b} \left[L \frac{dt}{d\tau}\right]d\tau=\\
 & =\int_a^{b} \Bigl[-mc^2-q\varphi\mfrac{1}{\sqrt{1-\mfrac{u^{2}\mathstrut}{c^{2}}}}+q\mfrac{\bar{u}\cdot \widebar{A}}{\sqrt{1-\mfrac{u^{2}}{c^{2}}}}\Bigr] d\tau=& &&&\\
 & =\int_a^{b} \left[-mc^2+q\,\boldsymbol{\mathcal{U}}\cdot \boldsymbol{\mathcal{A}}\right] d\tau\\
\end{align*}
\end{fleqn}

\end{document} 

insira a descrição da imagem aqui

Responder4

Um pouco atrasado para o jogo, mas espero que ainda seja útil.

insira a descrição da imagem aqui

Além de colocar &pontos de alinhamento onde eles são necessários, a principal mudança em seu código de exemplo é o uso da notação de fração embutida para os termos do denominador na linha do meio. Aliás, não há necessidade de \\no final da última fila de um alignedambiente.

\documentclass[a4paper,12pt]{article}
\usepackage{mathtools, mathrsfs, bm}

%% Code for '\widebar' macro is from https://tex.stackexchange.com/a/60253/5001
\makeatletter
\let\save@mathaccent\mathaccent
\newcommand*\if@single[3]{%
  \setbox0\hbox{${\mathaccent"0362{#1}}^H$}%
  \setbox2\hbox{${\mathaccent"0362{\kern0pt#1}}^H$}%
  \ifdim\ht0=\ht2 #3\else #2\fi
  }
%The bar will be moved to the right by a half of 
%\macc@kerna, which is computed by amsmath:
\newcommand*\rel@kern[1]{\kern#1\dimexpr\macc@kerna}
%If there's a superscript following the bar, then no 
%negative kern may follow the bar; an additional {} 
%makes sure that the superscript is high enough in 
%this case:
\newcommand*\widebar[1]{\@ifnextchar^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}}
%Use a separate algorithm for single symbols:
\newcommand*\wide@bar[2]{\if@single{#1}{\wide@bar@{#1}{#2}{1}}{\wide@bar@{#1}{#2}{2}}}
\newcommand*\wide@bar@[3]{%
  \begingroup
  \def\mathaccent##1##2{%
%Enable nesting of accents:
    \let\mathaccent\save@mathaccent
%If there's more than a single symbol, use the first 
%character instead (see below):
    \if#32 \let\macc@nucleus\first@char \fi
%Determine the italic correction:
    \setbox\z@\hbox{$\macc@style{\macc@nucleus}_{}$}%
    \setbox\tw@\hbox{$\macc@style{\macc@nucleus}{}_{}$}%
    \dimen@\wd\tw@
    \advance\dimen@-\wd\z@
%Now \dimen@ is the italic correction of the symbol.
    \divide\dimen@ 3
    \@tempdima\wd\tw@
    \advance\@tempdima-\scriptspace
%Now \@tempdima is the width of the symbol.
    \divide\@tempdima 10
    \advance\dimen@-\@tempdima
%Now \dimen@ = (italic correction / 3) - (Breite / 10)
    \ifdim\dimen@>\z@ \dimen@0pt\fi
%The bar will be shortened in the case \dimen@<0 !
    \rel@kern{0.6}\kern-\dimen@
    \if#31
      \overline{\rel@kern{-0.6}\kern\dimen@\macc@nucleus\rel@kern{0.4}\kern\dimen@}%
      \advance\[email protected]\dimexpr\macc@kerna
%Place the combined final kern (-\dimen@) if it is >0 or if a superscript follows:
      \let\final@kern#2%
      \ifdim\dimen@<\z@ \let\final@kern1\fi
      \if\final@kern1 \kern-\dimen@\fi
    \else
      \overline{\rel@kern{-0.6}\kern\dimen@#1}%
    \fi
  }%
  \macc@depth\@ne
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
  \macc@set@skewchar\relax
  \let\mathaccentV\macc@nested@a
%The following initialises \macc@kerna and calls \mathaccent:
  \if#31
    \macc@nested@a\relax111{#1}%
  \else
%If the argument consists of more than one symbol, 
%and if the first token is a letter, use that letter 
%for the computations:
    \def\gobble@till@marker##1\endmarker{}%
    \futurelet\first@char\gobble@till@marker#1\endmarker
    \ifcat\noexpand\first@char A\else
      \def\first@char{}%
    \fi
    \macc@nested@a\relax111{\first@char}%
  \fi
  \endgroup
}
\makeatother

\begin{document}
\[
\begin{aligned}
\mathscr{F} (\bar{r}(t))
&=\int_a^{b} \! L \,dt 
 = \int_a^{b} \Bigl[L \frac{dt}{d\tau}\Bigr] d\tau = \\
&=\int_a^{b} \biggl[-mc^2-q\varphi\frac{1}{\sqrt{1-u^2/c^2}}
+q\frac{\bar{u}\cdot \widebar{A}}{\sqrt{1-u^2/c^2}}\biggr]  d\tau = \\
&=\int_a^{b} [-mc^2+q\,\bm{\mathcal{U}}\cdot \bm{\mathcal{A}}\,]\, d\tau
\end{aligned}
\]
\end{document}

informação relacionada