從 tocloft 中刪除節編號而不使用 \section*{}

從 tocloft 中刪除節編號而不使用 \section*{}

我正在嘗試從 tocloft 中刪除部分編號,但僅限於某些條目。我想要的範例: 我想要的範例

這就是我現在刪除它的方法:

\section*{Discussion} \label{discussion}
\addcontentsline{toc}{section}{\nameref{discussion}}

但使用這種方法,連結不會包含在 pdf 導航選單中,在我看來,這是一個混亂的解決方案。

我嘗試了以下方法,但它僅適用於書籍部分(我使用文章):

\makeatletter
\renewcommand{\cftsecpresnum}{\begin{lrbox}{\@tempboxa}}
\renewcommand{\cftsecaftersnum}{\end{lrbox}}
\makeatother

我可以使用以下指令抑制論文本身的章節編號: ''' \renewcommand{\prefix@section}{ } '''

總而言之,我想從下面的範例中刪除 8、9 和 10:

刪除這個

使用正常時:

\section{Discussion} \label{discussion}

我希望任何人都可以提供幫助,因為我無法弄清楚。這似乎是一件很簡單的事。如果我需要提供更多信息,我很樂意這樣做。先感謝您!

工作代碼:

\documentclass[10pt]{article}

\usepackage{nameref}

%% # TOC CONFIG #
\usepackage[titles]{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}
\renewcommand*\contentsname{Table of contents}
\setcounter{tocdepth}{3}


\begin{document}
    \setcounter{secnumdepth}{5}  
    \setcounter{tocdepth}{5}    
    \tableofcontents
    \newpage

    \let\oldthesection=\thesection
    \renewcommand{\thesection}{}

    % Without before
    \renewcommand{\thesection}{}
    \section{section one no nr before} \label{1nonr}


    % Normal sections
    \let\thesection=\oldthesection
    \setcounter{section}{0}
    \section{section one}

    \section{section two}
    \subsection{subsection one}

    \section{section three}
    \subsection{subsection one}
    \subsection{subsection two}

    % Without after
    \renewcommand{\thesection}{}
    \renewcommand{\thesubsection}{}
    \section{section one no nr} \label{1nonr}

    \section{section two no nr} \label{2nonr}
    \subsection{subsection one} \label{2snonr}
\end{document}

圖片: 圖片展示了它現在的工作原理

相關內容