4

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}

  \clearscrheadfoot
  \pagestyle{scrheadings}
  \automark[subsection]{section}                       % section left, subsection right
  \setheadsepline{.2pt}[\color{black}]
  \renewcommand*{\headfont}{\normalfont}
  \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: enter image description here

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!

closed as unclear what you're asking by Andrew Swann, Stefan Pinnow, Phelype Oleinik, TeXnician, Bobyandbob Apr 16 '18 at 13:41

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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
  • 2
    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
  • 1
    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
  • 1
    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
  • 1
    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 at 17:13