
여기에 표시된 목차 형식을 재현하려고 합니다.
내 시도:
\documentclass[12pt]{book}
\usepackage{tocloft,titletoc}
%\cftsetindents{section}{0em}{2em}
%\cftsetindents{subsection}{0em}{2em}
\usepackage{theanomodern}
\usepackage[baskerville]{newtxmath}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\contentsname}{\parbox{\linewidth}{\centerline{\Large CONTENTS}~\\[-1.5cm]}}
\titlecontents*{chapter}[0pt]{}{\textsc{\chaptername} \thecontentslabel:\quad}{}{\bfseries\hfill\contentspage}
\setcounter{tocdepth}{0}
\usepackage{hyperref}
\hypersetup{linktoc=none,}
\begin{document}
\tableofcontents
\pagenumbering{arabic}
\clearpage
%\addcontentsline{toc}{part}{\protect\centering{}Chapter I}
\part{One}
\chapter{The Greatest Common Divisor of Two Numbers}
\part{Two}
\chapter{Prime Numbers and Factorization into Prime Factors}
\end{document}
출력은 약간 가깝지만 아주는 아닙니다. 누락된 기능:
- 부품 및 레이블이 부품으로 시작하지 않습니다. 이를 위해 이미 수정을 시도했지만
\titlecontents
오류가 발생하여 MWE에서 제거했습니다. - 부품이 중앙에 위치함
- 부품의 마지막 페이지에 대한 링크가 없습니다.
- 부품명은 별도의 줄에 기재
- 내 출력에 없는 장 이름이 정렬되었습니다.
답변1
이 솔루션은 tocloft를 사용하지 않습니다.
까다로운 부분은 하이퍼링크에서 제목과 부품 번호를 분리하는 것이었습니다.
\documentclass[12pt]{book}
\usepackage{etoolbox}
%\usepackage{showframe}% alignment tool
\usepackage{theanomodern}
\usepackage[baskerville]{newtxmath}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\contentsname}{\parbox{\linewidth}{\centerline{\Large CONTENTS}~\\[-1.5cm]}}
\makeatletter
\patchcmd{\@part}{\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}}%
{\addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}}{}{FAILED}%
\newcommand*{\@partnumber}{}% reserve global name
\renewcommand*\l@part[2]{%
\ifnum \c@tocdepth >-2\relax
\addpenalty{-\@highpenalty}%
\addvspace{1.0em \@plus\p@}%
\begingroup
\def\numberline##1{\xdef\@partnumber{##1}}%
\setbox0=\vbox{\centering\bfseries\strut #1}% Could be more than one line
\centering
\leavevmode
\hyperlink{\Hy@tocdestname}{\large \partname~\@partnumber}\\
\usebox0
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\renewcommand*\l@chapter[2]{% #1 = title, #2 = pagenumber
\begingroup
\def\numberline##1{\hbox to \@tempdima{\chaptername~##1:\hfill}}% add \chaptername
\@dottedtocline{0}{0pt}{3cm}{#1}{\hyperlink{\Hy@tocdestname}{\bfseries #2}}% 3cm is the space reserved for the chapter number box
\endgroup}
\makeatother
\setcounter{tocdepth}{0}
\usepackage{hyperref}
\hypersetup{linktoc=none,}
\begin{document}
\tableofcontents
\pagenumbering{arabic}
\clearpage
%\addcontentsline{toc}{part}{\protect\centering{}Chapter I}
\part{One}
\chapter{The Greatest Common Divisor of Two Numbers}
\part{Two}
\chapter{Prime Numbers and Factorization into Prime Factors}
\end{document}