実際にはパートでも章でもないセクションが必要です。そこで、\part コマンドをベースにした新しいコマンド \subpart を定義しようとしましたが、独自の番号付けがあり、新しい空白ページの真ん中に次のように表示されます。
サブパート 1
サブパート名
しかし、そうしようとすると、常にエラーが表示されます...
私のアプローチは、Web 上のどこにあるか覚えていないコードに基づいています。
\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
ゴンサロ・メディナさんの回答は素晴らしいです。しかし、私は次のように補足したいと思います。
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
部品番号も印刷できるようになりました- 下位レベルの目次の書式も再定義され、ラベルのためのスペースが確保される。