Как получить пользовательские заголовки на левой и правой страницах?

Как получить пользовательские заголовки на левой и правой страницах?

У меня есть следующие 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}

Надеюсь, поможет!

Связанный контент