samcarter
Back in the days before TL2020 I've been using the `xcntperchap` package to get access to the number of subsections within each section. This was very useful for creating custom tocs in beamer, e.g. here a fancy example using a mindmap:
```
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees,shadows}
% total number of sections %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}
\AtBeginDocument{%
\pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%
% number of subsections per section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
% creating automatic label %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% based on https://tex.stackexchange.com/a/386557/36296
\AtBeginSection[]{\label{sec:\thesection}}
\AtBeginSubsection[]{\label{subsec:\thesection:\thesubsection}}
\newcounter{currentsub}
\newcounter{totsection}
\newcommand{\mindtoc}{%
\centering
\setcounter{totsection}{\number\totvalue{totalsection}}
\begin{tikzpicture}[
grow cyclic,
concept color=blue!50!black,
text=white,
every node/.style={concept, scale=0.8},
level 1/.style={%
sibling angle=360/\thetotsection,
level distance = 25mm,
concept color=lime,
text=black,
},
level 2/.style={%
level distance = 25mm,
concept color=yellow,
text=black,
},
]
\node {\inserttitle} [clockwise from=135] child
foreach \i in {1,...,\thetotsection}{%
node{\hyperlink{sec:\i}{\nameref{sec:\i}}
\setcounter{currentsub}{\ObtainTrackedValueExp[\i]{section}{subsection}}
}%
\ifnum\thecurrentsub>0%
child foreach \j in {1,...,\thecurrentsub}{%
node {\hyperlink{subsec:\i:\j}{\nameref{subsec:\i:\j}}}
}
\fi%
};
\end{tikzpicture}
}
\title{Some Title}
\begin{document}
\begin{frame}
\frametitle{"Table" of Contents}
\mindtoc
\end{frame}
\section{Section One}
\frame{abc}
\section{Section Two}
\frame{abc}
\subsection{subsection a}
\frame{abc}
\subsection{subsection b}
\frame{abc}
\subsection{subsection c}
\frame{abc}
\section{Section Three}
\frame{abc}
\section{Section Three}
\frame{abc}
\end{document}
```
However this quick hack no longer works with the current kernel, so I was wondering if there are any alternatives which would give me the number of subsections in each section?
Minimal (non-)working example:
```
\documentclass{beamer}
\usepackage{pgffor}
\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}
\AtBeginDocument{%
\pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%
% number of subsections per section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
% creating automatic label %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% based on https://tex.stackexchange.com/a/386557/36296
\AtBeginSection[]{\label{sec:\thesection}}
\AtBeginSubsection[]{\label{subsec:\thesection:\thesubsection}}
\newcounter{currentsub}
\newcounter{totsection}
\newcommand{\mindtoc}{%
\setcounter{totsection}{\number\totvalue{totalsection}}
\foreach \i in {1,...,\thetotsection}{%
\setcounter{currentsub}{\ObtainTrackedValueExp[\i]{section}{subsection}}
\nameref{sec:\i} (\thecurrentsub{} subsections)
}
}
\title{Some Title}
\begin{document}
\begin{frame}
\mindtoc
\end{frame}
\section{Section One}
\frame{zzz}
\section{Section Two}
\frame{zzz}
\subsection{subsection a}
\frame{zzz}
\subsection{subsection b}
\frame{zzz}
\subsection{subsection c}
\frame{zzz}
\section{Section Three}
\frame{zzz}
\section{Section Three}
\frame{zzz}
\end{document}
```
Top Answer
Phelype Oleinik
The issue is not _exactly_ in the kernel, but in the L3 programming layer. `\c_zero` was deprecated a while back, because it's name doesn't follow the `expl3` naming conventions: it's an `int`, but it's missing the variable type (so we couldn't have a `\c_zero_fp`, for example).
Christian was very kind to fix most of his packages after this deprecation (even if not actively maintaining them anymore), but `xcntperchap` seems to have been forgotten.
To work around the issue you can, although not really recommended, use:
```
\ExplSyntaxOn
\cs_set_eq:NN \c_zero \c_zero_int
\ExplSyntaxOff
```
anywhere in your preamble to make `\c_zero` be the same as `\c_zero_int`.
---
For completeness, here's a full example (exactly the same as yours, with the lines above added):
```
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{mindmap,trees,shadows}
% total number of sections %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{totcount}
\newcounter{totalsection}
\regtotcounter{totalsection}
\AtBeginDocument{%
\pretocmd{\section}{\refstepcounter{totalsection}}{}{}%
}%
% number of subsections per section %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ExplSyntaxOn % fix xcntperchap
\cs_set_eq:NN \c_zero \c_zero_int
\ExplSyntaxOff
\usepackage{xcntperchap}
\RegisterCounters{section}{subsection}
\newcounter{totalsubsection}
\setcounter{totalsubsection}{0}
% creating automatic label %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% based on https://tex.stackexchange.com/a/386557/36296
\AtBeginSection[]{\label{sec:\thesection}}
\AtBeginSubsection[]{\label{subsec:\thesection:\thesubsection}}
\newcounter{currentsub}
\newcounter{totsection}
\newcommand{\mindtoc}{%
\centering
\setcounter{totsection}{\number\totvalue{totalsection}}
\begin{tikzpicture}[
grow cyclic,
concept color=blue!50!black,
text=white,
every node/.style={concept, scale=0.8},
level 1/.style={%
sibling angle=360/\thetotsection,
level distance = 25mm,
concept color=lime,
text=black,
},
level 2/.style={%
level distance = 25mm,
concept color=yellow,
text=black,
},
]
\node {\inserttitle} [clockwise from=135] child
foreach \i in {1,...,\thetotsection}{%
node{\hyperlink{sec:\i}{\nameref{sec:\i}}
\setcounter{currentsub}{\ObtainTrackedValueExp[\i]{section}{subsection}}
}%
\ifnum\thecurrentsub>0%
child foreach \j in {1,...,\thecurrentsub}{%
node {\hyperlink{subsec:\i:\j}{\nameref{subsec:\i:\j}}}
}
\fi%
};
\end{tikzpicture}
}
\title{Some Title}
\begin{document}
% \tracingall
\begin{frame}
\frametitle{"Table" of Contents}
\mindtoc
\end{frame}
\section{Section One}
\frame{abc}
\section{Section Two}
\frame{abc}
\subsection{subsection a}
\frame{abc}
\subsection{subsection b}
\frame{abc}
\subsection{subsection c}
\frame{abc}
\section{Section Three}
\frame{abc}
\section{Section Three}
\frame{abc}
\end{document}
```