4

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:

enter image description here

enter image description here

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}
1

3 Answers 3

5

This answer is based on the link that I have mentioned in the comment.

Put the text in each section in an environment text and set two labels at the ends of the environment.

\documentclass[a4paper, 11pt]{book}

\usepackage[esperanto]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage{lipsum}
\usepackage{fancyhdr}
\usepackage{microtype}
\usepackage{refcount}
\pagestyle{fancy}
\fancyhead[LO, RE]{}
\fancyhead[RO]{\small \thepage}
\fancyhead[LE]{\small \thepage}
\fancyhead[CE]{\textit{Profanator}}
\fancyhead[CO]{\textit{Atlante 1}}
\fancyfoot[C]{}
\fancyfoot[R]{%
  \ifnum\getpagerefnumber{text-begin-\thetext}<\getpagerefnumber{text-end-\thetext}%
  \textsl{Keep on reading}%
  \fi}
\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}

enter image description here

1
  • Brilliant, and perfectly clear. Thank you ;) Jul 8, 2023 at 11:56
0

I'm not sure to have correctly understood your question, but why don't you simply put \nopagebreak at the end of every line you don't want to be alone on the next page (that is, the end of the paragraph and every line with "if you want ... go to ...")?

\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]

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.

Some text just to put the lines on the page border.\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{2}
\lipsum[3-4]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{3}
\lipsum[5-6]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{4}
\lipsum[7-8]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{5}
\lipsum[9-10]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{6}
\lipsum[11-12]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{7}
\lipsum[13-14]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{8}
\lipsum[15-16]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{9}
\lipsum[17-18]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\section*{10}
\lipsum[19-20]\nopagebreak

If you want to do this, go to paragraph X.\nopagebreak

If you want to do this other thing, go to paragraph Y.\nopagebreak

If you want to do this instead, go to paragraph Z.\nopagebreak

\end{document}

enter image description here

3
  • 1
    The clarity issue remains because sometimes there are more than one lines on the following page, but still there are enough options on the original ones so people still might not realize that there's more. Jul 8, 2023 at 11:38
  • @ilmietitore If there is more than one line on the following page, there is also no separation of the following lines, but perhaps I didn't understand your question
    – CarLaTeX
    Jul 8, 2023 at 13:23
  • Sorry, I totally misunderstood your reply. What you propose makes sense, actually, and I would have done it this way if this happened only a few times over hundreds of pages. I think it is detrimental to the page's layout on the long run, though, because in my case this happens very much frequently (I dare to say the majority of times). The space between paragraph, lines and margins would end up being a mess. So I need a visual thing like this one. Jul 8, 2023 at 13:57
0

You are trying to use LaTeX to control/influence a reader's behavior. Rather than alter your LaTeX code, would it not be better to offer a visual cue to the the reader that their options are continued on the next page, like an incomplete box? You can used the framed package for that:

\documentclass{report}
\usepackage{lipsum}
\usepackage{framed}

\begin{document}


\chapter{The Basics}

\lipsum[5]

\begin{oframed}

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

If you want to do this, go to page X.

\end{oframed} % end minipage

\end{document}

Breaking box using framed package with oframed environment

1
  • 1
    I might find better graphical clues like the one you are suggesting. But I prefer to work on that after the game will be ready. For now, the solution above works just fine. Jul 9, 2023 at 23:11

You must log in to answer this question.

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