5

I'm relatively new to TeX/LaTeX, writing classroom notes. here's what I got:

\begin{equation} \label{eqn:constantspeed}
v=\frac{s}{t}
\end{equation}

It is very important to remember that Equation \ref{eqn:constantspeed} only works for objects moving at \emph{constant speed}. 

The pdf output has (3.1) as the number on the left side of the page where the equation is but in the text that follows, it shows "Equation 3". Please tell me what I'm doing wrong and how to make the numbers match. Thank you.

  • 3
    Please add to your question a complete minimal working example illustrating the problem. – Gonzalo Medina Mar 25 '12 at 3:56
  • to reinforce Gonzalo's comment, different document classes handle the equation referencing in different ways. identifying the document class and relevant packages is absolutely essential to solving the problem. – barbara beeton Mar 25 '12 at 13:20
2

The equation number is only 3.1, but the correct referring is (3.1), as you mention. To achieve this, we use \eqref{eqn:constantspeed} instead of \ref{eqn:constantspeed}. As well, in that case we usually omit the word Equation since the parentheses themselves stres that it's an equation reference.

  • 1
    I think the OP's main concern is the lack of congruence between the eqution's number as shown in the equation and as shown by \ref. – Mico Mar 25 '12 at 6:24
  • Sorry, I misread the question, you're right. – yo' Mar 25 '12 at 15:53
  • Interestingly I had the same problem as Celeste (\ref taking the section numbering even though \label was defined inside the equation environment) and moving from \ref to \eqref fixed it. – adunaic Jul 22 '16 at 15:13
2

Your example works fine in a standard \documentclass{book} environment. Just try

\documentclass{book}
\begin{document}
\chapter{}
\chapter{}
\chapter{}
\begin{equation} \label{eqn:constantspeed}
v=\frac{s}{t}
\end{equation}
It is very important to remember that Equation \ref{eqn:constantspeed} only works for objects moving at \emph{constant speed}. 
\end{document}

and you get Equation 3.1 as you want. This suggests that you have an old .aux file sitting around or you are including some other package in the preamble (before \begin{document}) that interferes with standard enumeration.

  • 1
    or some other document class than book – barbara beeton Mar 25 '12 at 13:18
2

There are two things which I infer from your question:

  • You want to have a reference like (1) and you do not mind typing Equation by yourself.

Solution: You can load amsmath or a better mathtools package and use Equation~\eqref{eqn:constantspeed}. This will produce Equation (1).

  • You do not want to type Equation by yourself but want it to be added automatically. But the parenthesis () can be sacrificed.

Solution: You can load hyperref and use \autoref{eqn:constantspeed}. This will produce Equation 1.

The following MWE illustrates these examples.

% ----------------------------------------------------------------
% BookClass (This is a LaTeX2e document)  ***********************
% ----------------------------------------------------------------
\documentclass{book}
\usepackage{mathtools,hyperref}
%-----------------------------------
\begin{document}
\chapter{First chapter}
\chapter{Second chapter}
\chapter{Third chapter}
%-----------------------------------
\begin{equation} \label{eq:constantspeed}
v=\frac{s}{t}
\end{equation}
%-----------------------------------
It is very important to remember that Equation~\eqref{eq:constantspeed} only works for   objects moving at \emph{constant speed}. This reference uses the \verb|\eqref{eq:constantspeed}| feature offered by \verb|amsmath| package.
\par
It is very important to remember that \autoref{eq:constantspeed} only works for objects moving at \emph{constant speed}. This reference uses the \verb|\autoref{eq:constantspeed}| feature offered by \verb|hyperref| package.
\end{document}
% ----------------------------------------------------------------

enter image description here

1

Had the same Problem once. The important thing is that you label your equation inside the equation environment. Otherwise \ref{eqn:x}, \autoref{eqn:x}, \eqref{eqn:x} will give you something else.

1.1 This works:

\begin{equation}\label{eqn:x}
v=\frac{s}{t}
\end{equation}

1.2 This too:

\begin{equation}
v=\frac{s}{t}\label{eqn:x}
\end{equation}

2. This will give you something else:

\begin{equation}
v=\frac{s}{t}
\end{equation}\label{eqn:x}
  • While the position statements are true, this does not answer the question, since it was about the reference format, not the reference source. In addition your suggestion is basically already in the document by the O.P., so there was no error regarding the positioning – user31729 Jul 3 '15 at 7:12

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.