0
\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\title{Test File}
\author{test}
\date{\today}
\begin{document}
\maketitle
\section{Introduction}
This is the Introduction.
\subsection{Some further intoduction}
equation: 
\begin{equation}
a^{-n}=\frac{1}{a^{n}} 
\end{equation}

Whatever... For this reason... \eqref{eq:1}
\end{document}

When compiling this code, I get questionmarks in parantheses instead of a reference, but when I replace \eqref with \ref , it works (obviously without parentheses) Anyone know why?

2
  • 2
    \eqref{eq:1} would reference the equation with \label{eq:1} but you have no such label. It is best to avoid numbers, use \label{eq:myfrac} in the equation, then \eqref{eq:myfrac} (\ref would not work and give the same error as \eqref) Dec 20, 2020 at 13:12
  • Thank you very much! Dec 20, 2020 at 13:18

2 Answers 2

4

\eqref{eq:1} would reference the equation with \label{eq:1} but you have no such label.

It is best to avoid numbers, use \label{eq:myfrac} in the equation, then \eqref{eq:myfrac} (Despite your comment in the question, \ref would not work, and would give the same error as \eqref on an undefined label.)

2
  • I hadn´t saved it with \ref before I compiled, thats why no errow occured. My fault Dec 20, 2020 at 13:29
  • @Talkingstreet note a label such as eq:1 works but is confusing (to humans looking at the source, not to latex) as it has no relation to the printed equation number, as you edit the text that equation might end up being equation 3 but if you label it eq:1 then you reference it as ref{eq:1} it produces 3 which is consistent but not what a casual reader of the tex source might expect. Dec 20, 2020 at 13:33
1

One of the general advantages of LaTeX is that you can give things like figures, equations, tables, chapters, sections etc. labels with a name that means something to you, and when you compile that document LaTeX automatically assigns numbers to all of these things and inserts the correct numbers for all references.

When you are writing only a short document this step may seem as extra work to you, but once you start writing something longer, like a thesis, you will be really glad that you can insert or delete something on the top without having to change the numbering in the entire document by hand.

\begin{equation} \label{eqn:negative_power}
a^{-n}=\frac{1}{a^{n}} 
\end{equation}

Half of my students cannot understand equation \ref{eqn:negative_power} despite my best efforts. 

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .