3

I have a series of pages with a couple of paragraphs each. Rather than leave the rest of the page blank, I have a whole bunch of “trivia” factoids. I'd like to put as many of those on the page as there is room for.

Imagine having a book with one page per day of the year. The main content would be a couple of paragraphs describing the day, but the page could be filled with “interesting things that happened this day in history”.

I can import way more than I'd ever need, so no packing or resizing or trying to get them all on. But definitely no extra pages with the rest of the “trivia” on them. And I definitely don't want to spend the time hand-typesetting every page by choosing exactly the right number of trivia entries, adjusting them after each edit, etc.

My only other slight requirement is that the whole factoid is there: I can't end the page with a half a fact. But I am assuming the samepage environment will do this.

I have no idea how to throw away data though.

7
  • For my understanding: "throw away" means "don't show it" or "remove from memory or source code" ?
    – MS-SPO
    Oct 15, 2022 at 10:52
  • Either. “Remove it from memory” sounds a bit technical to me. “Just don't show it” is fine!
    – Ian
    Oct 15, 2022 at 11:14
  • possible duplicate tex.stackexchange.com/questions/106354/vertical-dotfill
    – touhami
    Oct 15, 2022 at 11:26
  • Perhaps for some people finding this question, but definitely not a duplicate for me.
    – Ian
    Oct 15, 2022 at 11:32
  • 1
    So, if I understand correctly, you want to add material up to filling a page, but not more, sourcing from somewhere a series of small texts. Is this correct? Maybe you should explain it better, and could provide a document with a couple of pages and an external source of short snippets so that people can start from something different from zero.
    – Rmano
    Oct 15, 2022 at 15:49

2 Answers 2

1

There was an article in TUGboat which discussed this and provided some code https://tug.org/TUGboat/tb32-3/tb102glister.pdf (section 2. Cut off in its prime). There is far more in the article than can be put here, so please read it.

2
  • Thank you! None of them were quite perfect, (because I am limiting to a page size rather than a specific height) but the variation was more helpful for me to understand. \setbox\partialbox\vsplit\descbox in particular is the incantation. I don't know if there's a stock exchange etiquette, so If I get a working result, is it more appropriate to post and ✅ that in case someone else asks the same question, or give you the ✅ for solving 90% of my problem?
    – Ian
    Oct 16, 2022 at 9:25
  • 1
    @Ian If you come up with an answer, post it with any due acknowledgements. Oct 16, 2022 at 17:08
1

The idea is to create a separate file containing factoids, then read them (in order) until the page is full.

This creates a file of factoids. I put the fixed padding here so that you can change it per factoid then measure the needed space.

\documentclass[multi={minipage}]{standalone}
\textwidth=345.0pt% obtained using \the\textwidth
\begin{document} 

\begin{minipage}{\textwidth}
\null\bigskip
My dog has no nose.\\
\textit{How does he smell?}\\
Awful!
\end{minipage}

\begin{minipage}{\textwidth}
\null\bigskip
\textbf{abend} (from the German \textit{Guten Abend}) 
A system abort induced deliberately (usually on Fridays) to allow
third shift staffers to leave early.
\end{minipage}

\begin{minipage}{\textwidth}
\null\bigskip
\textbf{ACRONYM} Alphabetic Collocation Reducing Or Numbing Your Memory.
Often confused with its antonym \textit{mnemonic}.
\end{minipage}

\begin{minipage}{\textwidth}
\null\bigskip
\textbf{CAD} Computer Aided Delay.
\end{minipage}

\begin{minipage}{\textwidth}
\null\bigskip
\textbf{ISAM} Intrinsically Slow Access method.
\end{minipage}

\end{document}

This adds the factoids using \fillpage. Interestingly, I crash if I attempt to read the last page.

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}% MWE only

\newcounter{factoid}
\newif\ifmorefactoids
\newcommand{\maxfactoid}{4}% should be 5

\newcommand{\fillpage}{\bgroup% use local registers
  \morefactoidstrue
  \loop
  \stepcounter{factoid}%
  \ifnum\value{factoid}>\maxfactoid\relax
    \setcounter{factoid}{1}%
  \fi
  \sbox0{\includegraphics[page=\thefactoid]{test4}}% file contining factoids
  \par
  \setlength{\dimen0}{\dimexpr \ht0+\dp0}%
  \setlength{\dimen1}{\dimexpr \pagegoal-\pagetotal}%
  \ifdim \dimen1>\dimen0
    \box0
  \else
    \morefactoidsfalse
    \newpage
    \addtocounter{factoid}{-1}%
  \fi
  \ifmorefactoids\repeat
\egroup}
  
\begin{document}

\lipsum[1-4]
\fillpage

\lipsum[4-5]
\fillpage

\end{document}

You must log in to answer this question.

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