左ページと右ページにカスタム ヘッダーを表示するにはどうすればよいですか?

左ページと右ページにカスタム ヘッダーを表示するにはどうすればよいですか?

私は次の MWE を取得しました:

\documentclass[twoside]{book}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,headheight=28pt,bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\usepackage{fancyhdr}


\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{10pt}{\Huge\thechapter.\quad}
\newpagestyle{mystyle}{
  \sethead[][][\thechapter.\quad\chaptertitle]{\sectiontitle}{}{\thepage}
  \setfoot[][\thepage][]{\thesection~\sectiontitle}{}{\thepage}}


\begin{document}

\pagestyle{mystyle}
\chapter{Introduction}
\lipsum[1-40]

\end{document}

偶数ページにのみカスタム ヘッダーが生成されます。奇数ページにはページ番号が表示されます。奇数ページと偶数ページの両方で中央の位置にカスタム ヘッダー (1. はじめに) を表示するにはどうすればよいでしょうか。

答え1

\sectiontitleヘッダーに表示するには、\section

以下を確認してください:

\documentclass[twoside]{book}

\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,headheight=28pt,bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\usepackage{fancyhdr}

\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{10pt}{\Huge\thechapter.\quad}
\newpagestyle{mystyle}{
  \sethead[][][\thechapter.\quad\chaptertitle]{}{}{\thesection~\sectiontitle}
  \setfoot[][\thepage][]{}{\thepage}{}}

\begin{document}
\pagestyle{mystyle}
\chapter{Introduction}
\lipsum[1-5]
\section{H1 for test}
\lipsum[1-15]
\end{document}

それが役に立てば幸い!

関連情報