在 latex 中编写方程式

在 latex 中编写方程式

我是 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

enter image description here

  • 数学环境中禁止使用空行
  • 环境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如下方法:

enter image description here

\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之间的区别!alignatalignedat

enter image description here

\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

enter image description here

\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*。结果是一样的。

enter image description here

\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} 

通过公式的枚举:

enter image description here

\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} 

相关内容