# rightmark shows next subsection, not the active one on top of side [closed]

I don't like the logic behind the \rightmark for \subsection in this example.

  \documentclass[12pt,a4paper]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{xcolor,blindtext}
\usepackage[komastyle,nouppercase]{scrpage2}

\automark[subsection]{section}                       % section left, subsection right
\ihead{\leftmark\ifstr{\leftmark}{\rightmark}{}{:}}  % left: leftmark, and if rightmark differs, add an ":"
\ohead{\ifstr{\leftmark}{\rightmark}{}{\rightmark}}  % only rightmark, if leftmark is different
\cfoot{\pagemark}                                    % foot page number

\renewcommand*{\sectionmarkformat}{}                 % removes numbering from section in head
\renewcommand*{\subsectionmarkformat}{}              % removes numbering from subsection in head

\begin{document}

\section{Intro}
\blindtext[8]
\subsection{Part of Intro}
\blindtext[2]
\subsection{next Part of Intro}
\blindtext[5]
\section{Outro}
\blindtext
\end{document}


This results at page two is:

I would like to see the subsection of page two in the header of page three, and not subsection 1.2 which starts at the same page. Imagine you flip the page and forgot which subsection it was: than it would be better if you can rely on the header. But the usual appearance shows you the same subsection you are also able to read in the center of page three.

So is there a possibility to change this behaviour, so that I can see the subsection (and the same for section, subsubsection ...) of the topmost text lines at each page?

I hope I expressed clearly enough. Thanks in advance!

• I noticed this as well, but I've never looked into it. Although, it's not that it shows "next subsection", rather "the one that starts in the current page". – Alenanno Jan 6 '16 at 14:00
• It is possible but not easy (unless you add e.g. a \markright{Part of Intro} at the end of the subsection.). The code would have to test if a section/subsection is at the begin of the page. See e.g. tex.stackexchange.com/questions/51433/… – Ulrike Fischer Jan 6 '16 at 14:05
• Insert \subsection{Last Part of Intro} just before \section{Outro} in your example ... Then the first mark on that page is set by the \subsection and not by the \section command. See also tex.stackexchange.com/a/280954/43317 – esdd Jan 6 '16 at 14:28
• You wouldn't want \subsection to write \section ;-). Beside this your suggestion wouldn't work if there is \newpage before a sectioning command. It is really not easy to do this automatically, (without an explicit marking of the end of a section or subsection.) – Ulrike Fischer Jan 6 '16 at 14:38
• How in the world is this closed as not clear enough? He's posted a MWE and he's just asking for p.3 to show "Part of Intro" in the upper right corner of the page 3, since that's the title of the subsection that the page starts in. What's unclear? – Kevin Holt Mar 20 '19 at 17:13