Jesteś w: Start / Przedsięwzięcia/Projects / TeX Pearls / 2005 Pearls / david-kastrup / bachotex2005-david-kastrup-pearl2.tex

bachotex2005-david-kastrup-pearl2.tex

TeX document icon bachotex2005-david-kastrup-pearl2.tex — TeX document, 1 KB

Zawartość pliku

%%% David Kastrup: Words sorting
% ``Finnegans Wake'' by James Joyce is a book that is not easily
% comprehensible.  \TeX\ can systematize the approach to the text by
% confronting the reader with the longest, and consequently hardest
% words last.

\def\sorttext#1{\setbox0\vbox{{\language255\hsize=0pt\hfuzz\maxdimen
   \parfillskip0pt\noindent#1\par}\sortvlist\unpack}\unvbox0 }
\def\sortvlist{{\unskip\unpenalty \setbox0\lastbox
  \ifvoid0\noindent\else\setbox0\hbox{\unhbox0\ }\sortvlist\sortin\fi}}
\def\sortin{\setbox2\lastbox\ifdim\wd2>\wd0{\sortin}\fi\box2\box0}
\def\unpack{{\setbox0\lastbox\ifvoid0\indent\else\unpack\unhbox0\fi}}

% example

\sorttext{riverrun, past Eve and Adam's, ... linsfirst loved livvy.}