![在 latex 中编写方程式](https://linux22.com/image/380047/%E5%9C%A8%20latex%20%E4%B8%AD%E7%BC%96%E5%86%99%E6%96%B9%E7%A8%8B%E5%BC%8F.png)
我是 Latex 新手。我尝试在 Latex 中写出这个方程式,但出现了以下错误:Missing $
\begin{equation} \label{tranfdc}
\begin{split}
T_v(s) &= \frac{V_{dc}(s)}{V_{dcref}(s)} &= \frac{\omega _B}{B}
\frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} +
\frac{k_{idc} \omega _B} {B}} \\
T_i(s) &= \frac{V_{dc}(s)}{i_{l}(s)} &= - \frac{\omega _B}{B} \frac{s} {s^2
+ \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}}
\end{split}
\end{equation}
答案1
- 数学环境中禁止使用空行
环境
split
每个方程式只允许一个 & 符号\documentclass[11pt]{book} \usepackage{amsmath} \begin{document} \begin{equation} \label{tranfdc} \begin{split} T_v(s) & = \frac{V_{dc}(s)}{V_{dcref}(s)} = \frac{\omega _B}{B} \frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}} \\ % T_i(s) & = \frac{V_{dc}(s)}{i_{l}(s)} = - \frac{\omega _B}{B} \frac{s} {s^2 + \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}} \end{split} \end{equation} \end{document}
答案2
看到您在原始 MWE 中尝试&
在每行添加两个符号,也许这意味着您试图在两点处对齐方程式?即您希望两组等号都对齐。
如果是这样,那么可以使用alignat
如下方法:
\documentclass[11pt]{book}
\usepackage{amsmath}
\begin{document}
\begin{alignat}{2}\label{tranfdc}
T_v(s) & = \frac{V_{dc}(s)}{V_{dcref}(s)}
&& = \frac{\omega _B}{B}
\frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} +
\frac{k_{idc} \omega _B} {B}} \\
%
T_i(s) & = \frac{V_{dc}(s)}{i_{l}(s)}
&& = - \frac{\omega _B}{B} \frac{s} {s^2
+ \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}}
\end{alignat}
\end{document}
如果您只想为这组方程式找到一个方程编号,则使用alignedat
和。请注意和equation
之间的区别!alignat
alignedat
\documentclass[11pt]{book}
\usepackage{amsmath}
\begin{document}
\begin{equation}
\begin{alignedat}{2}\label{tranfdc}
T_v(s) & = \frac{V_{dc}(s)}{V_{dcref}(s)}
&& = \frac{\omega _B}{B}
\frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} +
\frac{k_{idc} \omega _B} {B}} \\
%
T_i(s) & = \frac{V_{dc}(s)}{i_{l}(s)}
&& = - \frac{\omega _B}{B} \frac{s} {s^2
+ \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}}
\end{alignedat}
\end{equation}
\end{document}
答案3
除了修复两个语法错误((i)display-math 环境中的空白行;(ii)环境&
中的对齐点超过 1 个)之外split
,您可能还希望使方程式更具可读性。我建议您(a)不要\frac
在两个较长的分母项中使用宏(改用内联样式的分数符号)和(b)将变量名称(尤其是)呈现为数学斜体,以使字母间距更均匀,并“缩小”和及其各自下标项dcref
之间的间距。V
\omega
\documentclass{article}
\usepackage{amsmath} % for 'split' env.
\newcommand\vn[1]{\mathit{#1}} % "variable name"
\renewcommand\!{\mkern-1.5mu} % optional; default is "\mkern-3mu"
\begin{document}
\begin{equation} \label{tranfdc}
\begin{split}
T_v(s) &= \frac{V_{\!\vn{dc}}(s)}{V_{\!\vn{dcref}}(s)}
= \frac{\omega_{\!B}}{B} \frac{k_{\vn{pdc}}s + k_{\vn{idc}}} {s^2 + k_{\vn{pdc}} \omega_{\!B} s/B +
k_{\vn{idc}} \omega_{\!B}/B} \\
T_i(s) &= \frac{V_{\!\vn{dc}}(s)}{i_{l}(s)}
= - \frac{\omega_{\!B}}{B} \frac{s} {s^2 + k_{\vn{pdc}} \omega_{\!B} s/B + k_{\vn{idc}} \omega_{\!B}/B}
\end{split}
\end{equation}
\end{document}
答案4
我使用了不带枚举的选项align*
。结果是一样的。
\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}\label{tranfdc}
T_v(s) & = \frac{V_{dc}(s)}{V_{dcref}(s)} =
\frac{\omega _B}{B} \frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}} &\\
T_i(s) & = \frac{V_{dc}(s)}{i_{l}(s)} = - \frac{\omega _B}{B} \frac{s} {s^2
+ \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}}\\
\end{align*}
\end{document}
通过公式的枚举:
\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}
\begin{align}\label{tranfdc}
T_v(s) & = \frac{V_{dc}(s)}{V_{dcref}(s)} =
\frac{\omega _B}{B} \frac{k_{pdc}s + k_{idc}} {s^2 + \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}} &\\
T_i(s) & = \frac{V_{dc}(s)}{i_{l}(s)} = - \frac{\omega _B}{B} \frac{s} {s^2
+ \frac{ k_{pdc} \omega _B s} {B} + \frac{k_{idc} \omega _B} {B}}\\
\nonumber
\end{align}
\end{document}