# Different section names in toc and minitoc

I am trying to have a different section name in ToC and in mintoc.

(That may sound strange, but since the toc and monitoc won't have the same depth, I want to give insight in the toc name that is not useful in the mintoc same that contains the detailed subsections)

It's easy to change the name in toc from the name in body, but I couldn't manage to put a different name in toc and in monitoc.

A MWE

\documentclass[11pt]{report}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[tight,k-tight]{minitoc}

\begin{document}

\dominitoc

\tableofcontents

\chapter{Animals}
\minitoc

\section{Lion}
\section[Zebra family]{Zebra}
\subsection{Mini-zebra}

\end{document}


I would like to have "Zebra family" in toc, but "Zebra" in monitoc.

• You don't say how mark-up in source would like. Please advise. – user4686 Jun 12 '18 at 12:38
• What do you mean exactly? I would like to have "Zebra family" in ToC but "Zebra" in monitoc. – AdrienS Jun 12 '18 at 18:42
• OK, I get it. The mark-up is already in place indeed. But then one needs to hack \section to insert both titles in toc, or insert one in toc and one in one of the numerous files used by minitoc package. I don't know enough about minitoc to propose a solution using it. – user4686 Jun 12 '18 at 19:35
• Ok, I see what you mean. Anyway, thanks for the advice! – AdrienS Jun 13 '18 at 8:01

Hacking into some core kernel macro:

\documentclass[11pt]{report}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[tight,k-tight]{minitoc}

\usepackage{etoolbox}
\makeatletter
\patchcmd\@sect{\fi #7}{\fi \ONEORTHEOTHER{#7}{#8}}{}{\typeout{***FAILED***}}
\patchcmd\@sect{\fi #7}{\fi \ONEORTHEOTHER{#7}{#8}}{}{\typeout{***FAILED TOO***}}
\makeatother
\DeclareRobustCommand\ONEORTHEOTHER[2]{#1}% ensures normal default behaviour
\begin{document}

\dominitoc
\tableofcontents
\DeclareRobustCommand\ONEORTHEOTHER[2]{#2}% switches to usage of alternative title

\chapter{Animals}
\minitoc

\section{Lion}
\section[Zebra family]{Zebra}
\subsection{Mini-zebra}

\end{document}


Main TOC:

Minitoc:

As requested it uses in Minitoc the same title Zebra as the section title itself.

You can define a robust command that normally chooses its first argument discarding the second, but changes behavior in a minitoc.

Every minitoc is typeset in a group, so the change will disappear at group ending.

\documentclass[11pt]{report}

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{etoolbox}

\usepackage[tight,k-tight]{minitoc}

\makeatletter
\pretocmd{\sv@minitoc@}
{\let\tocorminitoc\@secondoftwo}
{}{}
\newrobustcmd\tocorminitoc[2]{#1}
\makeatother

\begin{document}

\dominitoc

\tableofcontents

\chapter{Animals}
\minitoc

\section{Lion}
\section[Zebra\tocorminitoc{ family}{}]{Zebra}
\subsection{Mini-zebra}

\end{document}