使用此代码
\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}
我有这个输出:
但是,我希望有如下图所示的对齐方式:
这几天我做了几次测试,但都没有成功。其他公式左侧对齐效果很好。这个公式我做不到。
最后,我该如何改善第二行中两个绿色矩形突出显示的积分形状?方括号不符合积分符号的长度。
答案1
当我看到类似的东西时,我的数学家的眼睛流血了
\frac{<whatever}{\sqrt{1-\dfrac{u^2}{c^2}}
出现不止一次;我猜它出现在你的文档中许多次。
\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}
应该有一个单身的 &
每行。
\left
我还修复了and\right
和 loaded的使用bm
,其性能优于amsbsy
and 其命令,并用(但效果一样好)\boldsymbol
代替。\bm
\boldsymbol
答案2
以下是一些建议:
\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}
第一个建议使用扩展积分bigints
,但从视觉上看,它强调的重点太重了。因此,第二个建议是使用不太突兀的 a / b 形式的分数。
答案3
首先,您有不必要的“&”符号,并且其他符号也缺失了。
要使某些方程式左对齐,最简单的方法是使用fleqn
来自 的环境nccmath
。此外,我改进了中间行的布局,使用\mfrac
命令 (medium-sized
分数) 代替\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}
答案4
虽然有点晚了,但希望仍然有用。
除了将对齐点放置在需要的位置之外,与示例代码相比,主要变化是使用内联分数符号表示中间行中的分母项。顺便说一句,环境最后一行末尾&
不需要。\\
aligned
\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}