tocloft를 사용할 때 toc의 섹션 번호 매기기 문제

tocloft를 사용할 때 toc의 섹션 번호 매기기 문제

이 게시물의 답변에서 제안한 대로 pdflatex에서 tocloft(fontspec 없이)와 함께 \part를 사용할 때책을 부분과 장으로 분리, 목차의 섹션 번호에 이와 같은 문제가 있습니다.

내용물

첫 번째 부분

1장1

1 섹션1.1

1.1 하위 섹션 1.1.1

2 2장

1 섹션 2.1

1 섹션 2.2

1.1 하위 섹션2.2.1

두 번째 부분

3장3

2 섹션 3.1

2.1 하위 섹션 3.1.1

그러나 텍스트의 구분은 괜찮습니다.

누군가 나를 도와줄 수 있나요? 감사해요.

전문은 다음과 같습니다

\documentclass[a4paper,10pt]{book}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\usepackage{inputenc}
\usepackage{tabularx}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{xpatch}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{inputenc}
\usepackage{xspace}
\usepackage{fancyhdr} 
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[RE,LO]{\textcopyright~ Prints 2019}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\thepage}

\everymath{\displaystyle}

\newtheorem{prop}{Proposition}[chapter]
\newtheorem{defn}{Definition}[chapter]
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[prop]{Corollary}
\newtheorem{remark}{Remark}
\newtheorem{example}{Example}[chapter]

\newcommand{\floorceil}[1]{\lceil #1 \rfloor}

\makeatletter
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother

\renewcommand{\cftpartfont}{\bfseries\Large\hrule}%add line above part
\renewcommand{\cftpartpagefont}{\bfseries}
\renewcommand{\cftbeforepartskip}{5mm}
\renewcommand{\cftpartafterpnum}{\\\hrule}%add line below part
\cftpagenumbersoff{part}%get rid of part page numbers
\renewcommand{\cftsecindent}{8mm}%control spacing between number and sec title
\renewcommand{\cftsecnumwidth}{4mm}%section indent
\renewcommand{\cftparskip}{4mm}%control line spacing

\begin{document}
\tableofcontents
\part{First part}
\chapter{Chapter1}
\section{Sections1.1}
\subsection{Subsection1.1.1}
\chapter{Chapter2}
\section{Section2.1}
\section{Section2.2}
\subsection{Subsection2.2.1}
\part{Second part}
\chapter{Chapter3}
\section{Section3.1}
\subsection{Subsection3.1.1}
\end{document}

목차의 스냅샷은 여기에 있습니다.toc1[![][1]]2

답변1

몇 가지 의견과 제안:

  • 패키지 의 길이 매개변수는 를 tocloft통해 수정되어야 합니다 \setlength.\renewcommand

  • 교체를 고려해보다

    \renewcommand{\cftsecindent}{8mm}%control spacing between number and sec title
    \renewcommand{\cftsecnumwidth}{4mm}%section indent
    

    ~와 함께

    \cftsetindents{chap}{0em}{1.5em}
    \cftsetindents{sec}{1.5em}{2em}
    \cftsetindents{subsec}{3.5em}{2.75em}
    

    귀하의 선호도와 조판 요구 사항에 맞게 이러한 설정을 자유롭게 수정할 수 있습니다.


여기에 이미지 설명을 입력하세요

\documentclass[a4paper,10pt]{book}
\usepackage{mathtools,amssymb,amsthm}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{textcomp}
\usepackage{xpatch}
\usepackage{tikz}
\usepackage{tocloft}
\usepackage{xspace}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{}
\fancyhead[RE,LO]{\textcopyright~ Prints 2019}
\fancyfoot[CE,CO]{}
\fancyfoot[LE,RO]{\thepage}

\everymath{\displaystyle}

\newtheorem{prop}{Proposition}[chapter]
\newtheorem{defn}{Definition}[chapter]
\newtheorem{lemma}{Lemma}
\newtheorem{theorem}{Theorem}[chapter]
\newtheorem{corollary}[prop]{Corollary}
\newtheorem{remark}{Remark}
\newtheorem{example}{Example}[chapter]

\newcommand{\floorceil}[1]{\lceil #1 \rfloor}

\makeatletter
\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}
\makeatother

\renewcommand{\cftpartfont}{\hrule\bfseries\Large}%add line above part
\renewcommand{\cftpartpagefont}{\bfseries}
\setlength{\cftbeforepartskip}{5mm}
\renewcommand{\cftpartafterpnum}{\\\hrule}%add line below part
\cftpagenumbersoff{part}%no page numbers for part-level entries

%% commented out:
%\setlength{\cftsecindent}{8mm}% spacing between number and sec title
%\setlength{\cftsecnumwidth}{6mm}%section indent

%% new instructions:
\cftsetindents{chap}{0em}{1.5em}
\cftsetindents{sec}{1.5em}{2em}  % 1st length should be sum of lengths on preceding line
\cftsetindents{subsec}{3.5em}{2.75em}

\setlength{\cftparskip}{4mm}%control line spacing

\begin{document}
\tableofcontents

\part{First part}
\chapter{Chapter1}
\section{Section1.1}
\subsection{Subsection1.1.1}
\chapter{Chapter2}
\section{Section2.1}
\section{Section2.2}
\subsection{Subsection2.2.1}
\part{Second part}
\chapter{Chapter3}
\section{Section3.1}
\subsection{Subsection3.1.1}
\end{document}

관련 정보