0

I'm working to a document in which I would need a particular crossing reference (I know it sound strange but I have a strong reason to look at this). I'd like to know how can I write the preamble in a way such that when I write

\section{Ciao}

Interesting equation: \begin{equation}\label{ab} a=b \end{equation}

\section{Ciao ciao}

Another Interesting equation \begin{equation} c=d \end{equation} and another equation too \begin{equation}\label{ef} e=f \end{equation} Now consider \eqref{ab} and \eqref{ef}

I don't get

enter image description here

but instead I get

enter image description here

In other words I'd need to start equation counter in each section from 1, and this is easily doable adding \usepackage{chngcntr} \counterwithin*{equation}{section} to preamble, but I'd also need that when cross referencing goes to an equation in another section, it write the section inside parenthesis in that way (or in some other way that reader can understand to go correctly to the equation referred). Is there a simple way to do this? Thank you!

Bernard
  • 271,350
  • 2
    You want to work hard in order to confuse your readers, don't you? There won't always be a section number on the page to guide them. Also using headers is not foolproof. – egreg Jun 17 '21 at 20:24
  • I know it sounds strange but trust me, it's best for the type of document I'm working on, which has strictly one section per page, for reasons I don't want to go into here. – Fausto Vezzaro Jun 17 '21 at 22:02
  • 2
    you can build complex references with zref, see e.g. https://tex.stackexchange.com/a/325319/2388 – Ulrike Fischer Jun 17 '21 at 22:24

1 Answers1

1

The code snippets of the question are incomplete, adding the necessary lines to a complete example:

\documentclass{report}
\usepackage{amsmath}
\usepackage{chngcntr}
\counterwithin*{equation}{section}
\begin{document}
\section{Ciao}

Interesting equation: \begin{equation}\label{ab} a=b \end{equation}

\section{Ciao ciao}

Another Interesting equation \begin{equation} c=d \end{equation} and another equation too \begin{equation}\label{ef} e=f \end{equation} Now consider \eqref{ab} and \eqref{ef} \end{document}

does not show the problem, the references are: (1) and (2).

Probably you have multiply defined labels, e.g.:

\documentclass{report}
\usepackage{amsmath}
\usepackage{chngcntr}
\counterwithin*{equation}{section}
\begin{document}
\section{Ciao}

Interesting equation: \begin{equation}\label{ab} a=b \end{equation}

\section{Ciao ciao}

Another Interesting equation \begin{equation} c=d \end{equation} and another equation too \begin{equation}\label{ef} e=f \end{equation} Now consider \eqref{ab} and \eqref{ef}

\chapter{foo} \section{bar} \label{ab} \end{document}

This produces (1.1) and (2) and the warning in the .log file:

LaTeX Warning: Label `ab' multiply defined.

and at the end:

LaTeX Warning: There were multiply-defined labels.
Heiko Oberdiek
  • 271,626
  • Thank you. I see why you wrote what you wrote, but you misunderstood my question (my bad English maybe doesn't help). I want to have (1.1) so that the reader understands that he has to go to equation 1 of section 1. But I want omit section number when referring to an equation within the current section, and just write the equation number (I know it's weird but I need this). – Fausto Vezzaro Jun 17 '21 at 18:33