
con este codigo
\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}
Tengo esta salida:
Sin embargo, me gustaría tener la siguiente alineación como en la imagen a continuación:
En los últimos días he hecho varias pruebas pero no lo he conseguido. Para otras fórmulas la alineación a la izquierda es muy buena. Con esta fórmula no puedo hacerlo.
Por último, ¿cómo puedo mejorar la forma de la integral de la segunda línea donde se resaltan los dos rectángulos verdes? Los corchetes no respetan la longitud del símbolo integral.
Respuesta1
Los ojos de mi matemático sangran cuando veo algo como
\frac{<whatever}{\sqrt{1-\dfrac{u^2}{c^2}}
aparecer más de una vez; Supongo que en tu documento aparece.muchosveces.
\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}
Debería haber unsoltero &
por línea.
También arreglé el uso de \left
y \right
cargado bm
que funciona mejor que amsbsy
y su \boldsymbol
comando, reemplazado por \bm
(pero \boldsymbol
funciona también).
Respuesta2
Aquí hay algunas sugerencias:
\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}
La primera sugerencia utiliza una integral extendida debigints
, pero visualmente pone demasiado énfasis. De ahí la segunda sugerencia, y utilizar una fracción menos intrusiva de la forma a/b.
Respuesta3
Primero, tenías símbolos innecesarios y faltaban otros.
Para dejar algunas ecuaciones alineadas, la forma más sencilla es utilizar el fleqn
entorno de nccmath
. Además, mejoré el diseño de la fila del medio usando el \mfrac
comando ( medium-sized
fracciones) en lugar 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}
Respuesta4
Un poco tarde para el juego, pero espero que siga siendo útil.
Además de colocar &
puntos de alineación donde son necesarios, el cambio principal con respecto al código de muestra es el uso de notación de fracciones en línea para los términos del denominador en la fila del medio. Por cierto, no es necesario \\
al final de la última fila de un aligned
entorno.
\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}