1

I'm writing a book beginning with \documentclass[11pt]{amsbook}. I have an item counter set up within sections and I want the cross-references to appear as follows:

In chapter number X, a reference to item 3 of section 2 in the same chapter should be 2.3 ; but a reference to item 3 of section 2 from a different chapter number Y should be Y.2.3 .

How can I do this?

\documentclass{amsbook}
 \newcounter{contRef}[section] 
\setcounter{contRef}{0}Thank you 
\renewcommand{\thecontRef}{\thesection.\arabic{contRef}}
\NewDocumentCommand \newItem{mo} {
 \IfNoValueTF {#2}
{\noindent\hskip-.07in\refstepcounter{contRef} {\bf#1}\textbf{ \thecontRef}}
{\noindent\hskip-.07in\refstepcounter{contRef} {\bf#1}\textbf{ \thecontRef}{\bf \hskip.05in#2} }
 }
\begin{document}
\chapter{(title)}
A reference to an item in this chapter from a location in this chapter should be of the form [section number].[item number].
\section{Section One in Chapter One}
\newItem{Definition}\label{def} This is a lemma that is references in this chapter as Definition \ref{def}.
\section{Section Two in Chapter One}
Here we refer to Definition  \ref{def}
Now scroll down to Chapter 2.
\chapter{(title)}
I want a reference from this chapter to the item labelled ``def'' in chapter 1 to have the form 1.1.1.
However, the present numbering system refers to it as Definition  \ref{def}.
\end{document}
  • Create two labels, like subcaption creates both \ref and \subref (same label name with "sub@" added). – John Kormylo Mar 30 '24 at 00:34
  • Welcome! Can you please add a short example of what you have up to now? How would you use the “item counter”? – egreg Mar 30 '24 at 14:11
  • I'm sure I've seen pretty much this same question before, but I haven't been able to find the one I am thinking about. Here are some other potentially relevant previous questions: https://tex.stackexchange.com/questions/472472/remove-section-number-in-references-to-theorems and https://tex.stackexchange.com/questions/317544/is-there-an-alternative-to-ref-or-eqref-that-omits-the-chapter-number-without – Willie Wong Mar 31 '24 at 01:47

0 Answers0