2

My code:

\documentclass{book}
\usepackage{amsmath}
\usepackage{hyperref}
\begin{document}

\chapter{Introduction}
\begin{equation}
  \label{a}
  1 + 1 = 2.
\end{equation}

\begin{equation}
  \label{b}
  2 + 2 = 4.
\end{equation}

\chapter{Elementary Results}
\begin{equation}
  \label{c}
  10 + 10 = 20.
\end{equation}

\begin{equation}
  \label{d}
  20 + 20 = 40.
\end{equation}

From \eqref{c} and \eqref{d} we get

\begin{equation}
  30 + 30 = 60.
\end{equation}

\end{document}

Here is how the document layout looks:

  • Chapter 1
    • Equation 1.1
    • Equation 1.2
  • Chapter 2
    • Equation 2.1
    • Equation 2.2
    • Two links to equations 2.1 and 2.2
    • Equation 2.3

What I want instead:

  • Chapter 1
    • Equation 1
    • Equation 2
  • Chapter 2
    • Equation 1
    • Equation 2
    • Two links to equations 1 and 2 of the current chapter (chapter 2)
    • Equation 3

Can this be achieved in LaTeX?

3
  • 1
    Have you tried \renewcommand\theequation{\arabic{equation}?
    – Mico
    May 26, 2021 at 6:43
  • How do you plan to reference equations in other chapters?
    – vonbrand
    May 26, 2021 at 15:30
  • 1
    As long as each equation gets a unique label, there should be no problems with hyperlinking. (Only possibly confusion for someone reading on paper. who isn't able to hyperlink.) May 26, 2021 at 18:58

1 Answer 1

2

Given that you're using the book document class, running

\renewcommand\theequation{\arabic{equation}

in the preamble is really all you need to apply to your test code in order to achieve your formatting objectives.

The following screenshot shows the output of the chapter-2 test material. You may verify easily that the cross-references "(1)" and "(2)" point to the equations on that page rather than at, say, the sample equations associated with chapter 1.

enter image description here

\documentclass{book}
\renewcommand\theequation{\arabic{equation}} % <-- new
\usepackage{amsmath}
\usepackage[colorlinks=true]{hyperref}
\usepackage[nameinlink,noabbrev]{cleveref}
\begin{document}

\chapter{Introduction}
\begin{gather}
  1 + 1 = 2. \label{a} \\
  2 + 2 = 4. \label{b}
\end{gather}

\chapter{Elementary Results}
\begin{gather}
  10 + 10 = 20.  \label{c} \\
  20 + 20 = 40.  \label{d}
\end{gather}
From \labelcref{c,d} we get
\begin{equation}
  30 + 30 = 60.
\end{equation}

\end{document}

You must log in to answer this question.

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