1

I want my Table of Contents to highlight only current subsection, hide subsections of other sections. I found the solution in beamer template but did not work in other template. How can I do it?

This is my style for setting of the Table of Contents:

% tableofcontents options
\setcounter{toclevel}{2}
\setcounter{tocncols}{1}
\def\contentsname{Outline}
\def\tocitem{$\bullet$}
\def\tocitemi{\textbf{--}}
\def\tocitemii{\textbf{--}}

% tableofcontents
\setcounter{tocdepth}{3}
\def\tableofcontents{
\begin{frame}[\hypertarget{toc}{\contentsname}]
\raggedright
\ifnum\thetocncols>1 \begin{multicols}{\thetocncols} \fi
\renewcommand {\labelitemi}{\tocitem}
\begin{itemize}\parskip0pt
\@input{\jobname.toc}%
\end{itemize}
\ifnum\thetocncols>1 \end{multicols} \fi
\end{frame}
}
\def\contentsline#1{
\csname l@#1\endcsname
}
\def\l@section#1#2#3{
\ifnum\c@toclevel>0
\item
\ifnum\thepage=#2
\hyperlink{#3}{\textcolor{red}{\bf#1}}
\else
\hyperlink{#3}{#1}
\fi\fi
}
\def\l@subsection#1#2#3{
\ifnum\c@toclevel>1
\ifnum\thepage=#2
\\\hyperlink{#3}{\hspace{1pt}\tocitemi\hspace{10pt}\textcolor{red}{\bf#1}}
\else
\\\hyperlink{#3}{\hspace{1pt}\tocitemi\hspace{10pt}#1}
\fi\fi
}
\def\l@subsubsection#1#2#3{
\ifnum\c@toclevel>2
\ifnum\thepage=#2
\\\hyperlink{#3}{\hspace{24pt}\tocitemii\hspace{10pt}\textcolor{red}{\bf#1}}
\else
\\\hyperlink{#3}{\hspace{24pt}\tocitemii\hspace{10pt}#1}
\fi\fi
}
  • 1
    Could you please provide your MWE document (from \documentclass to \end{document} Especially with your mentioned template. – Jan Dec 20 '16 at 8:50
  • And could you also please add a sketch, what the toc should look like? From the complexity of your code I tend to bet, that there will be an easier solution. – user36296 Dec 20 '16 at 9:49
  • And of course welcome to TeX.Stackexchange! – user36296 Dec 20 '16 at 13:23