I'm beginning to learn LaTeX and I need some help with counters.
My goal is to store the value a certain counter reaches at some point in the document and use it later. This is my attempt:
\documentclass{article}
\begin{document}
\section{title}
text
\let\myvalue\thesection
\section{title}
text
\myvalue
\end{document}
but \myvalue
prints 2 instead of 1.
I read this: What is the difference between \let and \def? but let does not seem to store the value at the definition time in my case.
What am I doing wrong?
Best Answer
A naive example of how to do that,
You just create a new counter with the command
\newcounter
and you set it to the value you want with\setcounter
.NOTE If you re looking for some referencing tool, better solutions exist with
\label{}
and\ref{}
, among other.