I'd like to write a command to get a reference to the "current" section provided (the term is all wrong, but the example will clarify).
The idea is something along the lines of:
\getcurrentref{chapter}
or
\getcurrentref{subsubsection}
and so on.
A section is considered "current" at a given point if said point is within the "scope" of said section.
Example:
\chapter{A}
% point (1)
\section{A.A}
% point (2)
\section{A.B}
% point (3)
\subsection{A.B.A}
% point (4)
the only "living" section at point (1)
is chapter
, the only "living" sections at points (2)
and (3)
are chapter
and section
, and the only "living" sections at point (4)
are chapter
, section
and subsection
.
I hope I could explain myself (it's tricky).
PS: in case of trying to get the reference to a non-"living" section, the command should return ??
(this is just to have a standard graceful way of saying "no such section alive").