I am writing an equation in LYX and I get the error "Undefined control sequence" With the message

"The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), typeI' and the correct spelling (e.g., `I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined."

\batchmode
\makeatletter
\def\input@path{{C://Desktop}}
\makeatother
\documentclass[english]{book}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{setspace}
\doublespacing
\usepackage{babel}

\begin{document}
\begin{equation}
c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|}  {\rho(r)}dr]^{1/2}
\end{equation}
\end{document}

How to correct that?

  • 1
    Could you please provide a M(N)WE? – Rico Dec 25 '15 at 14:40
  • 1
    Or at the very least, we need to know which command is undefined. I.e. what is at the end of the top line. – Johannes_B Dec 25 '15 at 14:46
  • Often "undefined command" and such are due to errors elsewhere in equation environments (unclosed {, stray empty lines, missing/extra & or `\\`). – vonbrand Dec 25 '15 at 15:58
up vote 3 down vote accepted

Or simply add amsmath package in preamble of your document:

enter image description here

\documentclass[english]{book}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{setspace}
\doublespacing
\usepackage{babel}
\usepackage{amsmath}%<-- added or {mathtools}

    \begin{document}
\begin{equation}
c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|}  {\rho(r)}dr]^{1/2}
\end{equation}
    \end{document}

For my taste the nicer look of equation is obtained by

\begin{equation}
c=\alpha+\beta\left[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|}  {\rho(r)}\mathrm{d}r\right]^{1/2}
\end{equation}

i.e., similarly as suggested @egred in his answer.

enter image description here

The standard setup of LaTeX doesn't define \varOmega. Some font packages do.

If your aim is to get a slanted Omega, add

\providecommand{\varOmega}{\mathnormal{\Omega}}

Full example:

\documentclass[english]{book}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{geometry}
\geometry{verbose,tmargin=1.5cm,bmargin=2.5cm,lmargin=2.5cm,rmargin=2.5cm}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{setspace}
\doublespacing
\usepackage{babel}

\providecommand{\varOmega}{\mathnormal{\Omega}}

\begin{document}
\begin{equation}
c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|}  {\rho(r)}dr]^{1/2}
\end{equation}
\end{document}

enter image description here

Of course the formula should be typed as

\begin{equation}
c=\alpha+\beta\biggl[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|}  {\rho(r)}dr\biggr]^{1/2}
\end{equation}

that would produce

enter image description here

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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