4

I need own section and chapter macros with own \sectionmarkformat.
I try create it with: KOMA (v.3.24) \DeclareSectionCommand.
My 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}  

In text and TOC all printed normally (almost). But I have no running headers for new \zsection and \zchapter, contrary to usual sections.

Perhaps pagestyle not using here? Can I apply pagestyle for new section? Or I need some other way (patchcmd, renewcommand{\section} etc.)?

Thank you.

1 Answer 1

5

Use

\automark*[zsection]{zchapter}

to get running headers for the new section commands, too.

enter image description here

Code:

\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}

If you use KOMA-Script version 3.24 or newer and beforeskip and afterskip for the new zchapter should be the same as for chapter, you can remove this two options from \DeclareSectionCommand. Starting with version 3.24 the values of beforeskip and afterskip from chapter and part will be used for new sectioning commands using style=chapter and style=part respectively.

With some additional changes:

\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}
5
  • Thank you! It's work fine. One little subquestion, if possible. If i try set default value (from documentation) for beforeskip=-3\baselineskip-\parskip for chapter, this is not compiled: ! Package scrbase Error: unknown option `beforeskip=3\baselineskip -\parskip '. (In my MWE I delete -\parskip for compiling). Is there some ideas?
    – Elisey
    Commented Sep 30, 2017 at 7:46
  • Use beforeskip=\dimexpr 3\baselineskip-\parskip\relax. But note this is the default value for headings=normal and scrbook uses headings=big by default. So you will get different skips for chapter and zchapter.
    – esdd
    Commented Sep 30, 2017 at 9:40
  • Do you really want numberwithin=chapter for zsection?
    – esdd
    Commented Sep 30, 2017 at 9:41
  • Thank you. In my book I have some chapters with only one section. And for this "zero" section I need alternative markformat (numbering in r-header, etc). But hierarhically this z-secion exist into usual chapter. In a similar, there is part with only one, "zero"-chapter. As for \dimexpr - this not compiled too unfortunatelly. And yes, I mistook about default "big" headings, thank you again!
    – Elisey
    Commented Sep 30, 2017 at 10:04
  • @Evgeny Maybe you can accept the answer if it solves your issue.
    – esdd
    Commented Sep 30, 2017 at 19:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .