I would like to hide sections of Appendix from the table of contents, without losing the section number in the body of the document and section should be possible to reference.
I found a solution: hide an entry from Toc in latex
\newcommand{\toclesslab}[3].
{\bgroup\let\addcontentsline=\nocontentsline#1{#2\label{#3}}\egroup}
Usage: \toclesslab\section{Motivation}{s:motivation}
but it is showing two errors first after the command:
Argument of \label has an extra }.
Missing $ inserted.
second after the row
LaTeX Error: Not in outer par mode.
Undefined control sequence.
Missing number, treated as zero.
and it's not possible to use \label
is there a way to hide a section without losing number and still be referencable?
I have tried this too Remove specific subsection from TOC in LaTeX [duplicate]
Minimal reproducible example: https://latexbase.com/d/498aec5c-d490-47d5-a469-9c6df79a2962
Thank you