1

I get the missing $ inserted error(and many other errors like "missing } inserted") for the following code:

    \documentclass[11pt,oneside,onecolumn]{article}

    \usepackage{amsthm}
    \usepackage{verbatim}

    \begin{document}


    \begin{eqnarray}

    f(x)&=&\cos x\\
    f'(x)&=&-\sin x\\
    \int_0^xf(y)\ud y&=&\sin x

    \end{eqnarray}

    \end{document}

I have tried out different changes based on Googling for this error, but nothing seems to help. Any suggestions would be appreciated.

  • 2
    Welcome to TeX.Stackexchange! Please have a look at tex.stackexchange.com/questions/196/eqnarray-vs-align – samcarter_is_at_topanswers.xyz Aug 9 '18 at 13:58
  • 2
    You can't have empty lines in an eqnarray environment. Just remove the empty first and last line and things should compile provided you have defined \ud somewhere in your preamble. But as samcarter hints at, you should if at all possible avoid eqnarray and use align (the same thing about empty lines applies: they are not allowed). – moewe Aug 9 '18 at 14:01
3

You cannot have blank lines inside the eqnarray environment. Note also the use of \dd from the physics package. Besides, as indicated by @samcarter, align should be preferred.

enter image description here

\documentclass[11pt,oneside,onecolumn]{article}

\usepackage{amsthm}
\usepackage{physics}% for the differential operator \dd


\begin{document}

Using \texttt{eqnarray},
\begin{eqnarray}
  f(x)  &=& \cos x\\
  f'(x) &=& -\sin x\\
  \int_0^x f(y)\dd{y} &=& \sin x                       
\end{eqnarray}
and better, using \texttt{align},
\begin{align}
  f(x)  &= \cos x\\
  f'(x) &= -\sin x\\
  \int_0^x f(y)\dd{y} &= \sin x                       
\end{align}

\end{document}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.