![如何修改eqnarray?](https://linux22.com/image/285323/%E5%A6%82%E4%BD%95%E4%BF%AE%E6%94%B9eqnarray%EF%BC%9F.png)
我目前正在使用 Texmaker 撰写数学本科论文,当我使用时eqnarray
。它不断将所有方程式向右对齐,但仍在中心?
我该如何改变它,让它们在左侧对齐(但仍在中心)?也就是说,让所有等号都对齐?例如:
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray}
\dfrac{d }{dx} \dfrac{y'}{\sqrt{1+(y')^2}} = 0\\
\Rightarrow \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}}=0\\
\Rightarrow \displaystyle\int_b^a \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} \,dx= constant = C\\
\Rightarrow f'(x) = \dfrac{C}{\sqrt{1-C^2}} = m\\
\Rightarrow \quad f(x) = mx+ \text{constant}
\end{eqnarray}
\end{document}
答案1
该eqnarray
环境旨在实现“左中右”对齐的方程数组。您必须用&
符号标记对齐方式(将每个更改=
为&=&
):
\dfrac{d }{dx} \dfrac{y'}{\sqrt{1+(y')^2}} &=& 0\\
\Rightarrow \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}}&=&0\\
\Rightarrow \displaystyle\int_b^a \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} \,dx= constant &=& C\\
\Rightarrow f'(x) = \dfrac{C}{\sqrt{1-C^2}} &=& m\\
\Rightarrow \quad f(x) &=& mx+ \text{constant}
\end{eqnarray}
但eqnarray
对于方程数组来说,这不是一个好的解决方案,因为方程项之间的间距与其他数学表达式中的间距不一致。使用amsmath
包和align
环境(这里,&
每个方程只需要一个):
\begin{align}
\dfrac{d }{dx} \dfrac{y'}{\sqrt{1+(y')^2}} &= 0\\
\Rightarrow \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}}&=0\\
\Rightarrow \displaystyle\int_b^a \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} \,dx= constant &= C\\
\Rightarrow f'(x) = \dfrac{C}{\sqrt{1-C^2}} &= m\\
\Rightarrow \quad f(x) &= mx+ \text{constant}
\end{align}
答案2
环境alignat
来自 »数学“使对齐更容易。并且”物理« 简化了衍生产品的排版。
\documentclass[11pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{physics}
\begin{document}
\begin{alignat}{2}
&& \dv{x}\,\frac{y'}{\sqrt{1+(y')^2}} &= 0 \\
\Rightarrow\qquad && \dv{x}\,\frac{f'(x)}{\sqrt{1+(f'(x))^2}} &= 0 \\
\Rightarrow\qquad && \int_b^a \dv{x} \frac{f'(x)}{\sqrt{1+(f'(x))^2}}\,\dd x &= \text{constant} = C \\
\Rightarrow\qquad && f'(x) &= \frac{C}{\sqrt{1-C^2}} = m \\
\Rightarrow\qquad && f(x) &= mx+\text{constant}
\end{alignat}
\end{document}
有关高级数学排版的更多信息,请参阅 »数学模式“ 文档。
答案3
一个可能的解决方案:
\documentclass{article}
\usepackage{amsmath}
\newcommand*\differential[1]{\mathop{}\!\mathrm{d}#1}
\newcommand*\diff[3][\differential]{\frac{#1#2}{#1#3}}
\begin{document}
\begin{alignat}{2}
&&\diff{}{x}\frac{y'}{\sqrt{1+(y')^{2}}}
&= 0\\
&\Rightarrow
&\diff{}{x}\frac{f'(x)}{\sqrt{1+(f'(x))^{2}}}
&= 0\\
&\Rightarrow\quad
&\int_{b}^{a} \diff{}{x}\frac{f'(x)}{\sqrt{1+(f'(x))^{2}}} \differential{x}
&= \text{constant}
= C\\
&\Rightarrow
&f'(x)
&= \frac{C}{\sqrt{1-C^{2}}}
= m\\
&\Rightarrow
&f(x)
&= mx + \text{constant}
\end{alignat}
\end{document}
注意:\mathrm
如果您不想让差速器d
直立,请将其移除。
(记得避免eqnarray
!。
更新
如果希望方程式之间有垂直箭头,可以使用以下方法:
\documentclass{article}
\usepackage{mathtools}
\newcommand*\differential[1]{\mathop{}\!\mathrm{d}#1}
\newcommand*\diff[3][\differential]{\frac{#1#2}{#1#3}}
\newcommand*\arrowDown{\ArrowBetweenLines[\Downarrow]}
\begin{document}
\begin{alignat}{2}
&&\diff{}{x}\frac{y'}{\sqrt{1+(y')^{2}}}
&= 0\\
\arrowDown
&&\diff{}{x}\frac{f'(x)}{\sqrt{1+(f'(x))^{2}}}
&= 0\\
\arrowDown
&&\int_{b}^{a} \diff{}{x}\frac{f'(x)}{\sqrt{1+(f'(x))^{2}}} \differential{x}
&= \text{constant}
= C\\
\arrowDown
&&f'(x)
&= \frac{C}{\sqrt{1-C^{2}}}
= m\\
\arrowDown
&&f(x)
&= mx + \text{constant}
\end{alignat}
\end{document}
答案4
您已在使用amsmath
:
\documentclass[11pt]{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\dfrac{d }{dx} \dfrac{y'}{\sqrt{1+(y')^2}} &= 0\\
\Rightarrow \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} &=0\\
\Rightarrow \displaystyle\int_b^a \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} \,dx &= constant = C\\
\Rightarrow f'(x) = \dfrac{C}{\sqrt{1-C^2}} &= m\\
\Rightarrow \quad f(x) &= mx+ \text{constant}
\end{align}
\end{document}
或者
\begin{align}
&&\dfrac{d }{dx} \dfrac{y'}{\sqrt{1+(y')^2}} &= 0\\
\Rightarrow &&\dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} &=0\\
\Rightarrow &&\displaystyle\int_b^a \dfrac{d }{dx} \dfrac{f'(x)}{\sqrt{1+(f'(x))^2}} \,dx &= constant = C\\
\Rightarrow &&f'(x) = \dfrac{C}{\sqrt{1-C^2}} &= m\\
\Rightarrow &&\quad f(x) &= mx+ \text{constant}
\end{align}
字符&
用于水平对齐。请参阅http://mirror.ctan.org/info/math/voss/mathmode/Mathmode.pdf
顺便说一下:eqnarray
语法如下:left & middle & right