¿Cómo puedo obtener el último número de sección para usarlo en el nombre?

¿Cómo puedo obtener el último número de sección para usarlo en el nombre?

Estoy escribiendo algunas notas que contienen muchos capítulos y secciones. Al final de cada sección de este archivo me gustaría insertar una lista de ejercicios con el siguiente título:

Problems - Section x.y (x = chapter, y = section)

\begin{exercise}
blah blah blah
\end{exercise}

Podría hacer esto usando un comando \label como

     \section{NameSection}\label{secx.y}

bla bla bla


     Problems - Section \ref{secx.y}
        
        \begin{exercise}
        blah blah blah
        \end{exercise}

¿Hay alguna forma de utilizar algún comando como \lastchapter.section o \current.chapther.section en lugar de \ref{secx.y}?

Estoy usando hipervínculos a.

\documentclass[a4paper, 12pt]{report}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage[x11names, usenames,svgnames,dvipsnames, table]{xcolor}
\RequirePackage[babel=true]{microtype}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{tasks}
\usepackage{graphicx}
\usepackage{float}
\usepackage[margin=1.5cm ]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{indentfirst}
\usepackage{eqparbox, ulem}
\usepackage{lipsum}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{allcolors=magenta}

\everymath{\displaystyle}

\newcounter{theeq} 
\counterwithin{theeq}{chapter}
\setcounter{theeq}{0}

\newcommand{\eq}{ 
    \
    
    \noindent 
    \refstepcounter{theeq}\textbf{\thechapter.\arabic{theeq}}. }
%%%%%%%%%%%%%%%%%
\begin{document}

\chapter{test1}
\lipsum[2]

\section{test1.1}\label{test1.1}
\lipsum[3]

\begin{center}
    \Large{Problems - Section \ref{test1.1}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\section{test1.2}\label{test1.2}
\lipsum[3]

\begin{center}
    \Large{Problems - Section \ref{test1.2}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\section{test1.3}\label{test1.3}
\lipsum[3]

\begin{center}
    \Large{Problems - Section \ref{test1.3}}
\end{center}

\eq Let \(x \in R\)

\eq xx


\chapter{test2}
\lipsum[3]

\section{test2.1}\label{test2.1}

\begin{center}
    \Large{Problems - Section \ref{test2.1}}
\end{center}

\eq Let \(x \in R\)

\eq \(\lim_{x\to 0} \frac{1}{x}\)

\chapter{test3}

\section{test3.1}\label{test3.1}

\begin{center}
    \Large{Problems - Section \ref{test3.1}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\end{document}
                    

Respuesta1

Esto funcionará en una sola ejecución. Puedes poner casi cualquier cosa en la entrada de texto.

Es posible que no siempre funcione section.\thesection, dependiendo de cómo \thesectionse defina. Si busca en el archivo auxiliar a continuación, \contentslineencontrará el nombre del ancla section.1.1(por ejemplo). Para eso necesitas reproducirte \hyperlink.

\documentclass[a4paper, 12pt]{report}
\usepackage{mathpazo, amsmath,amsfonts,amscd,bezier, amssymb, ifthen,amsthm}
\usepackage[x11names, usenames,svgnames,dvipsnames, table]{xcolor}
\RequirePackage[babel=true]{microtype}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage{enumerate}
\usepackage[shortlabels]{enumitem}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{tasks}
\usepackage{graphicx}
\usepackage{float}
\usepackage[margin=1.5cm ]{geometry}
\usepackage[most]{tcolorbox}
\usepackage{indentfirst}
\usepackage{eqparbox, ulem}
\usepackage{lipsum}
\usepackage[colorlinks=true]{hyperref}
\hypersetup{allcolors=magenta}

\everymath{\displaystyle}

\newcounter{theeq} 
\counterwithin{theeq}{chapter}
\setcounter{theeq}{0}

\newcommand{\eq}{ 
    \
    
    \noindent 
    \refstepcounter{theeq}\textbf{\thechapter.\arabic{theeq}}. }
%%%%%%%%%%%%%%%%%
\begin{document}

\chapter{test1}
\lipsum[2]

\section{test1.1}\label{test1.1}
\lipsum[3]

\begin{center}
    \Large{Problems - \hyperlink{section.\thesection}{Section \thesection}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\section{test1.2}
\lipsum[3]

\begin{center}
    \Large{Problems - \hyperlink{section.\thesection}{Section \thesection}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\section{test1.3}
\lipsum[3]

\begin{center}
    \Large{Problems - \hyperlink{section.\thesection}{Section \thesection}}
\end{center}

\eq Let \(x \in R\)

\eq xx


\chapter{test2}
\lipsum[3]

\section{test2.1}

\begin{center}
    \Large{Problems - \hyperlink{section.\thesection}{Section \thesection}}
\end{center}

\eq Let \(x \in R\)

\eq \(\lim_{x\to 0} \frac{1}{x}\)

\chapter{test3}

\section{test3.1}

\begin{center}
    \Large{Problems - \hyperlink{section.\thesection}{Section \thesection}}
\end{center}

\eq Let \(x \in R\)

\eq xx

\end{document}

información relacionada