scrlayer-scrpage: "Глава 1" в lehead, "Заголовок главы" в rohead

scrlayer-scrpage: "Глава 1" в lehead, "Заголовок главы" в rohead

Используя scrlayer-scrpage в documentclass scrreprt, я хотел бы, чтобы слово "Глава 1" (или 2, или какая бы глава это ни была) отображалось во внешнем заголовке четных страниц, а название главы - без "Глава 1" перед ним - во внешнем заголовке нечетных страниц (см. изображение). ПРАВКА: В ненумерованных главах заголовок должен быть пустым. Как этого добиться?

введите описание изображения здесь

Мой МВЭ:

\documentclass[twoside, openright, BCOR=1cm, bibliography=totoc,headsepline,chapterprefix=true]{scrreprt}

\usepackage{scrlayer-scrpage}

\pagestyle{scrheadings}
\automark[chapter]{chapter}
\usepackage{lipsum}

\setcounter{secnumdepth}{0}

\begin{document}

\chapter{An interesting title}
\thispagestyle{empty}

\newpage

\section{A slightly less interesting title}
\lipsum[1-5]

\end{document}

решение1

Вопрос: Что должно быть в заголовке четных страниц, если глава не пронумерована?


Вот предложение, где название главы будет использоваться на четных страницах в ненумерованных главах:

\documentclass[
  twoside, open=right, BCOR=1cm,
  bibliography=totoc,
  headsepline,
  chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text

\usepackage{scrlayer-scrpage}% sets pagestyle scrheadings automatically
\automark{chapter}

\renewcommand*\chaptermark[1]{%
  \markboth{\ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}

\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\end{document}

или без упаковки scrlayer-scrheadings:

\documentclass[
  twoside, open=right, BCOR=1cm,
  bibliography=totoc,
  headsepline,
  chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text

\pagestyle{headings}

\renewcommand*\chaptermark[1]{%
  \markboth{\ifnumbered{chapter}{\chaptermarkformat}{#1}}{#1}%
}
\renewcommand*\sectionmark[1]{}

\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\end{document}

Если заголовок четной страницы должен быть пустым для ненумерованных глав, вы можете использовать

\renewcommand*\chaptermark[1]{%
  \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

Кроме того, вам придется переключиться на ручные отметки и вручную устанавливать отметки для TOC и т. д.:

\manualmark% or option manualmark for package `scrlayer-scrpage`
\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}

Пример:

\documentclass[
  twoside, open=right, BCOR=1cm,
  bibliography=totoc,
  headsepline,
  chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text

\usepackage[manualmark]{scrlayer-scrpage}% sets pagestyle scrheadings automatically

\renewcommand*\chaptermark[1]{%
  \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}

\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\end{document}

или без упаковки scrlayer-scrheadings:

\documentclass[
  twoside, open=right, BCOR=1cm,
  bibliography=totoc,
  headsepline,
  chapterprefix=true
]{scrreprt}
\usepackage{blindtext}% only for dummy text

\pagestyle{myheadings}

\renewcommand*\chaptermark[1]{%
  \markboth{\ifnumbered{chapter}{\chaptermarkformat}{}}{#1}%
}

\AfterTOCHead[toc]{\markboth{}{\contentsname}}
%\AfterTOCHead[lof]{\markboth{}{\listfigurename}}
%\AfterTOCHead[lot]{\markboth{}{\listfigurename}}

\begin{document}
\tableofcontents
\chapter{Numbered Chapter}
\blindtext
\section{Numbered Section}
\Blindtext[10]
\addchap{Unnumbered Chapter}
\blindtext
\addsec{Unnumbered Section}
\Blindtext[10]
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument\Blinddocument\Blinddocument
\Blinddocument\Blinddocument
\end{document}

решение2

Вы можете переопределить \chaptermarkи \sectionmarkдля того, чтобы достичь этого.

\documentclass[twoside]{scrreprt}

\usepackage{lipsum} % just for example text

\pagestyle{headings}

\renewcommand*\chaptermark[1]{%
  \markboth{Chapter~\thechapter}{#1}%
}
\renewcommand*\sectionmark[1]{}

\begin{document}

\chapter{Some Title}
\lipsum[1-5]

\section{A Section}
\lipsum[6-12]

\section{Another Section}
\lipsum[13-20]

\end{document}

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