0

In my Latex, I am using \usepackage{chngcntr} \counterwithin{equation}{section} to keep track of my equation environments sectionwise but when I am labeling and then referring to the labels, it refers to the corresponding section, not the environment I wish to refer to.

Can anybody kindly mention what am I missing here, to refer to any environment specificly and independently of its section or subsection or whatever?!

  • 4
    Welcome to TeX.SE. It will be real hard to help you out without an example of how you're using label and ref. – Teepeemm Jul 25 '21 at 00:45
  • 3
    You are probably setting \label in the wrong place. – egreg Jul 25 '21 at 09:09
  • Please take my code as an example and modify it according to your use case. Then you can ask a follow-up question (or modify this one) in which you show us your code and explain your problem. Otherwise you are wasting everybody's time including your own time :) – Dr. Manuel Kuehner Jul 25 '21 at 17:47

1 Answers1

1

Maybe this helps.

% https://tex.stackexchange.com/questions/54241
\documentclass{article}

\usepackage{amsmath} \numberwithin{equation}{section} % <-- Important

\begin{document}

\section{Here is a section} \begin{equation} f(x)=x^2+\sin(x) \label{eq:lala} \end{equation}

See \eqref{eq:lala}. Equation \ref{eq:lala} is pretty nice. \end{document}

enter image description here

  • \counterwithin{equation}{section} and \numberwithin{equation}{section} do exactly the same thing. – egreg Jul 25 '21 at 09:10
  • Oh thanks. I wasn't aware of that, but one more thing, if I use \newtheorem*{axiom}{Axiom} and refer the axiom environmnt, that refers to the corresponding section, not the specific environment I want? This is alright for equation or align, only \newtheorem{} gives trouble! Why so, and what's possible remedy? – prikarsartam Jul 25 '21 at 11:50
  • 1
    @prikarsartam: You need to show your code for us to help. The location of \label is important. – Werner Jul 25 '21 at 17:18
  • @egreg My "answer" is more an attempt to give the OP an mwe. The question is very unclear to me. I was in a hurry and just thought "better than nothing" – Dr. Manuel Kuehner Jul 25 '21 at 17:45