[Tex/LaTex] How to remove the section title in header using scrpage2

header-footerscrpage2

I would like to remove the section title (header) in the appendix:

\documentclass[headsepline, open=right,twoside=true, numbers=noenddot]{scrreprt}

\usepackage[english]{babel}
\usepackage{scrpage2}
\usepackage{blindtext}

\clearscrheadfoot
\ihead{\headmark}
\ohead[\pagemark]{\pagemark}
\automark[section]{chapter}
\pagestyle{scrheadings}
\renewcommand*{\chapterpagestyle}{empty}


\begin{document}

\begin{appendix}

    \chapter{Appendix}
    \section{Remove the section title}
    \blindtext[12]

\end{appendix}

\end{document}

I'm looking for something like \renewcommand*{\sectionmarkformat}{} except I want to keep the number and remove the title.

Best Answer

If the KOMA-Script option appendixprefix is not used:

\newcommand*{\appendixmore}{%
  \renewcommand\sectionmark[1]{%
    \markright{\ifnumbered{section}{\thesection\autodot}{}}%
}}

enter image description here

Using \ifnumbered avoids a wrong number in the header if there is an unnumbered section.

Note \appendix is not an environment. The package scrpage2 is depreciated. Use scrlayer-scrpage instead.

\documentclass[headsepline,twoside, numbers=noenddot]{scrreprt}
\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\headmark}
\ohead[\pagemark]{\pagemark}
\automark[section]{chapter}
\renewcommand*{\chapterpagestyle}{empty}
\newcommand*{\appendixmore}{%
  \renewcommand\sectionmark[1]{%
    \markright{\ifnumbered{section}{\thesection\autodot}{}}%
}}

\begin{document}
\appendix
\chapter{Appendix}
\section{Remove the section title}
\blindtext[30]
\addsec{Unnumbered section}
\blindtext[12]
\end{document}
Related Question