本のタイトルを見出しにするにはどうすればいいですか?

本のタイトルを見出しにするにはどうすればいいですか?

奇数ページには章、続いてページ番号を入れたいです。そして偶数ページにはページ番号、続いてタイトルを入れたいです。問題は、どうやって入れるかです。

答え1

標準クラスを使用する場合は、バンドルからパッケージbookを使用できます。次のコードをプリアンブルに追加するだけです。titlepstitlesec

\usepackage{titleps}
\newpagetyle{mystyle]{%
\titlerule% if you want a header rule
\sethead[\thepage\quad\chaptertitle][][]{}{}{\chapterritle\quad\thepage}
\setfoot{}{}{}
}%
\pagestyle{mypage}

章のタイトルをヘッダーの中央に配置したい場合は、次のように記述します。

\sethead[\thepage][\chaptertitle][]{}{\chaptertitle}{\thepage}

例と可能性の詳細については、ドキュメントを参照してください。

答え2

KOMA-Script クラスを使用すると、scrbook次のように簡単に使用できます。

\documentclass{scrbook}

\usepackage{mwe}
\usepackage{scrlayer-scrpage}
\automark[chapter]{chapter}
\clearpairofpagestyles
\lehead{\pagemark\quad\expandafter\MakeMarkcase\csname @title\endcsname}
\rohead{\headmark\quad\pagemark}

\begin{document}
\title{Title of the Document}
\author{Author of the Document}
\maketitle
\blinddocument
\end{document}

章見出しのあるページには、デフォルトでは見出しが表示されないことに注意してください。

標準クラスを使用している場合は、\@titleの後に が削除されます\maketitle。そのため、新しいコマンドを使用するのが簡単な解決策になる場合があります。

\documentclass{book}

\usepackage{mwe}
\newcommand*{\Title}{Title of the Document}
\usepackage{scrlayer-scrpage}
\automark[chapter]{chapter}
\clearpairofpagestyles
\lehead{\pagemark\quad\MakeMarkcase{\Title}}
\rohead{\headmark\quad\pagemark}

\begin{document}
\title{\Title}
\author{Author of the Document}
\maketitle
\blinddocument
\end{document}

関連情報