4

I am editing a collection of articles by a scholar. For this I find it extremely useful if not necessary to indicate pagebreaks in the first edition of articles so that citations of certain passages of these articles in other, especially older texts, are still valid and viable. Here is my MWE-example for this:

\documentclass{scrbook}

\usepackage{lipsum}
\usepackage{scrlayer-scrpage}
\ohead{\textbf{\pagemark}}
\ihead{\textit{\theoldpage}}
\ofoot{}
\pagestyle{scrheadings}

\newcounter{oldpage}
\setcounter{oldpage}{1}

\newcommand{\markoldpage}{
[mark]
\marginpar{\begin{center}\footnotesize\theoldpage\end{center}}
\stepcounter{oldpage}
}

\begin{document}

\chapter{Chapter}

\markoldpage{} This is the first oldpage. \markoldpage{} Now the second oldpage has begun.

\newpage

\lipsum \markoldpage{} \lipsum \markoldpage{}

\end{document}

What I have achieved is defining a new counter oldpage. Every chapter begins a new article. Therefore I manually set the oldpage-counter every time a new chapter starts. Some sort of ›[mark]‹-symbol indicates a pagebreak in the old text. The oldpage is then also indicated in the margins. The oldpage-counter is then set in the head, on the exact opposite side of the normal page-counters (E.g. if the page counter in a book is top-outer, the oldpage-counter is top-inner). I achieved this using scrlayer-scrpage.

What I would like is the oldpage-counter to be context-sensitive, which means that it should behave to following way:

  • If there is one oldpage referred to on the newpage, the oldpage-counter should simply show the number (e.g. ›1‹)
  • if there are two oldpages referred to on the newpage, the oldpage-counter should show the numbers separated by a space and a comma (e.g. ›1, 2‹)
  • if there are three ore more oldpages referred to on the newpage, the oldpage-counter should show the first and the last number connected with a double-dash (e.g. ›1--3‹)

To program the intended behaviour it is, I guess, necessary to work with conditionals, and these conditionals probably need information how many oldpage-breaks there will be on the output page in the end. My questions are thus:

  • Where can one obtain the information and how can one refer to it? I haven´t got a clue, and it wouldn´t know where to start looking.

I would be extremely greatful if someone could help me do the first step and help me write some code on this.

3
  • you need a macro using your old-counter... A counter can not provide two numbers... Counters are just integers.
    – koleygr
    Commented Jul 5, 2017 at 20:27
  • this is what \mark are for (it is how section headings get to the page head) you need to set a mark each time you change the counter and then tex in the page head will give you the first and last mark on the page Commented Jul 5, 2017 at 20:29
  • If you use \refstepcounter{oldpage} then \label{name}, then \ref{name} will return old page and \pageref{name} will return the new page. Commented Jul 5, 2017 at 21:18

1 Answer 1

3

TeX's mark system provides a way to track values that should be registered in the page head.

enter image description here

\documentclass{scrbook}

\usepackage{lipsum}
\usepackage{scrlayer-scrpage}
\ohead{\textbf{\pagemark}}
\def\lastoldpagemark{\topmarks\oldpagemark}
\ihead{\textit{\lastoldpagemark\ifnum\lastoldpagemark<\botmarks\oldpagemark--\botmarks\oldpagemark\fi
               \xdef\lastoldpagemark{\botmarks\oldpagemark}}}
\ofoot{}
\pagestyle{scrheadings}
\newmarks\oldpagemark % etex marks not completely reliable in latex, but probably OK here
\newcounter{oldpage}
\setcounter{oldpage}{1}

\newcommand{\markoldpage}{%%%
[mark]%%%
\marks\oldpagemark{\theoldpage}\marginpar{\centering\footnotesize\theoldpage}%%%
\stepcounter{oldpage}%%%
}

\begin{document}

\chapter{Chapter}

\markoldpage{} This is the first oldpage. \markoldpage{} Now the second oldpage has begun.

\newpage

\lipsum \markoldpage{} \lipsum \markoldpage{}

\end{document}
4
  • I just tested the macros with LuaLaTeX in a different context, and they worked fine; however, when I compiled the exact same code with XeLaTeX the pagenumbers in the header appear oddly, e.g. instead of [2–4] with LuaLaTeX I receive [444] with XeLaTeX. Have you got any idea as to what leads to this behaviour?
    – Kubo
    Commented Jan 27, 2018 at 6:20
  • @Kubo not really, I suggest you make an example showing the problem and ask a new question, referencing this one, and I'll have a look. Commented Jan 27, 2018 at 8:37
  • The above solution works like charm in a continous document. However, I have encountered many problems as soon as the counter oldpage switches to an entirely different value, which is often the case in collected works, as a change of the article indicates a change of journal and therefore page-number. Shall I open up a new question or edit the question to include these problems and what I have come up with so far?
    – Kubo
    Commented Jul 27, 2018 at 16:58
  • See part 2 of this question here
    – Kubo
    Commented Nov 27, 2019 at 11:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .