실제로는 부분도 아니고 장도 아닌 섹션이 필요합니다. 그래서 나는 \part 명령을 기반으로 새 명령인 \subpart를 정의하려고 했습니다. 그러나 고유한 번호가 지정되어 있으며 새 빈 페이지 중간에 다음과 같이 표시됩니다.
제1부
하위 부분의 이름
그런데 그렇게 하려고 하면 항상 오류가 뜹니다…
웹에서 I-dont-remember-where의 코드를 기반으로 한 내 접근 방식은 다음과 같습니다.
\makeatletter
\def\@subpart[#1]{%
\ifnum \c@secnumdepth >\m@ne
\refstepcounter{subpart}%
\addcontentsline{toc}{subpart}{\thepart\hspace{1em}#1}%
\else
\addcontentsline{toc}{subpart}{#1}%
\fi
{\parindent \z@ %\raggedright % Commented \raggedright
\interlinepenalty \@M
\normalfont
\ifnum \c@secnumdepth >\m@ne
\Large\bfseries\hfil\partname~\thepart\hfil % added \hfil … \hfil for centering
\par\nobreak
\fi
\huge \bfseries %
\markboth{}{}\par}%
\nobreak
\vskip 3ex
\@afterheading}
\makeatother
LaTeX를 올바르게 사용하는 법을 배워야겠어요…
도와줘서 고마워요,
세바스찬
답변1
완전히 새로운 단면 단위를 정의하는 것은 간단한 문제가 아닙니다. 사용하여titlesec
패키지는 작업을 완화할 수 있습니다. ToC에서 하위 파트 항목이 어떻게 표시되어야 하는지에 대한 정보를 제공하지 않았기 때문에 파트 스타일과 장용 스타일 사이에서 스타일을 선택했습니다. 이 재정의를 적절하게 변경할 수 있습니다 \l@subpart
.
\documentclass{book}
\usepackage[explicit]{titlesec}
\usepackage{tocloft}
\usepackage{lipsum}
\usepackage{fmtcount}
\newcommand\subpartname{Subpart}
\titleclass{\subpart}{top}[\part]
\newcounter{subpart}
\renewcommand\thesubpart{\Numberstring{subpart}}
\makeatletter
\titleformat{\subpart}[display]
{\normalsize\Huge\filcenter}{\scshape\subpartname~\thesubpart}{1em}{{\bfseries#1}\iftitlemeasuring{\def\ttl@endlongest{\clearpage}}{}}
\titlespacing*{\subpart}
{0pt}{0em}{\pagetotal}
\makeatother
\newcommand\subpartautorefname{\subpartname}
\newcommand\subpartbreak{\cleardoublepage\mbox{}\vfil}
\assignpagestyle{\subpart}{plain}
\makeatletter
\def\toclevel@subpart{0}
\newcommand*\l@subpart[2]{%
\ifnum \c@tocdepth >-2\relax
\addpenalty{-\@highpenalty}%
\addvspace{1em \@plus\p@}%
\setlength\@tempdima{3.5em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
{\leavevmode
\large\bfseries\subpartname~#1\hfil\hb@xt@\@pnumwidth{\hss #2}}\par
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\makeatother
\begin{document}
\tableofcontents
\part{Test Part One}
\subpart{Test Subpart One}
\chapter{Test Chapter One}
\section{Test Section}
\subpart{Test Subpart Two}
\chapter{Test Chapter Two}
\section{Test Section}
\end{document}
\chapter
이제 단면 단위의 레벨 이 아래쪽에서 1씩 감소했다는 점을 고려하십시오 . 즉, \part
레벨 있음 -1
, \subpart
레벨 있음 0
, \chapter
레벨 있음 1
, \section
레벨 있음 2
, \subsection
레벨 있음 3
등입니다.
답변2
Gonzalo Medina의 답변이 좋습니다. 그러나 나는 그것을 보충하고 싶다.
titletoc
패키지를 사용하여 목차를 처리하는 방법을 보여줍니다 .하위 파트와 챕터에 상위 레벨 카운터가 포함되도록 번호 매기기 체계를 변경하는 방법을 보여줍니다.
첫 번째 버전
그냥 추가 titletoc
:
~와 함께
\documentclass{book}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\titleformat{\part}[display]{\normalfont\Huge\bfseries}%
{\partname~\thepart}{1pc}{\Huge\bfseries}
\titleclass{\subpart}{page}[\part]
\newcounter{subpart}
\renewcommand{\thesubpart}{\Alph{subpart}}
\newcommand{\subpartname}{Subpart}
\titleformat{\subpart}[display]{\normalfont\Large\bfseries}%
{\subpartname~\thesubpart}{1pc}{\Huge\bfseries}
\titlespacing{\subpart}{0pt}{0pt}{0pt}
\titlecontents{subpart}[0pt]{\addvspace{1pc}\normalfont\bfseries}%
{\thecontentslabel\enspace ---\enspace\large}%
{\normalfont\large\bfseries}{\hspace{2em plus 1fill}\large\contentspage}
\begin{document}
\tableofcontents
\part{Part One}
\subpart{First Subpart}
\chapter{A chapter}
\subpart{Second Subpart}
\chapter{Another chapter}
\section{Testing}
\section{TT}
\part{Part Two}
\subpart{First Subpart}
\chapter{A chapter}
\subpart{Second Subpart}
\chapter{Another chapter}
\end{document}
위에서 주목해야 할 주요 사항은 part
목차 기능이 작동하도록 하려면 재정의해야 한다는 것입니다. 그러면 코드는
- 바로 아래 (및 위 )
subpart
에 하위 구역으로 설정됩니다 .part
chapter
- 해당 카운터와 인쇄 방법을 정의합니다(
\thesubpart
). - 하위 부분 이름에 대한 문자열을 소개합니다.
- 표시된(중앙에 배치된) 블록으로 하위 파트 제목의 인쇄를 설정합니다.
- 목차의 형식을 정의합니다.
두 번째 버전
하위 번호 지정:
~와 함께
\documentclass{book}
\usepackage[newparttoc]{titlesec}
\usepackage{titletoc}
\usepackage{amsmath}
\titleformat{\part}[display]{\normalfont\Huge\bfseries}%
{\partname~\thepart}{1pc}{\Huge\bfseries}
\titleclass{\subpart}{page}[\part]
\newcounter{subpart}[part]
\numberwithin{chapter}{subpart}
\renewcommand{\thesubpart}{\thepart-\Alph{subpart}}
\newcommand{\subpartname}{Subpart}
\titleformat{\subpart}[display]{\normalfont\Large\bfseries}%
{\subpartname~\thesubpart}{1pc}{\Huge\bfseries}
\titlespacing{\subpart}{0pt}{0pt}{0pt}
\titlecontents{subpart}[0pt]{\addvspace{1pc}\normalfont\bfseries}%
{\thecontentslabel\enspace ---\enspace\large}%
{\normalfont\large\bfseries}{\hspace{2em plus 1fill}\large\contentspage}
\titlecontents{chapter}[0pt]{\addvspace{0.5pc}\normalfont\bfseries}%
{\thecontentslabel\enspace}{}{\hspace{2em plus 1fill}\contentspage}
\dottedcontents{section}[6em]{}{4em}{1pc}
\begin{document}
\tableofcontents
\part{Part One}
\subpart{First Subpart}
\chapter{A chapter}
\subpart{Second Subpart}
\chapter{Another chapter}
\section{Testing}
\section{TT}
\part{Part Two}
\subpart{First Subpart}
\chapter{A chapter}
\subpart{Second Subpart}
\chapter{Another chapter}
\end{document}
이 경우 코드는 다음을 제외하면 동일합니다.
- 이제 카운터
subpart
는 매번 재설정되도록 정의되었습니다.part
- 카운터
chapter
는 각 하위 부분에서 재설정됩니다(\numberwithin
이를 위해 AMS 패키지가 사용되었습니다). \thesubpart
이제 부품 번호도 인쇄됩니다.- 하위 수준의 목차 형식도 재정의되어 레이블 공간을 허용합니다.