# Undefined control sequence while writing equation

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}
$$c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|} {\rho(r)}dr]^{1/2}$$
\end{document}


How to correct that?

• Could you please provide a M(N)WE? – Rico Dec 25 '15 at 14:40
• 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

Or simply add amsmath package in preamble of your document:

\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}
$$c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|} {\rho(r)}dr]^{1/2}$$
\end{document}


For my taste the nicer look of equation is obtained by

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


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

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

\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}
$$c=\alpha+\beta[\frac{1}{\varOmega}\int_{\varOmega}\frac{|\nabla\rho(r)|} {\rho(r)}dr]^{1/2}$$
\end{document}


Of course the formula should be typed as

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

that would produce