目次の中央にパート名を配置し、番号とページ番号は付けない

目次の中央にパート名を配置し、番号とページ番号は付けない

クラスでドキュメントを書いているのですbookが、目次の中央にパート名を表示したいです。また、パート番号やページ番号なしで表示する必要があります。他のクラスでいくつかの解決策を見たことがありますが、うまくいかないようです。コード

\documentclass{book}
\usepackage{titlesec}
\makeatletter
\renewcommand*\l@part[2]{%
  \ifnum \c@tocdepth >-2\relax
    \addpenalty{-\@highpenalty}%
    \addvspace{2.25em \@plus\p@}%
    \setlength\@tempdima{3em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      {\leavevmode
       \hspace*{\fill}\centering\large\bfseries #1\hspace*{\fill}\llap{#2}}\par
       \nobreak
         \global\@nobreaktrue
         \everypar{\global\@nobreakfalse\everypar{}}%
    \endgroup
  \fi}
\makeatother
\renewcommand{\partname}{}
\makeatletter
\titleformat{\part}[display]
  {\Huge\scshape\filright\centering}
  {}
  {20pt}
  {\thispagestyle{empty}}
\makeatother
\begin{document}
\tableofcontents
\part{This is a part of a document}
\end{document}

部品名を中央に配置しますが、数字を削除するにはどうすればよいでしょうか?

答え1

titletoc難解なコードをいじるよりもはるかに簡単です。

\documentclass{book}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc} %

\titleformat{\part}[display]
  {\Huge\scshape\filright\centering}
  {}
  {20pt}
  {\thispagestyle{empty}}
\titlecontents{part}[0pt]{\addvspace{2pc}\centering\large\bfseries}{}{}{}%

\begin{document}

\tableofcontents

\part{This is a part of a document}

\chapter{Chapter Title}

\end{document} 

ここに画像の説明を入力してください

関連情報