如何删除目录中部分条目的页码(不是目录页中打印的页码)

如何删除目录中部分条目的页码(不是目录页中打印的页码)

我想删除目录中第 3 部分的页码(本例中必须删除第 3 页)

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape}

\settocfeature{pagenumberhook}{~}
\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering#2}}% original #1 in second argument
}

\usepackage{blindtext}


\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

答案更新自步调一致回答

\documentclass{scrbook}
\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape~}
\makeatletter
\settocstylefeature[-1]{pagenumberhook}{\@gobble}
\makeatother

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering Module #1 ~--~ #2}}% original #1 in second argument
}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\part{Second Module}

\blinddocument
\end{document}

在此处输入图片描述

答案1

tocstyle您的所有要求都可以通过以下两行代码实现,无需重新定义内部命令:

\settocstylefeature[-1]{entryhook}{\hfil}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part

以下是完整的 MWE:

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature[-1]{entryhook}{\hfil}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part

\settocstylefeature{pagenumberhook}{\itshape~}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

一些与 OP 的评论相关的修改。

\documentclass{scrbook}
\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature[-1]{entryhook}{\hfil\partname\space}%centering part entry
\settocstylefeature[-1]{pagenumberbox}{\csname @gobble\endcsname}%no page numbers for part
\settocstylefeature[0]{leaders}{\hfill}%
\settocstylefeature{pagenumberhook}{\itshape~}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

在此处输入图片描述

答案2

\settocstylefeature[-1]{pagenumberhook}{\@gobble}成功了。请注意,\settocstylefeature同一级别的多个指令中的最后一条将覆盖其他指令。

\documentclass{scrbook}

\usepackage{lmodern}% for sans-serif plus bold plus italic

\renewcommand\partname{Module}

\usepackage{tocstyle}
\usetocstyle{standard}
\usetocstyle{nopagecolumn}
\settocstylefeature{pagenumberhook}{\itshape~}
\makeatletter
\settocstylefeature[-1]{pagenumberhook}{\@gobble}
\makeatother

\renewcommand*{\addparttocentry}[2]{%
  \addtocentrydefault{part}{}{\protect\parbox{\textwidth}{\protect\centering#2}}% original #1 in second argument
}

\usepackage{blindtext}

\begin{document}

\tableofcontents

\part{First Module}

\blinddocument

\end{document}

在此处输入图片描述

相关内容