\section*{} を使用せずに tocloft からセクション番号を削除します。

\section*{} を使用せずに tocloft からセクション番号を削除します。

私は tocloft からセクション番号を削除しようとしていますが、一部のエントリのみです。私が望む例: 私が望む例

今私が削除する方法は次のとおりです:

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

しかし、この方法では、リンクが PDF ナビゲーション メニューに含まれず、面倒な解決策だと私は思います。

以下を試しましたが、Book セクションのみです (私は article を使用します)。

\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}

写真: 現在の仕組みを示す写真

関連情報