0

How can I include a "hidden" \section*{} or \chapter*{} in the header (centered) using scrpage2?

  \documentclass[a4paper,12pt]{scrbook}
    \usepackage[T1]{fontenc}

    \usepackage[automark]{scrpage2}
    \pagestyle{scrheadings}
    \chead{\headmark}
    \ohead{\pagemark}
    \automark[chapter*]{section*}  %%leftpageheader: chapter* / rightpagehaeder: section*
    \begin{document}
    \chapter*{Bla}

    \pagebreak

    \section*{Blub}

    \end{document}
5
  • Do you just want unnumbered chapers and sections?
    – Johannes_B
    Dec 22, 2017 at 14:10
  • Yes. unnumbered Dec 22, 2017 at 14:14
  • Do you use \chapter* here to have an unnumbered chapter or to prevent the chapter from being in toc (or both)?
    – TeXnician
    Dec 22, 2017 at 15:05
  • @TeXnician I just don't want any numbers. (but I want other parts of the book with numbered chapters as well) Dec 22, 2017 at 15:08
  • Please note: scrpage2 is obsolete. You should use scrlayer-scrpage instead of scrpage2. Dec 22, 2017 at 15:22

2 Answers 2

3

scrbook like book does not provide automatic running head for \chapter* and \section*. If everything should be unnumbered, set \secnumdepth to -2 and use \chapter and \section instead of \chapter* and \section*:

\documentclass[a4paper,12pt]{book}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\chead{\headmark}
\ohead{\pagemark}
\setcounter{secnumdepth}{-2}%
\usepackage{blindtext}
\begin{document}
\chapter{Bla}

\section{Blub}

\Blindtext[10]

\end{document}

If you have numbered and not numbered chapters and section, you can use:

\documentclass[a4paper,12pt]{book}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\chead{\headmark}
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\chapter*{Bla}
\markboth{\MakeUppercase{Bla}}{}

\section{Blub}
\markright{\MakeUppercase{Blub}}

\Blindtext[10]

\end{document}

But using scrbook it is more easy to use \addchap and \addsec:

\documentclass[a4paper,12pt]{scrbook}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\chead{\headmark}
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\addchap{Bla}

\addsec{Blub}

\Blindtext[10]

\end{document}

If you want to avoid the ToC entries:

\documentclass[a4paper,12pt,headings=optiontotoc]{scrbook}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\chead{\headmark}
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\addchap[]{Bla}

\addsec[]{Blub}

\Blindtext[10]

\end{document}

And please note, that scrpage2 is obsolete. You should use scrlayer-scrpage:

\documentclass[a4paper,12pt,headings=optiontotoc]{scrbook}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrlayer-scrpage}
\chead{\headmark}
\ohead{\pagemark}
\usepackage{blindtext}
\begin{document}
\tableofcontents
\addchap[]{Bla}

\addsec[]{Blub}

\Blindtext[10]

\end{document}

See the KOMA-Script manual or the German KOMA-Script manual or the German KOMA-Script book for more information about scrlayer-scrpage, \addchap, \addsec and option headings.

3
  • Thank you @Schweinebacke – but what if I want numbered and unnumbered \chapterin the same document (like an unnumbered appendix)? Dec 22, 2017 at 15:10
  • @לאהפּאַסטעך See the additional examples. Dec 22, 2017 at 15:20
  • Thank you both! the addchap / addsec command is new to me, but much better than the "old" \chapter* And thanks for the information that scrpage2is obsolete! Dec 22, 2017 at 15:30
3

As your intention is to get unnumbered sections or chapters you can use KOMA's commands \addchap and \addsec which will produce unnumbered headings, but set the head marks and add the title to toc.

\documentclass[a4paper,12pt]{scrbook}
\usepackage[T1]{fontenc}

\usepackage[automark]{scrpage2}
\pagestyle{scrheadings}
\chead{\headmark}
\ohead{\pagemark}
\automark[chapter]{section}  %%leftpageheader: chapter* / rightpagehaeder: section*
\begin{document}
\addchap{Bla}

\pagebreak

\addsec{Blub}

\pagebreak
test
\end{document}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.