# Cross referencing to any reference counter without adding labels

This answer provided a great solution for creating a new reference counter. I have a further idea to refer to a particular point without putting label or ref manually. This is done in package linguex for a different purpose. Let's see this code.

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{linguex}
\newcounter{mynumber}
\newcommand{\myno}[1]{\hfill\refstepcounter{mynumber}(\arabic{mynumber})\label{#1}}

\begin{document}
\lipsum[1]
\ex. This is one example.

\lipsum[1]
\ex. This is another example.

Example \LLast illustrates abc and \Last illustrates xyz.

\section{New section}
This is my first theorem. \myno{first}\\
This is my second theorem. \myno{}\\
By \eqref{first} it is evident that bla bla bla.\\
By \eqref{} it is evident that bla bla bla.\\
\end{document}


This code will produce -

Now as the linguex package provides me commands like \Last, \LLast I want them to be for these new ref-counters. Is it possible?

This is a pseudo code made by me. It looks almost the same, but has two additional commands which should end-up in referring to the theorem-numbers in an automated way. The expected output is exactly the same like the screenshot attached.

\documentclass{article}
\usepackage{lipsum}
\usepackage{amsmath}
\usepackage{linguex}
\newcounter{mynumber}
\newcommand{\myno}{\hfill\refstepcounter{mynumber}(\arabic{mynumber})}

\begin{document}
\lipsum[1]
\ex. This is one example.

\lipsum[1]
\ex. This is another example.

Example \LLast illustrates abc and \Last illustrates xyz.

\section{New section}
This is my first theorem. \myno\\ % Note that I have no compulsory label argument here. It is automatically labelled.
This is my second theorem. \myno\\
By \NewLast it is evident that bla bla bla.\\ % Here the labels are referred.
By \NewLLast it is evident that bla bla bla.\\
\end{document}

• your question is not very clear about where you want lablels, what input do you want to use, and what output do you want it to generate? – David Carlisle Oct 3 at 16:25
• Changing the counter name used in the custom defined \myno to the counter name used in linguex could at a first glance give the desired result: \newcommand{\myno}[1]{\refstepcounter{ExNo}(\arabic{ExNo})\label{#1}}. – leandriis Oct 3 at 16:27
• you could use \themynumber as the equivalent to \last to get the last used number, is that what you need? – David Carlisle Oct 3 at 16:27
• Please see the edit. Sorry for not being very clear before. – Niranjan Oct 3 at 16:35
• so you just want \def\NewLast{\the\value{mynumber}} and \def\NewLLast{\the\numexpr\value{mynumber}-1\relax} ? – David Carlisle Oct 3 at 17:34