I'm writing a gamebook. My text is divided into a lot of little paragraphs, with length varying from a couple of lines to a page and a half. Readers/players will start from paragraph 1 and then move from one paragraph to the other according to their choices, which are usually presented in this format:
If you want to do this, go to paragraph 20.
If you want to do this other thing, go to paragraph 31.
If you want to do this instead, go to paragraph 2.
Now: I noticed that, because of the peculiarities of this format, sometimes it isn't clear whether there's more to read in the following page. For instance, in the example above, if the third line ends up in the following page players won't realize it's there and won't take that option.
I'd like to solve this by having something to appear at the right footer of the page in case there's more to read in the following page. Something such as "Keep on reading...".
I can't take the document and phisically insert all those indications both because the book will be big and because the paragraph will be randomized when I export them (they will actually be written in an other document, generated by a script). Also the page breaks would move every time I modify the text, and this is destined to happen a lot of times before the game will be definitively complete.
So: I suppose I'll need to use the package ifthen, and to put a \ifthenelse statement in the RO and RE footer. My issue is that I don't know how to write the conditional: how can I ask LaTeX if the section is over or there's more on the following page?
Here's a MWE that generates a document on which we can work. As you'll see, some section will end at the end of the page, others will span on the following one. I need the words "Keep on reading..." to appear in the footer of the page in the second case.
\documentclass[a4paper, 11pt]{book}
\usepackage[esperanto]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{microtype}
\pagestyle{fancy}
\fancyhead[LO, RE]{}
\fancyhead[RO]{\small \thepage}
\fancyhead[LE]{\small \thepage}
\fancyhead[CE]{\textit{Profanator}}
\fancyhead[CO]{\textit{Atlante 1}}
\cfoot{}
\renewcommand{\headrulewidth}{0pt}
\begin{document}
\chapter{Example}
\section*{1}
\lipsum[1-2]
\section*{2}
\lipsum[3-4]
\section*{3}
\lipsum[5-6]
\section*{4}
\lipsum[7-8]
\section*{5}
\lipsum[9-10]
\section*{6}
\lipsum[11-12]
\section*{7}
\lipsum[13-14]
\section*{8}
\lipsum[15-16]
\section*{9}
\lipsum[17-18]
\section*{10}
\lipsum[19-20]
\end{document}
EDIT 08/07/2023
Clarifications about the problem have been asked. Probably I didn't explain my issue properly.
Here's the current situation:
It's in italian language, but you get the context: at the page break it's not self-evident that there are more options on the following page, so I need something to indicate this. I'll make some experiments with words and symbols to find the best solution, but adding something there seems to be the correct starting point for me. This thing will hopefully solve the problem.
Stephen's solution worked perfectly. I personally don't love mixing TeX primitives with LaTeX commands, so I altered his version using the ifthen package. I'll leave this here for future users. It's exactly the same thing, at the end of the day.
\documentclass[a4paper, 11pt]{book}
\usepackage[esperanto]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage{refcount}
\usepackage{ifthen}
\pagestyle{fancy}
\fancyhead[LO, RE]{}
\fancyhead[RO]{\small \thepage}
\fancyhead[LE]{\small \thepage}
\fancyhead[C]{}
\fancyfoot[C]{}
\fancyfoot[R]{%
\ifthenelse{\getpagerefnumber{text-begin-\thetext}<\getpagerefnumber{text-end-\thetext}}%
{\textit{Keep on reading...}}%
{}%
}
\fancypagestyle{plain}{}
\renewcommand{\headrulewidth}{0pt}
\newcounter{text}
\newenvironment{text}{%
\refstepcounter{text}%
\label{text-begin-\thetext}%
}{%
\label{text-end-\thetext}%
}
\begin{document}
\chapter{Example}
\section*{1}
\begin{text}\lipsum[1-2]\end{text}
\section*{2}
\begin{text}\lipsum[3-4]\end{text}
\section*{3}
\begin{text}\lipsum[5-6]\end{text}
\section*{4}
\begin{text}\lipsum[7-8]\end{text}
\section*{5}
\begin{text}\lipsum[9-10]\end{text}
\section*{6}
\begin{text}\lipsum[11-12]\end{text}
\section*{7}
\begin{text}\lipsum[13-14]\end{text}
\section*{8}
\begin{text}\lipsum[15-16]\end{text}
\section*{9}
\begin{text}\lipsum[17-18]\end{text}
\section*{10}
\begin{text}\lipsum[19-20]\end{text}
\end{document}




