I have this code in LaTeX and I am dealing with some dynamic work with labels and references. This code works - first reference references to the first text and second to the second but I want to reset the contentCounter
within each section.
\documentclass{article}
\usepackage{hyperref}
\newcounter{contentCounter}
\renewcommand{\thesection}{\arabic{section}}
\newcommand{\inserttext}{%
\refstepcounter{contentCounter}
\par This is inserted text widh ID \thesection.\thecontentCounter. \\
\label{text:\thesection.\thecontentCounter}
}
\begin{document}
\setcounter{section}{1}
\inserttext
\setcounter{section}{2}
\inserttext
\newpage
\textbf{References}
\setcounter{section}{1}
\hyperref[text:\thesection.1]{first text}
\setcounter{section}{2}
\hyperref[text:\thesection.2]{second text}
\end{document}
I tried to reset the counter but second reference is not working. Where's the problem? Thank you.
\documentclass{article}
\usepackage{hyperref}
\newcounter{contentCounter}
\renewcommand{\thesection}{\arabic{section}}
\newcommand{\inserttext}{%
\refstepcounter{contentCounter}
\par This is inserted text with the ID \thesection.\thecontentCounter. \\
\label{text:\thesection.\thecontentCounter}
}
\begin{document}
\setcounter{section}{1}
\inserttext
\setcounter{section}{2}
\setcounter{contentCounter}{0}
\inserttext
\newpage
\textbf{References}
\setcounter{section}{1}
\hyperref[text:\thesection.1]{first text}
\setcounter{section}{2}
\hyperref[text:\thesection.1]{second text}
\end{document}
\newcounter{countername}[supercounter]
(wheresupercounter
here probably should besection
).\label{text:\thesection.\thecontentCounter}
is very odd. do you just have this in the test file or are you really using labels based on the counter value?