
수업시간 에 문서를 작성하고 있는데 book
TOC 중앙에 부품 이름이 나오도록 하고 싶습니다. 또한 부품 번호나 페이지 번호 없이 표시되어야 합니다. 다른 클래스에 대한 몇 가지 솔루션을 보았지만 작동하지 않는 것 같습니다. 코드
\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}