From fc082f22f8569ded9b8f518fb13c32cbbbbf1e73 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 19 Aug 2021 20:21:03 +0000 Subject: gamebooklib (19aug21) git-svn-id: svn://tug.org/texlive/trunk@60276 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/latex/gamebooklib/README | 41 ++++++++ .../doc/latex/gamebooklib/gamebooklib.pdf | Bin 0 -> 265430 bytes .../gamebooklib/gamebooklib_countpagesperseed.sh | 62 ++++++++++++ .../doc/latex/gamebooklib/gamebooklib_test.pdf | Bin 0 -> 117057 bytes .../doc/latex/gamebooklib/gamebooklib_test.tex | 109 +++++++++++++++++++++ 5 files changed, 212 insertions(+) create mode 100644 Master/texmf-dist/doc/latex/gamebooklib/README create mode 100644 Master/texmf-dist/doc/latex/gamebooklib/gamebooklib.pdf create mode 100755 Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_countpagesperseed.sh create mode 100644 Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.pdf create mode 100644 Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.tex (limited to 'Master/texmf-dist/doc/latex/gamebooklib') diff --git a/Master/texmf-dist/doc/latex/gamebooklib/README b/Master/texmf-dist/doc/latex/gamebooklib/README new file mode 100644 index 00000000000..01ac270ee26 --- /dev/null +++ b/Master/texmf-dist/doc/latex/gamebooklib/README @@ -0,0 +1,41 @@ +Copyright (C) 2021 by Robert J Lee + +This file may be distributed and/or modified under the +conditions of the LaTeX Project Public License, either +version 1.3 of this license or (at your option) any later +version. The latest version of this license is in: + +http://www.latex-project.org/lppl.txt + +and version 1.3 or later is part of all distributions of +LaTeX version 2005/12/01 or later. + + +The gamebooklib package, provides a convenient set of macros to assist +the author choosing to develop a gamebook. In particular, it aims to +solve 2 non-trivial issues: + +1) Writing a set of entries in order, then shuffling them in the +output routine, preserving reference links, and + +2) Allowing LaTeX to output footnotes at the end of an entry, in the +case where another entry falls below the footnote mark on the page. + + +This package uses the standard TeX .dtx+.ins install mechanism, +although a UNIX Makefile is provided for convenience to generate all +files. + +The file "gamebooklib_test.tex" provides a simple demonstration of +this library. + +The file "gamebooklib_countpagesperseed.sh" is a utility script using +bash, perl and pdflatex that will report on the number of pages for +your document, when entries are shuffled with different pseudorandom +seeds. This is useful if you have large objects such as graphics and +want to minimise needless white space. Further instructions are +provided in the header of that file. + +It is suggested that the gamebooklib_countpagesperseed.sh utility +should be placed on the system path for ease of use, or into any +utility scripts directory. \ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib.pdf b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib.pdf new file mode 100644 index 00000000000..991b237de3b Binary files /dev/null and b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib.pdf differ diff --git a/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_countpagesperseed.sh b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_countpagesperseed.sh new file mode 100755 index 00000000000..926e7d152eb --- /dev/null +++ b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_countpagesperseed.sh @@ -0,0 +1,62 @@ +#!/bin/bash +# Copyright (C) 2021 by Robert J Lee +# +# This file may be distributed and/or modified under the +# conditions of the LaTeX Project Public License, either +# version 1.3 of this license or (at your option) any later +# version. The latest version of this license is in: +# +# http://www.latex-project.org/lppl.txt +# +# and version 1.3 or later is part of all distributions of +# LaTeX version 2005/12/01 or later. +# +# A utility script to find the best seed number for a particular gamebook +# +# Prerequisites: bash, tee, tail, egrep, pdflatex, perl with Sort::Naturally +# +# To install Sort::Naturally, you can simply type "cpan install Sort::Naturally" +# assuming Perl is installed. +# +# First keep a backup of your .tex file, just in case. +# +# Next, ensure that you have a line containing "seed=," +# (including the comma) in your .tex file. +# +# The first occurence will be replaced with a sequence of numbers in turn, +# the PDF regenerated, and the number of output pages with each number reported +# on, first by seed number, then by reversed number of pages (smallest last). +# It's then up to you to choose the seed number appropriate for your work. +# +# Use this script with caution as it will edit your source file. +# +# The script may be placed on the system path or copied to the working directory. + +file=${1} + +if [[ -z $file ]]; then + echo "Usage: $0 .tex" + exit 1 +fi + +egrep -q "seed=[0-9]+," $file || ( + echo "$1 Does not contain \\usepackage[seed=123,quiet]{lcg}" + exit 2 +); + +pdf="pdflatex -interaction=nonstopmode $file" + +cp $file $file~ || exit 3 + +# FOR seed in (1..1000) +for seed in $(perl -e 'for (1..1000){print "$_\n"}'); do + # edit $file and replace any seed values + perl -i -pe "s/seed=[0-9]*,/seed=$seed,/" $file + # Run it through LaTeX, stripping out the line of output containing the number of pages, and then + # add the seed value + echo $($pdf 2>&1 | grep 'pages' | tail -n 1 | perl -pe "chomp") "; seed=$seed"; +done | \ + # report on the output as we get it, and report on the sorted pages at the end. + # (sort numerically by first numeral on lines with identical prefix) + perl -MSort::Naturally -pe \ + '{push @lines, $_}; END{print "SORTED:"; print reverse nsort(@lines)}' diff --git a/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.pdf b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.pdf new file mode 100644 index 00000000000..ceac9a9eb7f Binary files /dev/null and b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.pdf differ diff --git a/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.tex b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.tex new file mode 100644 index 00000000000..4d661dce633 --- /dev/null +++ b/Master/texmf-dist/doc/latex/gamebooklib/gamebooklib_test.tex @@ -0,0 +1,109 @@ +%% +%% This is file `gamebooklib_test.tex', +%% +%% Copyright (C) 2021 by Robert J Lee +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.3 of this license or (at your option) any later +%% version. The latest version of this license is in: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% and version 1.3 or later is part of all distributions of +%% LaTeX version 2005/12/01 or later. +%% +\documentclass{report} +\usepackage[seed=123]{lcg} +\usepackage[verbose,footnote]{gamebooklib} +\usepackage{lipsum} +\begin{document} + +\newcommand{\turnto}[1]{\ref{gentry:#1}\par} + +\section*{Example of Use} + +This document was used for testing during development of gamebooklib. +Please see the \texttt{gamebooklib\_test.tex} file alongside the PDF +to see how the package behaves. + + +\begin{gentry}{codea} + This is the first gentry! + + It actually contains two gentryraphs. + +Turn to \turnto{codeb} +\end{gentry} + +\begin{gentry}{codea} + This one is a duplicate! This creates a `'multiple defined'' labels Warning! +\end{gentry} + +\begin{gentry}{codeb} + This is the second gentry. + + Turn to \turnto{codec} + +Turn to \turnto{coded} +\end{gentry} + +\begin{gentry}{codec}[You lose!] + This is the third gentry. + + You can't escape from here. +\end{gentry} + +\begin{gentry}[123]{coded}[You win!] + This is the second and final gentryraph. + + To play again, turn to \turnto{codea} + + (Note that this is the wrong number due to the duplicate label) +\end{gentry} + +\section*{Here is the result:} + +\thegentries +\eject + +For my next trick, here are some longer and multi-page examples. + +Note the location of the footnotes in these entries. + +\begin{gentry}{restart}\noentryfoot + This is the first gentryraph again. + \lipsum[1]\footnote{First footnote, forced to page end} +\end{gentry} + +\begin{gentry}{restart2} + \lipsum[2-7]\footnote{This is just Lorum Ipsum\footnote{Nonsense + pseudo-latin, with roughly English letter distribution, commonly + used to compare fonts\footnotemark.\footnotetext{Here, it's just nonsense.}}} +\end{gentry} + +\newcounter{foo} +\newcounter{bar} +\setcounter{foo}{3} +\setcounter{bar}{3} +\newcommand{\gentrytst}[2]{ + \begin{gentry}{restart#1} + \lipsum[#1]\footnote{This was gentry #1} + \lipsum[#1-#2]\footnote{This was also gentry #1} + \end{gentry} +} +\whiledo{\not{\value{foo}>10}}{ + \stepcounter{foo} + \stepcounter{bar} + \stepcounter{bar} + \edef\idx{\arabic{foo}} + \edef\idxx{\arabic{bar}} + \expandafter\gentrytst\expandafter{\idx}{\idxx} +} + +\section*{Here is the result:} + +\thegentries +\vfill + +\end{document} -- cgit v1.2.3