Every entry in the mtcX
files is of the form
{\reset@font\mtcSfont\mtc@string\contentsline{section}{\noexpand \leavevmode \numberline {1.1}Test 1}{\reset@font\mtcSfont 3}}
where \mtc@string
is defined to be \relax
. We can overload it to modify (locally) the meaning of \numberline
to gobble up to and including the first period.
\documentclass{book}
\usepackage{minitoc}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\setcounter{minitocdepth}{\value{tocdepth}}
\makeatletter
\let\xumtc@numberline\numberline
\protected\def\mtc@string{\let\numberline\xumtc@gobble@numberline}
\def\xumtc@gobble@numberline#1{\xumtc@gobble@@numberline#1\@nil}
\def\xumtc@gobble@@numberline#1.#2\@nil{\xumtc@numberline{#2}}
\makeatother
\begin{document}
\dominitoc
\tableofcontents
\chapter{Chapter title}
\minitoc
\section{Test 1}
\chapter{Chapter two}
\minitoc
\section{Test 1}
hello
\subsection{Test 1 subsection}
\section{Test 2}
hello
\subsection{Test 2 subsection}
\subsection{Test 2 subsection}
hello
\subsubsection{Subsubsection}
hello
\end{document}

A higher level patch that takes care of possible lacking periods (we might have \numberline{}
for unnumbered sections that are included in the minitoc nonetheless):
\documentclass{book}
\usepackage{minitoc}
\usepackage{expl3}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\setcounter{minitocdepth}{\value{tocdepth}}
\ExplSyntaxOn
\cs_new_protected:Nn \xumtc_string:
{
% locally change \numberline to gobble up to and including the first period
\cs_set_eq:NN \numberline \xumtc_gobble_numberline:n
}
% the 'external' name
\cs_set_eq:cN { mtc@string } \xumtc_string:
% save the old meaning of \numberline
\cs_set_eq:NN \xumtc_numberline:n \numberline
% define a variant that first expands the argument
\cs_generate_variant:Nn \xumtc_numberline:n { x }
% allocate a variable
\seq_new:N \l__xumtc_numberline_seq
% the main macro
\cs_new_protected:Nn \xumtc_gobble_numberline:n
{
% split the argument at periods
\seq_set_split:Nnn \l__xumtc_numberline_seq { . } { #1 }
% discard the first item
\seq_pop_left:NN \l__xumtc_numberline_seq \l_tmpa_tl
% yield the remaining items with a period between them
\xumtc_numberline:x { \seq_use:Nn \l__xumtc_numberline_seq { . } }
}
\ExplSyntaxOff
\begin{document}
\dominitoc
\tableofcontents
\chapter{Chapter title}
\minitoc
\section{Test 1}
\chapter{Chapter two}
\minitoc
\section{Test 1}
hello
\subsection{Test 1 subsection}
\section{Test 2}
hello
\subsection{Test 2 subsection}
\subsection{Test 2 subsection}
hello
\subsubsection{Subsubsection}
hello
\end{document}
\makeatletter \def\numberline#1{\def\mt{#1}\hb@xt@\@tempdima{\expandafter\@gobbletwo\mt\hfil}} \makeatother
after\tableofcontents
.