メインマターの章の最初のページでページ番号を抑制しますが、フロントマターでは抑制しません

メインマターの章の最初のページでページ番号を抑制しますが、フロントマターでは抑制しません

私はbookクラスを使用しています。メインマターの各章の最初のページでページスタイル(ページ番号、ヘッダー、フッター)を抑制したいのですが、ないin \frontmatter- フッター(右隅)にローマ数字を配置する場所。

次のようにすると、ドキュメント全体の各章の最初のページのページ スタイルを抑制できます。

\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \thispagestyle{empty}% original style: plain
                \global\@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}
\makeatother

しかし、これにより、\pagestyle{empty}前書きの各「章」の最初のページにも が強制され、目次ページには番号が付けられなくなります。目次ページに番号を付けたいのですが、その方法がわかりません。

MWE:

\documentclass[a4paper,11pt,titlepage,oneside,openany]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{kantlipsum}
% empty style for the first page of every chapter
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \thispagestyle{empty}% original style: plain
                \global\@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}
\makeatother

\usepackage{makeidx}

\usepackage[titles]{tocloft}

\usepackage{fancyhdr}
\fancyhead{} % clear default layout
\fancyfoot{} % clear default layout
\fancypagestyle{mainmatter}{%
\fancyhead[L]{\sffamily \small \color{darkgray}\MakeUppercase{\bfseries        \leftmark}}  
\fancyhead[R]{\nouppercase \scshape \small \thepage}
}

\fancypagestyle{frontmatter}{%
\fancyhead[L]{}
\fancyhead[R]{}
\fancyfoot[R]{\thepage}
}

\begin{document}
\frontmatter
\pagestyle{frontmatter}% frontmatter page style
\clearpage
\tableofcontents
\clearpage % with tocloft we need this
\listoffigures
\clearpage % with tocloft we need this
\listoftables
\clearpage

\mainmatter
\pagestyle{mainmatter}

\chapter{A}
\kant
\chapter{B}
\kant
\chapter{C}
\kant
\end{document}

答え1

memoirドキュメントのセクション\if@mainmatter内にいるかどうかを条件付けるために使用できる条件を提供します。\mainmatter

\documentclass[a4paper,11pt,titlepage,oneside,openany]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{kantlipsum}
% empty style for the first page of every chapter, except in \frontmatter
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                \if@mainmatter
                  \thispagestyle{empty}% plain page style in mainmatter
                \else
                  \thispagestyle{plain}% empty page style outside of mainmatter
                \fi%
                \global\@topnum\z@
                \@afterindentfalse
                \secdef\@chapter\@schapter}
\makeatother

\usepackage{makeidx}

\usepackage[titles]{tocloft}

\usepackage{fancyhdr}
\fancyhead{} % clear default layout
\fancyfoot{} % clear default layout
\fancypagestyle{mainmatter}{%
\fancyhead[L]{\sffamily \small \color{darkgray}\MakeUppercase{\bfseries        \leftmark}}  
\fancyhead[R]{\nouppercase \scshape \small \thepage}
}

\fancypagestyle{frontmatter}{%
\fancyhead[L]{}
\fancyhead[R]{}
\fancyfoot[R]{\thepage}
}

\begin{document}
\frontmatter
\pagestyle{frontmatter}% frontmatter page style
\clearpage
\tableofcontents
\clearpage % with tocloft we need this
\listoffigures
\clearpage % with tocloft we need this
\listoftables
\clearpage

\mainmatter
\pagestyle{mainmatter}

\chapter{A}
\kant
\chapter{B}
\kant
\chapter{C}
\kant
\end{document}

empty私はそれぞれ mainmatter と frontmatter の章ページ スタイルとしてと を使用しましたがplain、これを任意のスタイルに更新したり、独自の新しいスタイルを作成したりすることもできます。

また、memoirヘッダー/フッターを作成する機能も提供されているので、fancyhdrこのために。

答え2

titlesecパッケージには\assignpagestyle{\chapter}{<style>}コマンドが用意されており、 と同じように使用できます\pagestyleが、各章の最初のページのみを変更します。 の場合と同じです\thispagestyle{}が、 を明示的に更新しません\chapter

関連情報