This is too long for a comment. As per the OP the counter number is to be used
for checking the order of packages loaded. This is highly unlikely that it can be a full
proof technique.
LaTeX2e
, stores all the counters allocated in an \@elt
list called \cl@@ckpt
.
The following MWE will display all counters allocated and the name of the
counter i.e., the part after c@
. As you will observe by running the example, hyperTexies like Heiko will fiddle the system. Mostly though, it will predict order of loading:
% See all the counters in LaTeX2e
% and their allocation numbers
\documentclass{book}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{verse}
\usepackage{hyperref}
\usepackage{caption}
\newcounter{ZZZ}
\begin{document}
\makeatletter
\def\Z{%
\def\@elt##1{%
\expandafter\meaning
\csname c@##1\endcsname
\space = ##1,\par
}%
\cl@@ckpt%
}
All counter in article class plus one!
Expand list.
\Z
\section{Test}
\ifcsname c@section@level\endcsname
hyperef package has been loaded
\else
not loaded
\fi
%\expandafter\let\csname c@section@level\endcsname\undefined
\the\count118
\the\c@section@level
\end{document}
A better way to check for file order is to check the @filelist
.
\documentclass{book}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{verse}
\usepackage{hyperref}
\usepackage{caption}
\newcounter{ctr}
\makeatletter
\let\afilelist\@filelist
\begin{document}
% Just to see files
\@for\next:=\afilelist\do{%
\next, \par
}
% Command factory
\stepcounter{ctr}
\@for\next:=\afilelist\do{%
\expandafter\edef\csname @\next\endcsname{\thectr}
\stepcounter{ctr}
}
% Define macro to check order
\def\checkpkgorder#1#2{%
\edef\X{\csname @#1\endcsname}
\edef\Y{\csname @#2\endcsname}
\expandafter\ifnum\X\expandafter<\Y
Yes loaded earlier \X, \Y
\else
No loaded later \X, \Y
\fi
}
\checkpkgorder{book.cls}{ifxetex.sty}
\end{document}