5

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!

Phil
  • 359
  • 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 06 '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. http://tex.stackexchange.com/questions/51433/macro-that-knows-it-is-at-the-end-of-a-section/53849#53849 – Ulrike Fischer Jan 06 '16 at 14:05
  • @UlrikeFischer: Is there a possibility to \renewcommand the \subsection command so, that at its writing something like \markright{\lastsubsectionname}\section{#1}? – Phil Jan 06 '16 at 14:19
  • Do you really want "Outro: next Part of Intro" in your header on page 3? Note that this could also happen with your current example if a new subsection is followed by a new section on the same page. – esdd Jan 06 '16 at 14:20
  • @esdd: no, this shouldn't happen, because the \ifstr blocks subsections if a new section appears – Phil Jan 06 '16 at 14:21
  • 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 http://tex.stackexchange.com/a/280954/43317 – esdd Jan 06 '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 06 '16 at 14:38
  • Sorry, my fault. I know it wouldn't be easy, but because it's not easy, it doesn't mean it's impossible ;) so I really would like to see an answer! – Phil Jan 08 '16 at 15:24
  • I found a first (but not perfect) solution: I now use scrlayer-scrpage which adds \righttopmark where \topmark gives the mark last used on the previous side and the word right before forces it to use just the \rightmark, in my case this stands for subsection. Now I only need to let \rightmark detect whether there is a \subsubsection after a \subsection so that this will be prompted instead. Got my Problem? Any idea? – Phil Feb 04 '16 at 10:04
  • 2
    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

0 Answers0