In a LaTeX beamer presentation the spacings between the section numbers and section titles are too small for 2-digit section numbers and actually negative for 3- or 4-digit section numbers. I want the spacings in the case of 2,3,4 etc. digit section numbers to be the same as the spacings in the 1-digit case. The 1-digit case is super. I want the same for subsections and subsubsections. Is there a way to do this? (I am using texlive2023 in overleaf).
\documentclass[9pt,trans,xcolor={table},envcountsect]{beamer} % Plain
\usefonttheme[onlymath]{serif}
\usetheme[shownavsym,right]{Aalborg}
\setbeamertemplate{navigation symbols}{\insertframenavigationsymbol
\insertsectionnavigationsymbol \insertbackfindforwardnavigationsymbol} % Nav symbols
\begin{document}
\makeatletter
\newcommand{\ShiftSectionNumber}[1]{%
\beamer@tocsectionnumber=\numexpr#1+\beamer@tocsectionnumber}
\makeatother
\makeatletter
\newlength{\secnumwidth}
\settowidth{\secnumwidth}{\the\beamer@sectionmax.\space}
\newlength{\subsecnumwidth}
\settowidth{\subsecnumwidth}{\the\[email protected]\space\space}
\newlength{\subsubsecnumwidth}
\settowidth{\subsubsecnumwidth}{\the\[email protected]}
\setbeamertemplate{section in toc}{%
\leavevmode%
% prevents the period to be printed with the first/last section option
\ifnum\beamer@tempcount>\beamer@toclastsection
\else
\ifnum\beamer@tempcount>0
\makebox[\secnumwidth][l]{\inserttocsectionnumber.}%
\fi\fi%
\inserttocsection\par%
}
\setbeamertemplate{subsection in toc}{%
\leavevmode\leftskip=\secnumwidth\rlap{\inserttocsectionnumber.
\inserttocsubsectionnumber}\hspace*{\subsecnumwidth}\inserttocsubsection\par}
\setbeamertemplate{subsubsection in toc}{%
\leavevmode\leftskip=\dimexpr\subsecnumwidth+\secnumwidth\rlap{\inserttocsectionnumber.
\inserttocsubsectionnumber.\inserttocsubsubsectionnumber}\hspace*{\subsubsecnumwidth}
\inserttocsubsubsection\par}
\makeatother
\begin{frame}%[allowframebreaks]
\frametitle{Overview}
\tableofcontents
\end{frame}
\section{First Section (1-digit section number)}
\subsection{Subsection}
\subsubsection{Subsubsection}
\ShiftSectionNumber{8}
\section{Tenth Section (2-digit section number)}
\subsection{Subsection}
\subsubsection{Subsubsection}
\ShiftSectionNumber{89}
\section{Hundredth Section (3-digit section number)}
\subsection{Subsection}
\subsubsection{Subsubsection}
\ShiftSectionNumber{899}
\section{Thousandth Section (4-digit section number)}
\subsection{Subsection}
\subsubsection{Subsubsection}
\begin{frame}[<+->]{Spacing in TOC}
Hello.
\end{frame}
\end{document}