我想删除目录中第 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}