Math & ScienceReference to Equation fails

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
GustavMJ
Posts: 2
Joined: Tue Apr 16, 2013 12:54 pm

Reference to Equation fails

Post by GustavMJ »

Hi!

I'm totally new to both this forum and to LaTeX and have a question regarding equation numbering. I have used the command \label inside one of my equations, but later when I use the \eqref I get an error saying:
Undefined control sequence [...] 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'), type `I' and the correct spelling (e.g., `I\hbox').
I have checked so that the code is correctly spelled and everything looks fine, but still I get this error. My code looks like this.

Code: Select all

\begin{equation}
\label{eq:malus}
I_\theta = I_0 {\cos}^2 \theta
\end{equation}
Followed by \eqref{eq:malus}. I'm using the following packages and document class.

Code: Select all

\documentclass[11pt]{article}
\usepackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
\usepackage{graphicx}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

Thanks!
Last edited by localghost on Tue Apr 16, 2013 5:50 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Reference to Equation fails

Post by svend_tveskaeg »

You need to load the amsmath package.

Code: Select all

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{equation}
 \label{eq:malus}
  I_\theta = I_0\cos^2\theta
\end{equation}

Reference: \eqref{eq:malus}

\end{document}
Last edited by svend_tveskaeg on Tue Apr 16, 2013 5:59 pm, edited 2 times in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Reference to Equation fails

Post by localghost »

The \eqref command is provided by the amsmath package which you missed to load.


Further reading:

Best regards and welcome to the board
Thorsten
GustavMJ
Posts: 2
Joined: Tue Apr 16, 2013 12:54 pm

Re: Reference to Equation fails

Post by GustavMJ »

Ah, thanks :]
Post Reply