From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/fwlw/README | 12 +++ macros/latex/contrib/fwlw/fwlw.pdf | Bin 0 -> 40435 bytes macros/latex/contrib/fwlw/fwlw.sty | 155 +++++++++++++++++++++++++++++++++++++ macros/latex/contrib/fwlw/fwlw.tex | 87 +++++++++++++++++++++ 4 files changed, 254 insertions(+) create mode 100644 macros/latex/contrib/fwlw/README create mode 100644 macros/latex/contrib/fwlw/fwlw.pdf create mode 100644 macros/latex/contrib/fwlw/fwlw.sty create mode 100644 macros/latex/contrib/fwlw/fwlw.tex (limited to 'macros/latex/contrib/fwlw') diff --git a/macros/latex/contrib/fwlw/README b/macros/latex/contrib/fwlw/README new file mode 100644 index 0000000000..32201ac627 --- /dev/null +++ b/macros/latex/contrib/fwlw/README @@ -0,0 +1,12 @@ +F W L W . S T Y (First Word, Last Word) +Donald Arseneau (1993, 1995) + + The fwlw package provides a mechanism to determine the first and + last words on the current page, plus the first word on the *next* + page. These can be used in head-lines or foot-lines. The `words' + you see may not be real words, but any unbreakable object. + + Copyright (C) 1993,1995 by Donald Arseneau + Vancouver, Canada, email asnd@triumf.ca + This software package may be freely used, transmitted, reproduced, + or modified provided that this notice is left intact. diff --git a/macros/latex/contrib/fwlw/fwlw.pdf b/macros/latex/contrib/fwlw/fwlw.pdf new file mode 100644 index 0000000000..512e6d032b Binary files /dev/null and b/macros/latex/contrib/fwlw/fwlw.pdf differ diff --git a/macros/latex/contrib/fwlw/fwlw.sty b/macros/latex/contrib/fwlw/fwlw.sty new file mode 100644 index 0000000000..10a4ee04a5 --- /dev/null +++ b/macros/latex/contrib/fwlw/fwlw.sty @@ -0,0 +1,155 @@ +% F W L W . S T Y ( First Word, Last Word ) +% +% Donald Arseneau (1993, 1995) +% +% The fwlw package provides a mechanism to determine the first and +% last words on the current page, plus the first word on the *next* +% page. These can be used in head-lines or foot-lines. The `words' +% you see may not be real words, but any unbreakable object. +% +% Two pagestyles are defined to print these words: \pagestyle{NextWordFoot} +% which helps you read ahead to the word on the next page; and \pagestyle +% {fwlwhead} which is like the headers in a lexicon. Or you can use the +% words in your own page-style. The words are made available in the box +% registers: +% \FirstWordBox - first word on this page +% \NextWordBox - first word on next page +% \LastWordBox - last word on this page +% Use them in your header lines like: \usebox\LastWordBox. +% +% Such labelling does not make much sense when \chapter generates a page +% break, so the last page before a \chapter (or any \clearpage) gets +% a blank "next word", and the first page of the chapter gets a blank +% "first word". +% +% Note that `words' may unfortunately be things like: +% - two~words +% - [ ]Word ( [ ] represents a parindent box) +% - a whole displayed equation +% - the first column of an aligned equation +% - anomalously blank, if there are \writes or split footnotes etc. +% - partial words like par- or -tial due to hyphenation. +% +% (Major digression...) +% An entirely different approach is possible using \mark and \obeyspaces, +% and would have different problems. The problems with catcode changes +% may be more or less serious for your particular application. (You are +% invited to write a package using that method!) The best solution would +% involve \mark and an input filter program to +% `\w{tag} \w{each} \w{word}, \w{in} \w{some} \w{way}.' +% TeX has no \everyword hook to insert such tagging. +% +% Copyright (C) 1993,1995 by Donald Arseneau +% Vancouver, Canada, email asnd@triumf.ca +% This software package may be freely used, transmitted, reproduced, +% or modified provided that this notice is left intact. +% +% Declare a "unique" penalty value as flag +\mathchardef\LW@pen 12345 + +% allocate box registers +\newbox\FirstWordBox \global\setbox\FirstWordBox\hbox{} +\newbox\NextWordBox \global\setbox\NextWordBox\hbox{} +\newbox\LastWordBox \global\setbox\LastWordBox\hbox{} +\newbox\LW@box \global\setbox\LW@box\hbox{} +\newbox\LW@saved + +% pagestyle fwlwhead: header line hsa first word and last word +\def\ps@fwlwhead{\let\@mkboth\@gobbletwo + \def\@oddhead{\if@fcolmade\else % no word-heads on float pages. + \usebox\FirstWordBox\hfil\usebox\LastWordBox\fi}% + \let\@evenhead\@oddhead + \let\@oddfoot\@empty\let\@evenfoot\@oddfoot + \let\chaptermark\@gobble\let\sectionmark\@gobble\let\subsectionmark\@gobble + } + +% pagestyle NextWordFoot: foot line has page number and next-page first word, +% but only on odd pages +\def\ps@NextWordFoot{\let\@mkboth\@gobbletwo + \let\@oddhead\@empty\let\@evenhead\@oddhead + \def\@oddfoot{\hfil\thepage\hfil\llap{\usebox\NextWordBox}}% + \let\@evenfoot\@empty + \let\chaptermark\@gobble\let\sectionmark\@gobble\let\subsectionmark\@gobble + } + +% Shell around old output routine. Gets first word from next page by +% letting TeX continue with \vsize=0 to get a look at the next line. +% Values of \outputpenalty for \specialoutput ( -10001 to -19999 ) are +% simply run through the output routine. +% \supereject and \clearpage give a blank "next word". +% When called after making a stub-page the stub is returned to the +% vertical list, the previous page is restored and shipped out normally, +% but knowing what the next word will be. + +\edef\FWLWnorm@L@output{\the\output} + +\output{\@tempswafalse +\ifnum \outputpenalty>-\@MM \ifnum\outputpenalty<-\@M \@tempswatrue\fi\fi +\if@tempswa % special (float) output +% \message{Float handler: penalty=\the\outputpenalty}% + \FWLWnorm@L@output +\else + \ifvoid\LW@saved % end of real page +% \message{End of real page}% + \global\setbox\LW@saved\copy\@cclv % save page + \setbox\@tempboxa\vbox{\unvbox\@cclv \unskip\unkern\unpenalty + \unskip\unkern\unpenalty \unskip\unkern\unpenalty + \setbox\@tempboxa\lastbox + \LW@getlast@word\@tempboxa\LastWordBox + }\ifnum\outputpenalty>-\@MM % not \supereject + \xdef\LW@vsize{\global\vsize\the\vsize + \global\holdinginserts\the\holdinginserts}% + \global\vsize\z@ \global\holdinginserts\@ne + \else % \supereject, just output, don't look for word on next page +% \message{caused by super-eject.} + \global\setbox\@cclv\box\LW@saved + \global\setbox\NextWordBox\hbox{}% + \FWLWnorm@L@output + \global\setbox\FirstWordBox\box\NextWordBox + \fi + \else % saved page => just did tiny page to get next word +% \message{Just got next line:}{\tracingall\showboxdepth2 \showbox\@cclv}% + \setbox\@tempboxa\vbox{\penalty\LW@pen\unvcopy\@cclv \LW@getall@boxes + \ifvbox\LW@box \penalty\LW@pen\unvbox\LW@box \LW@getall@boxes\fi + \ifvbox\LW@box \global\setbox\NextWordBox\hbox{}\else + \LW@getfirst@word\LW@box\NextWordBox + \fi}% Return tiny page to page list: + \unvbox\@cclv \ifnum\outputpenalty<\@M \penalty\outputpenalty\fi + \LW@vsize\relax + \global\setbox\@cclv\box\LW@saved + \FWLWnorm@L@output + \global\setbox\FirstWordBox\box\NextWordBox +\fi\fi} + +% globally get last "word" from a box (#1) into another box (#2) +\def\LW@getlast@word#1#2{\setbox\@tempboxa\vbox{\hsize\maxdimen \@parboxrestore + \hyphenpenalty\@M \exhyphenpenalty\@M + \rightskip\fill \looseness\@M \linepenalty\z@ + \noindent\unhbox#1\endgraf + \unskip\unkern\unpenalty \global\setbox\LW@box\lastbox + }\LW@repack{#2}} + +% globally get first "word" from a box (#1) into another box (#2) +\def\LW@getfirst@word#1#2{\setbox\@tempboxa\vbox{\@parboxrestore + \parshape\thr@@ \z@\z@ \z@\z@ \z@\maxdimen \parfillskip\fill + \hyphenpenalty\@M \exhyphenpenalty\@M + \hbadness\@MM \overfullrule\z@ \hfuzz\maxdimen + \ifhbox#1\noindent + \vadjust{\penalty\LW@pen}\penalty-\@M\unhbox#1% eliminate previous \leftskip + \else\ifvbox#1\penalty\LW@pen\unvbox#1\fi\fi + \endgraf + \@tempcnta\z@ \LW@getall@boxes}\LW@repack{#2}} + +% Go through a vertical list that starts with special penalty +\def\LW@getall@boxes{\global\setbox\LW@box\lastbox \unskip\unkern \unskip\unkern + \let\@tempa\relax + \ifvoid \LW@box \advance\@tempcnta\@ne \else \@tempcnta\z@ \fi + \ifnum\lastpenalty=\LW@pen \else \unpenalty\fi + \ifnum\lastpenalty=\LW@pen \else \unpenalty\fi + \ifnum\lastpenalty=\LW@pen \else \ifnum\@tempcnta<5 + \let\@tempa\LW@getall@boxes \fi \fi \unpenalty \@tempa} + +% Put contents of \LW@box into hbox #1 +\def\LW@repack#1{\global\setbox#1\hbox{\ifhbox\LW@box + \unhbox\LW@box\unskip\unskip\unpenalty\unskip + \else\ifvbox\LW@box\box\LW@box\fi\fi}} diff --git a/macros/latex/contrib/fwlw/fwlw.tex b/macros/latex/contrib/fwlw/fwlw.tex new file mode 100644 index 0000000000..674562d086 --- /dev/null +++ b/macros/latex/contrib/fwlw/fwlw.tex @@ -0,0 +1,87 @@ +\documentclass[pagesize=auto]{scrartcl} + +\usepackage{fixltx2e} +\setlength\parskip{3pt} + +\newcommand*{\mail}[1]{\href{mailto:#1}{\texttt{#1}}} +\newcommand*{\pkg}[1]{\textsf{#1}} +\newcommand*{\cls}[1]{\textsf{#1}} +\newcommand*{\cs}[1]{\texttt{\textbackslash#1}} +\makeatletter +\newcommand*{\cmd}[1]{\cs{\expandafter\@gobble\string#1}} +\makeatother +\newcommand*{\env}[1]{\texttt{#1}} +\newcommand*{\opt}[1]{\texttt{#1}} +\newcommand*{\meta}[1]{\textlangle\textsl{#1}\textrangle} +\newcommand*{\marg}[1]{\texttt{\{}\meta{#1}\texttt{\}}} +\newcommand*{\oarg}[1]{\texttt{[}\meta{#1}\texttt{]}} +\newcommand*{\widevisiblespace}{% + \vrule height 2pt depth 0pt width 0.2pt + \kern -.1pt + \vrule height 0.2pt depth 0pt width 15pt + \kern -.1pt + \vrule height 2pt depth 0pt width 0.2pt} + +\addtokomafont{title}{\rmfamily} + +\title{The \pkg{fwlw} package} +\subtitle{First Word, Last Word} +\author{Donald Arseneau} +\date{1995} + + +\begin{document} + +\maketitle + +\noindent +The fwlw package provides a mechanism to determine the first and +last words on the current page, plus the first word on the \emph{next} +page. (So perhaps it should have been named `fwlwnw'). These words +can be used in head-lines or foot-lines. The `words' you see may +not be real words, but any unbreakable object. + +Two pagestyles are defined to print these words: +\verb+\pagestyle{NextWordFoot}+ which helps you read ahead to the +word on the next page; and \verb+\pagestyle{fwlwhead}+ which is like +the headers in a lexicon. Or you can use the +words in your own page-style. The words are made available in the box +registers: +% +\begin{labeling}[\hspace{\labelsep}--]{\quad\cmd{\FirstWordBox}} +\setlength\itemsep{0pt} +\item[\quad\cmd{\FirstWordBox}] first word on this page +\item[\quad\cmd{\NextWordBox}] first word on next page +\item[\quad\cmd{\LastWordBox}] last word on this page +\end{labeling} +% +Use them in your header lines like: \verb+\usebox\LastWordBox+. + +Such labelling does not make sense when \cmd{\chapter} generates a page +break, so the last page before a \cmd{\chapter} (or any \cmd{\clearpage}) gets +a blank ``next word'', and the first page of the chapter gets a blank +``first word''. The fwlwhead page style produces blank headers on +float pages. + +Note that `words' are any unsplittable unit and may be things like: +% +\begin{itemize} +\setlength\itemsep{0pt} +\item two\textvisiblespace words (\texttt{two}% + \lower 2pt\hbox{\verb+~+}\texttt{words}) + with unbreakable space between them +\item \widevisiblespace Word (where \widevisiblespace\ represents a + paragraph indent) +\item a whole displayed equation +\item the first column of an aligned equation +\item a list item label +\item anomalously blank, if there are \cmd{\write}s or split footnotes etc. +\item blank for the first word of the document (because of a \cmd{\write}) +\item partial words like `par-' or `-tial' due to hyphenation. +\end{itemize} +% +In short, a wide range of irregularities will cause non-words to +be captured, or nothing at all. + + +\end{document} -- cgit v1.2.3