Pagestyle、\sectionmarkformat 和 KOMA \DeclareSectionCommand

Pagestyle、\sectionmarkformat 和 KOMA \DeclareSectionCommand

我需要具有自己的章节和章节宏\sectionmarkformat
我尝试使用以下方法创建它:KOMA (v.3.24) \DeclareSectionCommand
我的 MWE:

\documentclass[draft=false,version=last,paper=a6,twoside,open=right,headings=optiontoheadandtoc,chapterprefix=no]{scrbook} 
\usepackage[headsepline]{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{lipsum}

\DeclareSectionCommand[%
    style=section,%
    indent=0pt,%
    level=1,%
    counterwithin=chapter,
    beforeskip=-3.5ex plus -1ex minus -.2ex,%
    afterskip=2.3ex plus.2ex,%
    %   pagestyle=scrheadings,% not working for sectioin; 
    %   in log-file: auto-selection of `pagestyleset=KOMA-Script' 
    toclevel = 1,
    tocindent=1.5em,% 
    tocnumwidth=2.3em,%
    font=\usekomafont{section}%
]{zsection}

\DeclareSectionCommand[%
    style=chapter,%
    level=0,%
    beforeskip=-3\baselineskip,%
    afterskip=1.5\baselineskip plus .1\baselineskip minus .167\baselineskip,%
    pagestyle=scrheadings,
    toclevel = 0,
    tocindent=0pt,% 
    tocnumwidth=1.5em,%
    font=\usekomafont{chapter}%
]{zchapter}

%\renewcommand*{\zsectionmarkformat}{\thezsection\autodot\enskip}
\renewcommand*{\zsectionmarkformat}{}

\begin{document}

\zchapter[tocentry={Zchapter},head={zchap}]{Zhapter Title text}
    \zsection[tocentry={Zsection},head={zsec}]{Zsection Title text}
    \lipsum
\chapter[tocentry={Chapter},head={chap}]{Chapter title text}
    \section[tocentry={Section},head={sec}]{Section title text}
    \lipsum
\tableofcontents

\end{document}  

在文本和目录中,所有打印都正常(几乎)。但我有 标题对于新的\zsection\zchapter,与通常的部分相反。

也许pagestyle这里用不了?我可以申请pagestyle新部分吗?或者我需要其他方法(patchcmd等等renewcommand{\section})?

谢谢。

答案1

使用

\automark*[zsection]{zchapter}

获取新部分命令的运行标题。

在此处输入图片描述

代码:

\documentclass[
  paper=a6,
  headings=optiontoheadandtoc,
  ]{scrbook} 
\usepackage[headsepline,
  automark% <- added
]{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{lipsum}

\DeclareSectionCommand[%
    style=section,%
    indent=0pt,%
    level=1,%
    counterwithin=chapter,
    beforeskip=-3.5ex plus -1ex minus -.2ex,%
    afterskip=2.3ex plus.2ex,%
    toclevel = 1,
    tocindent=1.5em,% 
    tocnumwidth=2.3em,%
    font=\usekomafont{section}%
]{zsection}

\DeclareSectionCommand[%
    style=chapter,%
    level=0,%
    beforeskip=-3\baselineskip,%
    afterskip=1.5\baselineskip plus .1\baselineskip minus .167\baselineskip,%
    %pagestyle=scrheadings,% I would suggest to use plain as for normal chapters
    toclevel = 0,
    tocindent=0pt,% 
    tocnumwidth=1.5em,%
    font=\usekomafont{chapter}%
]{zchapter}

\automark*[zsection]{zchapter}% <- added
\renewcommand*{\zsectionmarkformat}{}% there will be unnumbered zsections in header

\begin{document}

\zchapter[tocentry={Zchapter},head={zchap}]{Zhapter Title text}
    \zsection[tocentry={Zsection},head={zsec}]{Zsection Title text}
    \lipsum
\chapter[tocentry={Chapter},head={chap}]{Chapter title text}
    \section[tocentry={Section},head={sec}]{Section title text}
    \lipsum
\tableofcontents

\end{document}

如果你使用KOMA-Script 版本 3.24 或更新版本新的和beforeskip和应该与 相同,您可以从 中删除这两个选项。从 3.24 版开始,和中的和值将分别用于使用和 的新分段命令。afterskipzchapterchapter\DeclareSectionCommandbeforeskipafterskipchapterpartstyle=chapterstyle=part

还有一些其他更改:

\documentclass[
  paper=a6,
  headings=optiontoheadandtoc,
  %headings=normal% default is big
  ]{scrbook}[2017/09/07]% code needs version 3.24 or newer
\usepackage[headsepline,
  automark% <- added, does the same as \automark[section]{chapter}
]{scrlayer-scrpage}
\pagestyle{scrheadings}
\usepackage{lipsum}

\DeclareNewSectionCommand[% <- ...New... to ensure its really new
    style=chapter,%
    level=\chapternumdepth,% <- changed: use the same level as chapter
    toclevel=\chaptertocdepth,% <- changed: use the same level as chapter
    tocindent=0pt,% 
    tocnumwidth=1.5em,%
    tocentryformat={\usekomafont{chapterentry}},% <- added to use the same font settings in ToC
    tocpagenumberformat={\usekomafont{chapterentry}\usekomafont{chapterentrypagenumber}},% <- added
    toclinefill=\hfill% <-added
]{zchapter}

\DeclareNewSectionCommand[% <- ...New... to ensure its really new
    style=section,%
    level=\sectionnumdepth,% <- changed: use the same level as section
    counterwithin=chapter,
    beforeskip=-3.5ex plus -1ex minus -.2ex,%
    afterskip=2.3ex plus.2ex,%
    toclevel = \sectiontocdepth,% <- changed: use the same level as section
    tocindent=1.5em,% 
    tocnumwidth=2.3em,%
    font=\usekomafont{section}%
]{zsection}

\automark*[zsection]{zchapter}%<- added
\renewcommand*{\zsectionmarkformat}{}% there will be unnumbered zsections in header

\begin{document}

\zchapter[tocentry={Zchapter},head={zchap}]{Zhapter Title text}
    \zsection[tocentry={Zsection},head={zsec}]{Zsection Title text}
    \lipsum
\chapter[tocentry={Chapter},head={chap}]{Chapter title text}
    \section[tocentry={Section},head={sec}]{Section title text}
    \lipsum
\tableofcontents
\end{document}

相关内容