19

I have an equation consisting of two parts and would like to use subequation for that. Here's the code:

\usepackage{amsmath}

\begin{subequations}
\begin{equation}
\operatorname{min}_{a,b,c} 
\frac{1}{2}\mathbf{w}^{T}\mathbf{w} + C \sum_{i=1}^{l}\xi_{i} 

\end{equation}
\begin{equation}
y_{i}\left(\mathbf{w}^{T}\phi(x_{i})+b\right)
\end{equation}

\end{subequations}

I'm getting an error:

final.tex:118:Missing $ inserted.
final.tex:118:Display math should end with $$.

Can anybody help with that?

Andrey Vihrov
  • 22,325
matcheek
  • 535

1 Answers1

30

Paragraph breaks (which are produced by empty lines, too) don't quite work in math mode. Once you remove the empty line, the code compiles fine:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{subequations}
\begin{equation}
  \operatorname{min}_{a,b,c} 
  \frac{1}{2}\mathbf{w}^{T}\mathbf{w} + C \sum_{i=1}^{l}\xi_{i} 
\end{equation}    
\begin{equation}
  y_{i}\left(\mathbf{w}^{T}\phi(x_{i})+b\right)
\end{equation}
\end{subequations}

\end{document}
Andrey Vihrov
  • 22,325
  • 1
    Thank you for a swift answer. I have spent two hours on looking for this error and found it by myself minute I posted my question here. – matcheek Mar 22 '11 at 08:09
  • 2
    BTW: use \min instead of \operatorname{min}, and it might be an idea to use the bm package and its \bm command for bold letters, then one gets bold italic not bold upright – daleif Mar 22 '11 at 10:05
  • 4
    another suggestion: instead of separate equations within subequations, it's generally better to use one of the amsmath multi-line display structures; in this instance i'd suggest gather. separate equations may not be spaced well vertically, and can break across pages. – barbara beeton Mar 22 '11 at 12:39
  • There is a good example of how to do this in the `Short Math Guide to LaTeX'. – erik Nov 17 '13 at 20:26