diff options
Diffstat (limited to 'macros/generic/misc')
49 files changed, 6339 insertions, 0 deletions
diff --git a/macros/generic/misc/CropMarks_pt.tex b/macros/generic/misc/CropMarks_pt.tex new file mode 100644 index 0000000000..a30808f341 --- /dev/null +++ b/macros/generic/misc/CropMarks_pt.tex @@ -0,0 +1,391 @@ +% Self-documenting file
+
+\ifx \Comment \Undefined
+ \long \def \Comment #1\EndComment {}
+\else
+ \ifx \EndComment \Undefined
+ \def \EndComment
+ {\message {Error: \noexpand \EndComment encountered
+ without preceding \noexpand \Comment}}
+ \else %%% both defined; let's hope they're the right definitions!
+ \fi
+\fi
+
+%%% Author: Philip Taylor (RHBNC) <P.Taylor@Rhul.Ac.Uk>
+%%% Cropmarks.TeX V1.4 Copyright (C) Philip Taylor, MCMLXXXXII
+
+\Comment % The Licence
+
+ Unlimited copying and redistribution of this file
+ is permitted so long as the file is not modified
+ in any way.
+
+ Modifications may be made for private purposes (though
+ this is discouraged, as it could result in documents
+ typesetting differently on different systems) but if
+ such modifications are re-distributed, the modified
+ file must not be capable of being confused with the
+ original. In particular, this means
+
+(a) the filename (the portion before the extension, if any)
+ must not match either of the sequences :
+
+ CROPMARKS
+ CROP-MARKS
+
+ regardless of case, and
+
+(b) the file must contain conditions identical to these,
+ except that the modifier/distributor may, if he or she
+ wishes, augment the list of proscribed filenames.
+
+\EndComment
+
+%%% Usage:
+
+%%% \input cropmarks
+%%% \topcropmark = <dimen> [plus <dimen>] [minus <dimen>]
+%%% \bottomcropmark = <dimen> [plus <dimen>] [minus <dimen>]
+%%% \leftcropmark = <dimen> [plus <dimen>] [minus <dimen>]
+%%% \rightcropmark = <dimen> [plus <dimen>] [minus <dimen>]
+%%% \lrcropmarkstrue ;;; iff you want alternating left and right cropmarks only
+%%% \rvcropmarkstrue ;;; iff you want recto and verso specified independently
+%%% (in which case the first four variables are two-valued
+%%% as \recto<var> and \verso<var>).
+
+%%% Square brackets indicate optional items, and the <dimen>s are
+%%% respectively (and all measured w.r.t. the origin, which is the
+%%% top left corner of the notional, rather than physical page; the
+%%% exact origin will need to be determined by inspection)
+
+%%% The distance to the centre of the cross;
+%%% The distance which the cross extends beyond the page limits;
+%%% The distance which the cross extends within the page limits.
+
+%%% Any or all can be zero <unit>s. For conventional (exo-) cropmarks, the
+%%% `plus' component indicates the length of the mark, and the `minus' component
+%%% should be omitted or zero. For inverted (endo-) cropmarks, the `plus'
+%%% component should be omitted or zero, and the `minus' component indicates the
+%%% length of the mark. If `plus' or `minus' components are negative, this
+%%% has the effect of a `white cropmark' extending in the reverse direction
+%%% for the specified distance; this may be used to achieve non-touching marks.
+%%% The first and only mandatory component may be also negative, to cope with
+%%% pathological origins.
+
+%
+%%% A test which will allow us to be read regardless of the \catcode of `@'
+%
+
+\newif \ifatletter
+\ifcat @A\atlettertrue \else \catcode `\@ = 11 \atletterfalse \fi
+
+\ifx \c@tcodeminus \undefined \else \message {Warning: previous
+meaning of \string \c@tcodeminus \space lost} \fi \edef
+\c@tcodeminus {\the \catcode `\-} \catcode `\- = 12
+
+%
+\message {CROPMARKS.TEX V1.4 Copyright (C) 05-Mar-1992 13:43:28
+Philip Taylor}
+%
+
+%
+%%% Miscellaneous variables
+%
+\newif \iflrcropmarks \lrcropmarksfalse
+\newif \ifrvcropmarks \rvcropmarksfalse
+\newdimen \cropmarkwidth \cropmarkwidth = 0.4 pt
+\newdimen \t@pshift
+\newdimen \b@ttomshift
+\newdimen \l@ftshift
+\newskip \topcropmark
+\newskip \leftcropmark
+\newskip \rightcropmark
+\newskip \bottomcropmark
+\newskip \rectotopcropmark
+\newskip \rectoleftcropmark
+\newskip \rectorightcropmark
+\newskip \rectobottomcropmark
+\newskip \versotopcropmark
+\newskip \versoleftcropmark
+\newskip \versorightcropmark
+\newskip \versobottomcropmark
+\newskip \m@rkskip
+\newskip \m@rkplus
+\newskip \m@rkminus
+\newbox \p@gebox
+\newbox \cr@pmarkbox
+\newbox \topcr@pmarkbox
+\newbox \bottomcr@pmarkbox
+%
+%%% Extraordinary arcanery, to parse <skip>s into <dimen>s; any better ways ?
+%
+\begingroup
+\catcode `\P = 12 \catcode `\L = 12 \catcode `\U = 12 \catcode `\S =
+12 \catcode `\M = 12 \catcode `\I = 12 \catcode `\N = 12 \catcode
+`\T = 12 \globaldefs = 1 \lowercase
+{%
+\def \p@rseskip #1%
+ {\expandafter \p@rs@skip \the #1 PLUS 0.0PT MINUS 0.0PT \@ndparse #1 }
+\def \p@rs@skip #1 PLUS #2 MINUS #3\@ndparse #4
+ {%
+ \m@rkskip = #1%
+ \m@rkplus = #2%
+ \m@rkminus = #3%
+ \ifdim \m@rkminus = 0.0 pt
+ \expandafter \p@rs@sk@p \the \m@rkskip MINUS 0.0PT \@ndparse
+ \fi
+ }%
+\def \p@rs@sk@p #1MINUS #2\@ndparse {\m@rkskip = #1 \m@rkminus = #2 }
+}
+\endgroup
+%
+%%% Take control of \shipout, to force it to add cropmarks
+%
+\let \ship@ut = \shipout
+\def \shipout {\futurelet \b@x \whichb@x}
+\def \whichb@x
+ {%
+ \ifx \b@x \vbox
+ \def \n@xt {\setbox \p@gebox = }%
+ \afterassignment \Shipout
+ \else \ifx \b@x \hbox
+ \def \n@xt {\setbox \p@gebox = }%
+ \afterassignment \Shipout
+ \else \ifx \b@x \box
+ \def \n@xt {\setbox \p@gebox = }%
+ \afterassignment \Ship@ut
+ \else \ifx \b@x \copy
+ \def \n@xt {\setbox \p@gebox = }%
+ \afterassignment \Ship@ut
+ \else
+ \def \n@xt {\ship@ut}%
+ \message {Sorry, can't understand
+ what follows \shipout}%
+ \fi
+ \fi
+ \fi
+ \fi
+ \n@xt
+ }
+\def \Shipout {\aftergroup \Ship@ut}
+\def \Ship@ut
+ {%
+ \ifrvcropmarks
+ \ifodd \pageno
+ \topcropmark = \rectotopcropmark
+ \bottomcropmark = \rectobottomcropmark
+ \leftcropmark = \rectoleftcropmark
+ \rightcropmark = \rectorightcropmark
+ \else
+ \topcropmark = \versotopcropmark
+ \bottomcropmark = \versobottomcropmark
+ \leftcropmark = \versoleftcropmark
+ \rightcropmark = \versorightcropmark
+ \fi
+ \fi
+ \setbox \topcr@pmarkbox =
+ \hbox \bgroup
+ \p@rseskip \leftcropmark
+ \iflrcropmarks
+ \ifodd \count 0
+ \let \next = \phantom
+ \else
+ \let \next = \relax
+ \fi
+ \else
+ \let \next = \relax
+ \fi
+ \next {\ifdim \m@rkminus < 0 pt
+ \begingroup
+ \advance \m@rkplus by \m@rkminus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \kern -\m@rkminus
+ \endgroup
+ \else
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \fi
+ \begingroup
+ \p@rseskip \topcropmark
+ \vrule height \m@rkplus
+ depth \m@rkminus
+ width \cropmarkwidth
+ \endgroup
+ \ifdim \m@rkplus < 0 pt
+ \begingroup
+ \advance \m@rkminus by \m@rkplus
+ \rlap {\kern -\m@rkplus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus}%
+ \endgroup
+ \else
+ \rlap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus}%
+ \fi
+ }%
+ \hskip \m@rkskip
+ \p@rseskip \rightcropmark
+ \hskip \m@rkskip
+ \iflrcropmarks
+ \ifodd \count 0
+ \let \next = \relax
+ \else
+ \let \next = \phantom
+ \fi
+ \else
+ \let \next = \relax
+ \fi
+ \next {\ifdim \m@rkplus < 0 pt
+ \begingroup
+ \advance \m@rkminus by \m@rkplus
+ \llap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus
+ \kern -\m@rkplus
+ }%
+ \endgroup
+ \else
+ \llap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus
+ }%
+ \fi
+ \begingroup
+ \p@rseskip \topcropmark
+ \vrule height \m@rkplus
+ depth \m@rkminus
+ width \cropmarkwidth
+ \endgroup
+ \ifdim \m@rkminus < 0 pt
+ \begingroup
+ \advance \m@rkplus by \m@rkminus
+ \kern -\m@rkminus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \endgroup
+ \else
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \fi
+ }%%%%%%%% end of parameter to \next
+ \egroup%%%%%%%% end of \bgroup ... \egroup to \setbox ...
+ \ht \topcr@pmarkbox = 0 pt
+ \dp \topcr@pmarkbox = 0 pt
+ \wd \topcr@pmarkbox = \wd \p@gebox
+ \setbox \bottomcr@pmarkbox =
+ \hbox \bgroup
+ \p@rseskip \leftcropmark
+ \iflrcropmarks
+ \ifodd \count 0
+ \let \next = \phantom
+ \else
+ \let \next = \relax
+ \fi
+ \else
+ \let \next = \relax
+ \fi
+ \next {\ifdim \m@rkminus < 0 pt
+ \begingroup
+ \advance \m@rkplus by \m@rkminus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \kern -\m@rkminus
+ \endgroup
+ \else
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \fi
+ \begingroup
+ \p@rseskip \bottomcropmark
+ \vrule height \m@rkminus
+ depth \m@rkplus
+ width \cropmarkwidth
+ \endgroup
+ \ifdim \m@rkplus < 0 pt
+ \begingroup
+ \advance \m@rkminus by \m@rkplus
+ \rlap {\kern -\m@rkplus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus}%
+ \endgroup
+ \else
+ \rlap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus}%
+ \fi
+ }%
+ \hskip \m@rkskip
+ \p@rseskip \rightcropmark
+ \hskip \m@rkskip
+ \iflrcropmarks
+ \ifodd \count 0
+ \let \next = \relax
+ \else
+ \let \next = \phantom
+ \fi
+ \else
+ \let \next = \relax
+ \fi
+ \next {\ifdim \m@rkplus < 0 pt
+ \begingroup
+ \advance \m@rkminus by \m@rkplus
+ \llap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus
+ \kern -\m@rkplus
+ }%
+ \endgroup
+ \else
+ \llap {\vrule height \cropmarkwidth
+ depth 0 pt width \m@rkminus
+ }%
+ \fi
+ \begingroup
+ \p@rseskip \bottomcropmark
+ \vrule height \m@rkminus
+ depth \m@rkplus
+ width \cropmarkwidth
+ \endgroup
+ \ifdim \m@rkminus < 0 pt
+ \begingroup
+ \advance \m@rkplus by \m@rkminus
+ \kern -\m@rkminus
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \endgroup
+ \else
+ \vrule height \cropmarkwidth
+ depth 0 pt width \m@rkplus
+ \fi
+ }%%%%%%%% end of parameter to \next
+ \egroup%%%%%%%% end of \bgroup ... \egroup to \setbox ...
+ \ht \bottomcr@pmarkbox = 0 pt
+ \dp \bottomcr@pmarkbox = 0 pt
+ \wd \bottomcr@pmarkbox = \wd \p@gebox
+ \setbox \cr@pmarkbox = \vbox
+ \bgroup
+ \offinterlineskip
+ \p@rseskip \leftcropmark \l@ftshift = \m@rkskip
+ \p@rseskip \topcropmark \t@pshift = \m@rkskip
+ \p@rseskip \bottomcropmark \b@ttomshift = \m@rkskip
+ \advance \l@ftshift by \m@rkplus
+ \advance \l@ftshift by \cropmarkwidth
+ \vskip -\t@pshift
+ \moveleft \l@ftshift \box \topcr@pmarkbox
+ \vskip +\t@pshift
+ \vskip +\b@ttomshift
+ \moveleft \l@ftshift \box \bottomcr@pmarkbox
+ \vskip -\b@ttomshift
+ \egroup
+ \setbox \p@gebox = \vbox
+ {\offinterlineskip
+ \box \cr@pmarkbox
+ \box \p@gebox}%
+ \ship@ut \box \p@gebox
+ }
+%
+%%% Restore \catcode of `-' & `@'
+%
+
+\catcode `\- = \c@tcodeminus
+\let \c@tcodeminus = \undefined
+\ifatletter \else \catcode `\@ = 12 \fi
+
+%%% All done
diff --git a/macros/generic/misc/anti.tex b/macros/generic/misc/anti.tex new file mode 100644 index 0000000000..52bf003549 --- /dev/null +++ b/macros/generic/misc/anti.tex @@ -0,0 +1,19 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%% CUT HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \anti -- Definition. +% Produce a superscripted antiparticle: #1 with an overbar and a super- +% script #2. Looks better than \overline{{#1}^{#2}} (bar does not extend over +% superscript) or {\overline {#1}}^{#2} (superscript does not stick up above +% bar; in fact, superscript is at same height as for the charge conjugate, +% {#1}^{#2}). If you want subscripts too, you'll have to modify +% this definition to take a third argument. Math mode is assumed. +% Macro by Rich Holmes (rich@suhep.bitnet), 1/88 +% +\def\anti#1#2{\vbox{\ialign{##\crcr + \hrulefill$\smash{\phantom{\scriptstyle#2}}$\crcr % the right length bar + \noalign{\kern-1pt\nointerlineskip\vskip 0.25ex} % the right spacing + $\hfil{#1}^{#2}\hfil$\crcr}}} % the right text +%%%%%%%%%%%%%%%%%%%%%%%% CUT HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\Kzerobar{\anti{K}{0}} +\def\Dstarbar{\anti{D}{*}} % et cetera +%%%%%%%%%%%%%%%%%%%%%%%% CUT HERE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/macros/generic/misc/apldef.tex b/macros/generic/misc/apldef.tex new file mode 120000 index 0000000000..12ec83dd2f --- /dev/null +++ b/macros/generic/misc/apldef.tex @@ -0,0 +1 @@ +../../../fonts/apl/apldef.tex
\ No newline at end of file diff --git a/macros/generic/misc/arabic.tex b/macros/generic/misc/arabic.tex new file mode 100644 index 0000000000..acba65e59f --- /dev/null +++ b/macros/generic/misc/arabic.tex @@ -0,0 +1,55 @@ +%-------------------------------------------- +% Ole Michael Selberg, October 5, 1995 +% TeX macros to make a Roman number Arabic +% +% Syntax: \arabicnumeral <Roman number > +%-------------------------------------------- +\catcode`@=11 +\newcount\r@mancount \newcount\current \newcount\previous +\def\@valueofcurrent{% + \ifx\next i\global\current=1 \else + \ifx\next v\global\current=5 \else + \ifx\next x\global\current=10 \else + \ifx\next l\global\current=50 \else + \ifx\next c\global\current=100 \else + \ifx\next d\global\current=500 \else + \ifx\next m\global\current=1000 \else + \global\r@mancount=-100000 + \immediate\write16{Line \the\inputlineno: non-Roman digit!} + \fi\fi\fi\fi\fi\fi\fi} +\def\stop{\stop} +\def\arabicnumeral #1 {\r@mancount=0 \current=0 \previous=10000 + \fr@mroman#1\stop} +\def\fr@mroman {\afterassignment\@testchar\let\next} +\def\@testchar{% + \ifx\next\stop + \ifnum\r@mancount<0 (Wrong Roman numeral: ???) + \else + \the\r@mancount + \fi + \let\next\relax + \else \@valueofcurrent + \advance\r@mancount by\current + \ifnum\previous<\current + \multiply\previous by2 + \advance\r@mancount by -\previous + \fi + \let\next\fr@mroman + \fi + \previous=\current + \next} +\catcode`@=12 +\endinput + + +--------------------------------------------------------------------------- +Ole Michael Selberg, +Institutt for oesteuropeiske og orientalske studier +Universitetet i Oslo +Pb. 1030 Blindern +N-0315 Oslo + +Phone: (47) 22 85 67 94 +Fax: (47) 22 85 41 40 + + diff --git a/macros/generic/misc/backgrnd.tex b/macros/generic/misc/backgrnd.tex new file mode 100644 index 0000000000..165ee69094 --- /dev/null +++ b/macros/generic/misc/backgrnd.tex @@ -0,0 +1,319 @@ +%%% backgrnd.sty = background.sty +%%% Experimental version 24 march 1996 +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% +%%% This macro file aims at implementing marking of text, +%%% either by a grey background or by a changeebar +%%% using TeX's own resources only, +%%% (i.e., without resorting to any pstricks). +%%% Grey background uses a shade font defined using MetaFont +%%% The macros seem to work satisfactory under plain TeX, +%%% however, I have also tried (rudimentarily) to integrate them with +%%% LaTeX, too. It seems to work with (simple) LaTeX 2.09, at least. +%%% +%%% commands : +%%% \RuleOn and \RuleOff : changebar +%%% \RuleON : backs up to mark current line, too +%%% \RuleStyle { ( dimension ) % width of rule +%%% % rule offset on pages +%%% [ # dimension | % with even pagenumbers +%%% # dimension ] } % with odd pagenumbers +%%% % # is either < : left margin +%%% % or > : right margin +%%% e.g.: default values are set by +%%% \RuleStyle { (2pt)[<18pt|>18pt] } +%%% +%%% +%%% \ShadeON ( backs up to mark current line, too ) and +%%% \ShadeOn and \ShadeOff : grey background, requires shade.sty +%%% therefore, by default, + \let\ifUseGrey\iffalse % grey background will not be installed +%%% - and will be replaced by rules +%%% if grey background is required then +%%% remove comment signs %%% from next line : +%%% \let\ifUseGrey\iftrue +%%% +%%% (At present) it is not possible to use both commands +%%% in the same document ! +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% Peter Schmitt %%% +%%% Institut f\"ur Mathematik, Universit\"at Wien %%% +%%% Strudlhofgasse 4, A-1090 Wien, Austria %%% +%%% email: schmitt@awirap.bitnet %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\catcode`\: 11 % make internal macros private +\countdef\int: 255 % scratch registers +\dimendef\dim: 0 +\skipdef\skip: 0 + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% commands and options %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def \RuleOn {\bg:ini \bg:rule + \RuleStyle { (2pt)[<18pt|>18pt] } + \bg:commands \RuleOn \RuleON \RuleOff + \RuleOn + } +\def \RuleStyle #1{\set:hsize #1(\bg:hsize)\\% + \set:offsets #1[*|*]\iftrue]\iffalse\\% + } + +\def \bg:rule {\leaders\vrule width\bg:hsize\vskip} +\def \bg:empty {\vskip} +\let \bg:offset \relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% interface tools %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\bg:commands #1#2#3{\def #1{\bg:option {\vbox{}\pos:on}} + \def #2{\bg:option {\nobreak\vskip-\baselineskip + \vbox{}\pos:on + \nobreak\vskip\baselineskip } + } + \def #3{\bg:option {\vbox{}\pos:off}} + } +\def \bg:ini {\output{\bg:output} % should be followed by desired \bg:style + \zero:pos + \global\let \bg:skip \bg:empty + \let \bg:style + } +\def\bg:option #1{\ifvmode #1\else \vadjust{#1}\fi } + +\def \set:hsize #1(#2)#3\\{\edef\bg:hsize{#2}} +\def \set:offsets #1[#2#3|#4#5]#6]#7#8\\{#7 + \def\bg:shift{} + \set:offset #2#3 + \set:offset #4#5 + \expandafter \set:shifts \bg:shift + \fi } +\def\set:offset #1#2 {\setbox0\hbox{\dim: #2\bg:offset\xdef\bg:offset{\the\dim:}} + \dim:\bg:offset + \expandafter\expandafter\expandafter + \set:shift \csname bg:#1\endcsname + } +\def\set:shift #1#2{\dim: \bg:offset \advance\dim: #2% + \edef\bg:shift {\bg:shift {#1\the\dim:}} + } +\expandafter\def \csname bg:<\endcsname {\moveleft \bg:hsize} +\expandafter\def \csname bg:>\endcsname {\moveright \hsize} +\def \set:shifts #1#2{\def\bg:shift{\ifodd\pageno #2\else #1\fi}} + +%%% not used : +\def\bg:err #1{\errmessage {% + Warning ! Background mode \noexpand#1 already active ! } + } +%%% saving position without eject yields not always correct result +%%% \def\bg:on {\switch:to \bg:style } \def\bg:off {\switch:to \bg:empty } + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% grey background %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ifUseGrey + +\def\ShadeOn {\bg:ini \bg:grey + \let\bg:shift\relax + \let\bg:hsize\hsize + \setbox\grey:line + \vbox{\shade{\line:{\vphantom{\grey:\char0}\hfil}}} + \bg:commands \ShadeOn \ShadeON \ShadeOff + \ShadeOn + } +\csname newbox\endcsname\grey:line % allow \newbox in conditional text +\def\bg:grey {\leaders\copy\grey:line\vskip} +\let\line:\line +\input shade + +\else + \def\ShadeOn{\RuleOn} \def\ShadeOff{\RuleOff} \def\ShadeON{\RuleON} + \fi +%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% output routine %%% +%%%%%%%%%%%%%%%%%%%%%%%%%% + + \newbox \bg:page + \newdimen \v:size + \newskip \v:pos + \newcount \true:penalty + \chardef \the:page 255 + +\def\option: #1{\advance\int: -1 + \edef#1{\penalty\the\int: } + \expandafter\def\csname\the\int:\endcsname + } \int: -12345 +\def\bg:output{\expandafter\ifx\csname\the\outputpenalty\endcsname\relax + \global\true:penalty\outputpenalty + \expandafter\bg:pagecontents + \else \expandafter\expandafter + \csname\the\outputpenalty\endcsname + \fi } +\option: \pos:on {\bg:switch \bg:style } +\option: \pos:off {\bg:switch \bg:empty } +\option: \bg:top {\save:pos \add:bg\bg:empty\v:skip{} + \repeat:page \unvbox\the:page } +\option: \bg:bot {\save:pos \repeat:page \unvbox\the:page } +\option: \fg:end {\save:pos \add:bg\bg:empty{}\v:skip \bg:makepage } + +\def \bg:switch #1{\setbox\the:page + \vbox{\unvbox\the:page \setbox0\lastbox } + \ifdim \pagetotal=\topskip + \global\let \bg:skip #1 + \unvbox\the:page + \else \switch:to #1 + \repeat:page\repeat:inserts \unvbox\the:page + \fi + } +\def\switch:to #1{\save:pos + \add:bg \bg:skip{}\v:skip + \global\let \bg:skip #1} +\def\bg:pagecontents {\switch:to \bg:skip + \setbox\the:page \vbox + {\vbox{}\bg:top \unvbox\the:page \bg:bot } + \zero:pos \repeat:page + \pagecontents \fg:end + } +\def\bg:makepage {\global\v:size\vsize \advance\v:size \dp\the:page + \def\pagecontents{% + \bg:shift + \vbox to0pt{\vbox to\v:size{\unvbox\bg:page}\vss} + \unvbox\the:page } + \outputpenalty\true:penalty + \plainoutput + \zero:pos \reset:inserts + } + +%%%%%%%%%%%%%%%%% +%%% tools %%% +%%%%%%%%%%%%%%%%% + +\def\repeat:page {\vbox{}\nobreak\kern-\topskip } +\def\add:bg #1#2#3{\let\bg:vskip #1 + \global\setbox\bg:page \vbox{#2\unvbox\bg:page#3} + } + +\newdimen \v:fil +\newdimen \v:fill +\newdimen \v:filll +\def\zero:pos {\global \v:pos 0pt + \global \v:fil 0pt + \global \v:fill 0pt + \global \v:filll 0pt + } +\def\save:pos {\skip: -\v:pos % save -last:pos + \global \v:pos \pagetotal + \global\advance \v:pos \pagedepth + \ifnum \pagedepth=0 \advance\v:pos \dp\the:page \fi + \global\advance \v:pos 0ptplus\pagestretch minus\pageshrink + \save:skip + } +\def\save:pos {\skip: -\v:pos % save -last:pos + \global \v:pos \pagetotal + \global\advance \v:pos \pagedepth + \ifnum \pagedepth=0 \advance\v:pos \dp\the:page \fi + \global\advance \v:pos 0ptplus\pagestretch minus\pageshrink + \save:skip + \global\skip\ins:size \vsize + \global\advance\skip\ins:size -\pagegoal + \global\advance\skip\ins:size -\ins:skip + } +\def\save:skip {\advance\skip:\v:pos % v:pos - last:pos + \let\bg:vskip\relax + \edef\v:skip{\bg:vskip\the\skip:} + \fil:skip l \fil:skip ll \fil:skip lll + } +\def\fil:skip #1 {\set:fil {\csname v:fi#1\endcsname} + {\csname pagefi#1stretch\endcsname} + \edef\v:skip{\v:skip \bg:vskip0ptplus\the:pt \dim: fi#1 } + } +\def\set:fil #1#2{\dim: -#1 + \advance \dim: #2 + \global #1 #2 + } +\def\the:pt {\expandafter\PT:\the} + { \catcode`p 12 \catcode`t 12 +\gdef\PT: #1pt{#1} }% \catcode`p 11 \catcode`t 11 + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% insert handling %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcount\ins: +\newinsert\ins:size +\newdimen\ins:skip + +\let\do:insert \insert +\def\inserts:{} +\def\insert {\afterassignment\adjust:pos\ins:} +\def\adjust:pos {\csname ins:\the\ins:\endcsname\csname iftrue\endcsname + \add:plus \ins: \add:minus \ins: + \advance\ins:skip\skip\ins: + \let\temp:\relax + \edef\inserts:{\inserts: \temp:{\the\ins:}} + \fi + \global\expandafter\let\csname ins:\the\ins:\endcsname \iffalse + \do:insert\ins: } +\def\repeat:inserts{\def\temp:##1{\do:insert##1{}}\inserts: } +\def\reset:inserts{% + \def\temp: ##1{\global\expandafter\let\csname ins:##1\endcsname \relax } + \inserts: \gdef\inserts:{}\global\ins:skip 0pt } + +%%% tools for insert handling %%% + + \catcode `L12 \catcode `N12 \catcode `S12 \catcode `U12 \lowercase{ +\def\plus: #1LUS #2 #3\\{#2} +\def\Plus: #1{\expandafter\plus:\the#1 LUS 0.0pt \\} +\def\minus: #1NUS #2 #3\\{#2} +\def\Minus: #1{\expandafter\minus:\the#1 NUS 0.0pt \\} + } \catcode `L11 \catcode `N11 \catcode `S11 \catcode `U11 + +\def\set:int {\afterassignment\set:frac\int: } +\def\set:frac #1{\afterassignment\csname\count0 } +\def\adv:pos #1{\global\advance#1\the\int:.\the\count0 pt } +\def \pt:p {\adv:pos {\v:pos 0ptplus}} +\def \pt:m {\adv:pos {\v:pos 0ptminus}} +\def \fil:p {\adv:pos \v:fil } +\def \fill:p {\adv:pos \v:fill } +\def\filll:p {\adv:pos \v:filll } + +\def\add:plus #1{{\expandafter\set:int \Plus: {\skip#1}:p\endcsname }} +\def\add:minus #1{{\expandafter\set:int \Minus:{\skip#1}:m\endcsname }} + +%%%%%%%%%%%%%%%%%%%%%%%% +%%% LaTeX extras %%% +%%%%%%%%%%%%%%%%%%%%%%%% + +\catcode`@ 11 +\ifx \@outputbox\undefined \endinput \catcode`@12 \catcode`: 12 \fi + +\newtoks\latex:output \latex:output \output +\newdimen\v:ht % possibly \textheight could be used + +\def\bg:@makecol {\switch:to \bg:skip + \setbox\the:page \vbox + {\vbox{}\bg:top \unvbox\the:page \bg:bot } + \@makecol + \global\v:ht\ht\@outputbox \global\v:size\v:ht + \global\advance\v:size\dp\@outputbox + \zero:pos \outputpenalty\true:penalty + \repeat:page \unvbox\@outputbox \fg:end + } +\def\bg:@makepage {\setbox\@outputbox \vbox to \v:ht {% + \bg:shift + \vbox to0pt{\vbox to\v:size{\unvbox\bg:page}\vss} + \unvbox\the:page } + \outputpenalty\true:penalty + \let\@makecol\relax \the\latex:output + \zero:pos \reset:inserts + } +\let \bg:makepage \bg:@makepage +\let \bg:pagecontents \bg:@makecol +\def \line: {\hbox to\textwidth} +\let \pageno \c@page + +\catcode`@ 12 \catcode`: 12 + +\endinput %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%% end : background.sty [ 0.3 ] %%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/macros/generic/misc/balancedquotes.sty b/macros/generic/misc/balancedquotes.sty new file mode 100644 index 0000000000..f280fbeba8 --- /dev/null +++ b/macros/generic/misc/balancedquotes.sty @@ -0,0 +1,418 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% file name: balancedquotes.sty (for plain TeX and LaTeX) +%% Ole Michael Selberg, 25.8.1994 +%% E-mail: O.M.Selberg@easteur-orient.uio.no +%%------------------------------------------------------------------- +%% Description: +%% This file contains macros that simplify the management of quotes. +%% The input: +%% "...*....*..." +%% will be typeset as: +%% <<...<...>...>> (default) +%% +%% (or as: +%% ,,...,...'...'' +%% etc., depending on your choices.). +%% +%% TeX keeps track of whether full quotes (written as ") and half +%% quotes (written as *) are balanced, When a quote has been omitted, +%% as in: +%% --- text "text in quotes more text "text in quotes" --- +%% an error message is written to the screen, and a mark is put in +%% the margin to the left of the line in which a final full or half +%% quote followed by a letter was discovered. +%% +%% The macros can be used both with plain TeX and LaTeX. You can test +%% them and learn how to use the commands by running the test file +%% which is included in this file, after \endinput. +%% Just copy all the stuff after \endinput to a new file, +%% which you should name balancedquotestest.tex, and then delete it +%% from this file. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\catcode`\@=11 \catcode`\_=11 \newif\ifapostrophe \newlinechar=`^^J +% +\def\definequotes #1#2#3#4{% + \def\bquote_char{#1}\def\equote_char{#2}% + \def\bhquote_char{#3}\def\ehquote_char{#4}} +% +\def\setquotes{\futurelet\test_token\CheckForOptArg} +\def\CheckForOptArg{\ifx\test_token[ + \let\next\OptArgPresent + \else \let\next\OptArgAbsent \fi \next} +\def\OptArgPresent[#1]#2{\csname #2#1q\endcsname} +\def\OptArgAbsent #1{\csname #1q\endcsname} + %--------------------------------------- + % Norwegian: + % +\def\Nq{% Output: <<...<...>...>> + \def\bquote_char {\char"13 }\def\equote_char {\char"14 }% + \def\bhquote_char {\char"0E}\def\ehquote_char {\char"0F}% + } +\def\NCq{% Output: ,,...,...'...'' + \def\bquote_char {\char"12 \apostrophe_check}% + \def\equote_char {\char"11 }% + \def\bhquote_char {\char"0D}\def\ehquote_char {\char"27}% + \apostrophetrue} +\let\NGq=\Nq \let\norwegianquotes=\Nq \let\norwegianguillemetsq=\Nq +\let\norwegiancommasq=\NCq + %----------------------------------------- + % German: + % +\def\DGq{% Output: >>...>...<...<< + \def\bquote_char {\char"14 }\def\equote_char {\char"13 }% + \def\bhquote_char {\char"0F}\def\ehquote_char {\char"0E}% + } +\def\DCq{% Output: ,,...,...`...`` + \def\bquote_char{\char"12 \apostrophe_check}% + \def\equote_char {\char"10 }% + \def\bhquote_char {\char"0D}\def\ehquote_char {\char"60}% + \apostrophetrue} +\let\Dq=\DCq \let\germanquotes=\DCq \let\germanguillemetsq=\DGq +\let\germancommasq=\DCq + %------------------------------------------ + % French: + % +\def\Fq{% Output: <<...<<...>>...>> + \def\bquote_char {\char"13\ }% + \def\equote_char {\thinspace\char"14 }% + \def\bhquote_char {\char"13\thinspace }% + \def\ehquote_char { \char"14 }% + } +\def\FCq{\message{French doesn't use comma quotes! + I shall choose guillemets instead.}} +\let\frenchquotes=\Fq \let\FGq=\Fq \let\frenchguillemetsq=\Fq +\let\frenchcommasq=\FCq + %------------------------------------------ + % English: + % +\def\GBq{% Output: `...``...''...' + \def\bquote_char {\char"60 }\def\equote_char {\char"27 }% + \def\bhquote_char {\char"10 }\def\ehquote_char {\char"11 }% + } +\def\USq{% Output: ``...`...'...'' + \def\bquote_char {\char"10 }\def\equote_char {\char"11 }% + \def\bhquote_char {\char"60 }\def\ehquote_char {\char"27 }% + } +\def\EQM{\message{English doesn't use guillmets! + I shall choose normal English quotes instead.}} +\let\USquotes=\USq \let\GBquotes=\GBq \let\USCq=\USq \let\GBCq=\GBq +\def\GBguillemetsq{\EQM\GBq} \def\USguillemetsq{\EQM\USq} +\let\englishquotes=\USq \let\englishcommasq=\USq \let\Eq=\USq \let\ECq=\USq +\let\englishguillemetsq=\USguillemetsq +%------------------------------------------- +\def\bquote{\global\advance\quotecount by1 \bquote_char}% +\def\equote{\penalty 10000 {\equote_char }\global\advance\quotecount by1 }% +\def\bhquote{\bhquote_char \global\advance\hquotecount by1 }% +\def\ehquote{\penalty 10000 \ehquote_char \global\advance\hquotecount by1 }% + +\newcount\quoteflag \newcount\quotecount +\newcount\hquoteflag \newcount\hquotecount +\def\hex{"} \let\star=* +\catcode`\"=\active \catcode`\*=\active +\def"{\begingroup\ifnum\quoteflag=0 + \aftergroup\bquote\global\quoteflag=1 + \else \equote\global\quoteflag=0 + \aftergroup\equote_check \fi \endgroup} +\def*{\begingroup\ifmmode \else\ifnum\hquoteflag=0 \bhquote\global\hquoteflag=1 + \else \ehquote\global\hquoteflag=0 + \aftergroup\ehquote_check \fi \fi \endgroup} +\def\equote_check{\futurelet\next\equote_test} +\def\ehquote_check{\futurelet\next\ehquote_test} +\def\equote_test{\ifcat\noexpand\next a% + \immediate\write16{^^J--->> Final full quote followed by a + letter!!}\equote_warning\fi} +\def\ehquote_test{\ifcat\noexpand\next a% + \immediate\write16{^^J---> Final half quote followed by a + letter!!}\ehquote_warning\fi} +\def\quotesnumbertest{\ifodd\quotecount\immediate\write16{!! Odd number + of full quotes.}\fi + \ifodd\hquotecount\immediate\write16{!! Odd number + of half quotes.}\fi} +\def\apostrophe_check{\futurelet\next\apostrophe_test} +\def\apostrophe_test{\if\next j\thinspace\fi} + +\def\l_note{\strut\vadjust{\kern-\dp\strutbox + \vtop to 0pt{% + \vss\llap{{\box0}\ + \quad}} + \dimen0=-\prevdepth\advance\dimen0by\dp\strutbox + \penalty0\kern\dimen0 +}} +\def\equote_warning{{\setbox0=\hbox{\equote_char\thinspace !\quad}\l_note}} +\def\ehquote_warning{{\setbox0=\hbox{\ehquote_char\thinspace !\quad}\l_note}} +% +%\catcode`\@=12 \catcode`\_=8 +\Nq +\endinput + +% Copy this to a new file: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% file name: balancedquotestest.tex +%% Ole Michael Selberg, 25.8.1994 +%% E-mail: O.M.Selberg@easteur-orient.uio.no +%%------------------------------------------------------------------- +%% Description: +%% This file inputs the file balancedquotes.sty and tests +%% the quote macros defined there. +%% It works with both plain TeX and LaTeX. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newif\ifLaTeX + % Is this LaTeX? +\ifx\protect\undefined \else \LaTeXtrue \fi + % We presuppose Cork-encoding: +\def\"{\accent4}\def\\{$\backslash$}\def\<{$\lbrace$} +\def\>{$\rbrace$} +\overfullrule=0pt + + +\ifLaTeX + \documentstyle [balancedquotes] {article} + \begin{document} +\else \input balancedquotes.sty +\fi + +\message{^^JType the name of a font with Cork encoding, + ^^Je.g. dcr10:} +\read16 to \dvifontname +\font\dvifont=\dvifontname at 10pt +\message{^^J} +\dvifont + +\hsize=10cm +\hoffset=2cm +\parindent=0pt + +\hyphenation{Af-ten-pos-ten} +\centerline{Test of {\tt balancedquotes.sty}\hfill + Date:\enspace \the\month/\the\day/\the\year} + +\vglue 1cm +%\Nq +\definequotes{\char19}{\char20}{\char14}{\char15} + +\moveleft 10pt\vbox{\bf The command {\tt \\Nq} (\dvifont Norwegian: "...*...*..."):} +\smallskip +"Det er sant," sa han, "jeg har nettopp avbestilt *Aftenposten*!" + +"Har du det?" svarte hun forbauset. "Hvorfor spurte du ikke meg f{\o}rst?" + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt +\\norwegianquotes ({\dvifont This is the default for Norwegian.}) + +\\NGq + +\\setquotes \<norwegian\> + +\\setquotes \<N\> + +\\setquotes [guillemets]\<norwegian\> + +\\setquotes [G]\<N\> + +\\norwegianguillemetsq + +\\definequotes \<\\char19\>\<\\char20\>\<\\char14\>\<\\char15\> + +} + +\bigskip + +\setquotes [commas]{norwegian} + + +\moveleft 10pt\vbox{\bf The command {\tt \\NCq} \dvifont (Norwegian: "...*...*..."):} +\smallskip +"Det er sant," sa han, "jeg har nettopp avbestilt *Aftenposten*!" + +"Har du det?" svarte hun forbauset. "Hvorfor spurte du ikke meg f{\o}rst?" +\medskip + +{\leftskip20pt +Equivalent commands: +\tt +\smallskip + +\\setquotes [commas]\<norwegian\> + +\\setquotes [C]\<N\> + +\\norwegiancommasq + +\\definequotes \<\\char18\>\<\\char17\>\<\\char13\>\<\\char39\> + +} +\bigskip +\Dq + +\moveleft 10pt\vbox{\bf The command {\tt \\Dq} \dvifont (German: "...*...*..."):} +\smallskip +Goethe schrieb: "Wielands *Oberon* wird als ein Meisterst\"uck angesehen." + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt + +\\germanquotes ({\dvifont This is the default for German}) + +\\DCq + +\\setquotes [commas]\<german\> + +\\setquotes [C]\<D\> + +\\germancommasq + +\\definequotes \<\\char18\>\<\\char17\>\<\\char13\>\<\\char39\> + +} + +\bigskip +\DGq + +\moveleft 10pt\vbox{\bf The command {\tt \\DGq} \dvifont (German: "...*...*..."):} +\smallskip +Goethe schrieb: "Wielands *Oberon* wird als ein Meisterst\"uck angesehen." + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt + +\\setquotes [guillemets]\<german\> + +\\setquotes [G]\<D\> + +\\germanguillmetsq + +\\definequotes \<\\char20\>\<\\char19\>\<\\char15\>\<\\char14\> + +} + +\ifLaTeX \else\filbreak\fi + +\USq + +\moveleft 10pt\vbox{\bf The command {\tt \\USq} \dvifont (US English: "...*...*..."):} +\smallskip +Goethe wrote: "Wieland's *Oberon* is considered a masterpiece." + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt + +\\setquotes \<US\> + +\\setquotes [commas]\<US\> + +\\setquotes [C]\<US\> + +\\UScommasq + +\\definequotes \<\\char16\>\<\\char17\>\<\\char96\>\<\\char39\> + +\\setquotes [guillmets]\<US\> {\dvifont etc.\ will generate an error message +and call} \\USq + +} + +\bigskip +\GBq + +\moveleft 10pt\vbox{\bf The command {\tt \\GBq} \dvifont (GB English: "...*...*..."):} +\smallskip +Goethe wrote: "Wieland's *Oberon* is considered a masterpiece." + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt + +\\setquotes \<GB\> + +\\setquotes [commas]\<GB\> + +\\setquotes [C]\<GB\> + +\\GBcommasq + +\\definequotes \<\\char96\>\<\\char39\>\<\\char16\>\<\\char17\> + +\\setquotes [guillmets]\<GB\> {\dvifont etc.\ will generate an error message +and call} \\GBq + +} + + +\bigskip +\Fq + +\moveleft 10pt\vbox{\bf The command {\tt \\Fq} \dvifont (French: "...*...*..."):} +\smallskip +On dit couramment {\it nic nie wiem\/} "je ne sais rien". + +\medskip +{\leftskip20pt +Equivalent commands: +\smallskip +\tt + +\\frenchquotes {\dvifont This is the default.} +\\setquotes \<GB\> + +\\setquotes [guillemets]\<F\> + +\\setquotes [G]\<F\> + +\\frenchguillemetsq + +\\definequotes \<\\char19\ \>\<\\ \\char20\>\<\\char19\ \>\<\\ \\char20\> + +\\setquotes [commas]\<french\> {\dvifont etc.\ will generate an error message +and call} \\Fq + +} + +\bigskip + +\NCq + +\moveleft 10pt\vbox{\bf Test of error detection when quotes are unbalanced:} +\smallskip +"Det er sant," sa han, "jeg har nettopp avbestilt *Aftenposten*!" + +"Har du det? svarte hun forbauset. "Hvorfor spurte du ikke meg f{\o}rst?" + + +\bigskip + + +\moveleft 10pt\vbox{\bf Test of {\tt \\hex} og {\tt \\star}} +\smallskip +The command {\tt \\hex} is used instead of {\tt +\\char\hex22} whenever {\tt \\char\hex22} does not denote +a quote sign. For instance, we can write: {\tt +\\char\hex41} in order to get an `A'. Here we +test that the macro {\tt \\hex} works as it should: `{\tt +\\char\\hex4F\\char\\hex4B}' +is output as `\char\hex4F\char\hex4B'. + +\smallskip +Instead of {\char \hex2A} we write {\tt \\star}. + +\def\slutt{\end{document}} +{\ifLaTeX + \aftergroup\slutt +\fi} + +\bye + diff --git a/macros/generic/misc/calendarweek.tex b/macros/generic/misc/calendarweek.tex new file mode 100644 index 0000000000..fb5a42ed7b --- /dev/null +++ b/macros/generic/misc/calendarweek.tex @@ -0,0 +1,35 @@ +%% calendarweek.tex +%% 2006 (C) Taco Hoekwater, public domain +%% +%% Usage: +%% \calendarweek{30}{12}{2006} +%% +%% Watch out: Dec 29 can be week 1 of the next year; and Jan 3 can be +%% week 53 of the previous year. + +\def\Expr#1{\the\numexpr #1\relax} + +\def\Modulonumber#1#2{\Expr{#2-((((#2+(#1/2))/#1)-1)*#1)}} +\def\Divisionnumber#1#2{\Expr{(2*#2-#1)/(2*#1)}} + +\def\Mod#1#2{\Modulonumber{\Expr{#2}}{\Expr{#1}}} +\def\Div#1#2{\Divisionnumber{\Expr{#2}}{\Expr{#1}}} + +\def\Jday#1#2#3% + {\Expr{#1+\Div{((153*(\Expr{#2+(12*(\Div{14-#2}{12}))-3}))+2)} + {5}+365*(\Expr{#3+4800-(\Div{14-#2}{12})})+ + (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{4})- + (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{100})+ + (\Div{\Expr{#3+4800-(\Div{14-#2}{12})}}{400})-32045 }} + +\def\cwhlp#1#2#3% + {\Expr{\Mod {\Mod {\Mod {\Expr + {\Jday{#1}{#2}{#3}+31741-\Mod{\Jday{#1}{#2}{#3}}{7}}}% + {146097}}{36524}}{1461}}} + +\def\calendarweek#1#2#3% + {\Expr{\Expr{\Div{\Expr{\Mod{\cwhlp{#1}{#2}{#3}- + \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}{365}+ + \Expr{\Div{\cwhlp{#1}{#2}{#3}}{1460}}}}{7} +1}}} + +\endinput diff --git a/macros/generic/misc/chessmin.tex b/macros/generic/misc/chessmin.tex new file mode 100644 index 0000000000..49b03d31b4 --- /dev/null +++ b/macros/generic/misc/chessmin.tex @@ -0,0 +1,171 @@ +% These are two TeX macros which may be useful for writing about +% chess. \bore creates a chess diagram from Forsyth notation, with +% Z used as a terminator. For example, +% +% $$\bore r1bqkbnr pppp1ppp 2n5 1B2p3 4P3 5N2 PPPP1PPP RNBQK2R Z$$ +% +% shows the Ruy Lopez after white's third move. +% +% \VAR (number) (moves separated by spaces) Z may be used to write +% a variation. The macro inserts the move numbers, starting with +% (number). For example, +% +% Continuing from the diagram above, \VAR 3 \dots{} a6 Ba4 Nf6 O--O +% Be7 Re1 b5 Bb3 O-O c3 d5 Z is the Marshall gambit. +% +% Note the \dots{} to indicate that Black made the first move. +% +% The diagrams created by \bore have pieces made up of a small number +% of rectangles. Much nicer diagrams and more powerful macros were +% created by Piet Tutelaers, available by anonymous ftp +% at sol.cs.ruu.nl (131.211.80.5). However, the ones offered here +% do not require additional fonts, and may be easier to use. +% +% I authorize circulation of these macros by ftp sites and similar +% nonprofit media. Improvements are welcome. An earlier version of +% the macros (with letters for pieces) was done several years ago, +% with substantial modifications by Steve Cochran. +% +% Charles Blair (ceblair@ux1.cso.uiuc.edu) +% macros start below--- you may cut here -------------------------- +% +% \fun is the fundamental length unit for the diagrams. If you +% replace 1.2pt by something else, the scale is changed. +% The box rf is not used, except to provide something with which to +% refer to \fun. +% +\newdimen\fun \dimen\fun=1.2pt +\newbox\rf \setbox\rf=\vbox to \dimen\fun{ +\hrule height \dimen\fun width \dimen\fun} +% +\def\oil{\offinterlineskip} % I needed to use this in all my vboxes +% +% Black pieces are made from solid boxes of specified height and +% width (the \filbox macro). For White pieces, \filbox is replaced by a +% macro (\blbox) which draws the lines around the border of such a box. +% (the white knight is an exception to this) +% The macro \tbo is defined as \blbox or \filbox as needed. +% +\def\filbox#1#2{\vbox{\oil \hrule height #1\ht\rf width #2\ht\rf}} +% +\newdimen\adjust +\def\blbox#1#2{\dimen\adjust=#1\ht\rf \advance\dimen\adjust by-0.4\ht\rf +\vbox{\oil \hrule height 0.2\ht\rf width #2\wd\rf +\hbox to #2\wd\rf{\vrule height \dimen\adjust width 0.2\wd\rf\hfil +\vrule height \dimen\adjust width 0.2\wd\rf} +\hrule height 0.2\ht\rf width #2\wd\rf}} +% +% Each piece is 12 units wide. \scen produces an hbox with this width +% and either a \blbox or a \filbox in the center. +% +\def\scen#1#2{\hbox to 12\wd\rf{\hfil\tbo{#1}{#2}\hfil}} +% +% Definitions (color independent) of each piece +% +\def\pawn{\vbox{\oil \scen{2.5}{4}\scen{3}{8}\scen{4.5}{4}\scen{3}{10}}} +% +\def\bishop{\vbox{\oil \scen{2}{2.5}\scen{3}{8}\scen{4}{10}% +\scen{3}{6}\scen{1.5}{12}}} +% +\def\rook{\vbox{\oil +\hbox to 12\wd\rf{\tbo2{2.5}\hfil\tbo2{2.5}\hfil\tbo2{2.5}} +\scen{3}{12}\scen{5.5}{7}\scen{3}{12}}} +% +\def\queen{\vbox{\oil \hbox to 12\wd\rf{\tbo{6}{2}\hfil\tbo{8}{2}% +\hfil\tbo{8}{2}\hfil\tbo{6}{2}}\scen{4}{10}}} +% +\def\king{\vbox{\oil% Next 4 lines are the cross part (improvement wanted) +\hbox to 12\wd\rf{\rlap% +{\hbox to 12\wd\rf{\hfil\vrule height 3\ht\rf width 0.2\wd\rf\hfil}}% +\hfil\raise 1.5\ht\rf% +\hbox{\vrule width 3\ht\rf height 0.2\ht\rf}\hfil} +\hbox to 12\wd\rf{\tbo{6}{4.5}\hfil\tbo{6}{4.5}} +\scen{4}{10}}} +% +\def\knight{\vbox{\oil \hbox{\hskip 7\wd\rf\tbo{1}{1}} +\hbox{\hskip2\wd\rf\tbo{2.5}{7}}\hbox{\hskip 2\wd\rf +\vbox to 3\ht\rf{\tbo{1}{1.5}\vfil}\hskip3\wd\rf\tbo{3}{2.5}} +\hbox{\hskip 3.4\wd\rf\tbo{4}{5.6}} +\tbo{2.5}{12}}} +% +% Creation of the boxes for the pieces +% +\newbox\WP \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WP=\pawn +\newbox\BP \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BP=\pawn +\newbox\WB \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WB=\bishop +\newbox\BB \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BB=\bishop +\newbox\WR \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WR=\rook +\newbox\BR \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BR=\rook +\newbox\WQ \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WQ=\queen +\newbox\BQ \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BQ=\queen +\newbox\WK \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WK=\king +\newbox\BK \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BK=\king +\newbox\BN \def\tbo#1#2{\filbox{#1}{#2}} \setbox\BN=\knight +% +% The exceptional white knight (a lot of work to avoid a line at neck!) +% +\newbox\WN \def\tbo#1#2{\blbox{#1}{#2}} \setbox\WN= +\vbox{\oil \hbox{\hskip 7\wd\rf\tbo{1}{1}} +\hbox{\hskip2\wd\rf\vrule height 2.5\ht\rf width 0.2\ht\rf +\vbox to 2.5\ht\rf{\hrule height 0.2\ht\rf width 6.6\wd\rf\vfil +\hrule height 0.2\ht\rf width 4.5\wd\rf}% +\vrule height 2.5\ht\rf width 0.2\wd\rf} +\hbox{\hskip 2\wd\rf +\vbox to 3\ht\rf{\tbo{1}{1.5}\vfil}\hskip3\wd\rf +\hbox to 2.5\wd\rf{\vrule height 3\ht\rf width 0.2\wd\rf\hfil +\vrule height 3\ht\rf width 0.2\wd\rf}} +\hbox{\hskip 3.4\wd\rf\tbo{4}{5.6}} +\tbo{2.5}{12}} +% +% \ver is the line used for square boundaries on the board +% \nver is thinner line used to shade dark squares (if no piece on them) +% \hor draws horizontal lines for each rank +% +\def\ver{\vrule height 15\ht\rf width 0.4\wd\rf} +\def\nver{\vrule height 15\ht\rf width 0.1\wd\rf} +\def\hor{\hrule height 0.4\wd\rf width 120\wd\rf} +% + \newcount\color \newcount\blanks +\def\blanksquare{\ifodd\color \hbox to 15\wd\rf{\hfil\nver% +\hfil\nver\hfil\ver}\else\hbox to 15\wd\rf{\hfil\ver}\fi +\advance\color by 1} +% +% Each piece is centered inside a 15-unit square +% +\def\cen#1{\hbox to 15\wd\rf{\hfil\vbox to 15\ht\rf{\vfil\copy#1\vfil}% +\hfil\ver}} +% +% This processes the characters specifying a row of the diagram. It +% is patterned after the \length example at the end of chapter 20 +% of The TeXbook +\def\nextchar#1{\let\nex=\nextchar% +\ifcat7#1% +\blanks=#1\loop\ifnum\blanks>0 \blanksquare% +\advance\blanks by -1\repeat\else +\advance\color by 1% +\ifx#1P\cen{\WP}\else\ifx#1p\cen{\BP}\else% +\ifx#1N\cen{\WN}\else\ifx#1n\cen{\BN}\else% +\ifx#1B\cen{\WB}\else\ifx#1b\cen{\BB}\else% +\ifx#1Q\cen{\WQ}\else\ifx#1q\cen{\BQ}\else% +\ifx#1R\cen{\WR}\else\ifx#1r\cen{\BR}% +\else\ifx#1K\cen{\WK}\else\ifx#1k\cen{\BK}\else\let\nex=\relax% +\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\nex} +% +% \bore carries out preliminary steps for making the diagram. +% \rgc reads in a string of non-blank characters, checks that the +% first character is not the terminator Z, gives the string to \nextchar, +% and then processes the next string. (again patterned after \length) +% +\def\bore#1Z{\color=1\vbox{\oil \hor\rgc#1 Z }} +\def\rgc#1#2 {\advance\color by 1\let\nx=\rgc\ifx#1Z\let\nx=\relax +\else\hbox{\ver\nextchar#1#2Z}\hor\fi\nx} +% +% This macro prints a variation. It is supposed to use the ideas of +% \length and seems to work, but there is something I don't understand: +% if the {} following the \else is deleted, something goes wrong. Why? +% +\newcount\move \newcount\iswhite +\def\VAR#1 #2Z{\move=#1\iswhite=1\listem #2 Z } +\def\listem#1#2 {\ifx#1Z\let\nx=\relax\else{}% +\ifodd\iswhite{} \number\move~#1#2\else% +~#1#2\advance\move by 1\fi\advance\iswhite by 1\let\nx=\listem\fi\nx} diff --git a/macros/generic/misc/compare.tex b/macros/generic/misc/compare.tex new file mode 100644 index 0000000000..05976cbe86 --- /dev/null +++ b/macros/generic/misc/compare.tex @@ -0,0 +1,12 @@ +% compare.tex - macro to compare two strings +% By \'Eamonn McManus. This file is not copyrighted. + +\def\compare#1#2{\compcont#1\ \\#2\ \\} +\def\compcont#1#2\\#3#4\\{% + \csname comp% + \if #1#3\if #1\ same\else cont\fi + \else \ifnum `#1<`#3less\else greater\fi \fi + \endcsname #2\\#4\\} +\def\compsame#1\\#2\\{0} +\def\compless#1\\#2\\{-1} +\def\compgreater#1\\#2\\{1} diff --git a/macros/generic/misc/cropmark.tex b/macros/generic/misc/cropmark.tex new file mode 100644 index 0000000000..3f04674e82 --- /dev/null +++ b/macros/generic/misc/cropmark.tex @@ -0,0 +1,154 @@ +%% Save file as: CROPMARK.TEX Source: FILESERV@SHSU.BITNET +% Author: Peter Ungar <LAXA@ACFcluster.NYU.EDU> +% +% CROPMARK MACROS FOR PLAIN TEX. Feb. 10, 1992 01:31 Peter Ungar 914 723 7187 +% Cropmarks are markings on pages intended to be phototypeset. They mark the +% corners of the intended book page. +% THE DIMENSION SPECIFICATIONS (\paperheight,\paperwidth, \topmargin, +% \outsidemargin, \hsize, \vsize) SHOULD COME BEFORE THE MACROS. OTHERWISE +% THE CROPMARKS GO INTO ODD LOCATIONS. THESE QUANTITIES ARE ASSIGNED VALUES +% IN THIS FILE TO MAKE THE EXAMPLE WORK. REPLACE THE GIVEN VALUES BY THE +% ONES YOU NEED BEFORE INSTALLING THE MACROS. HSIZE IS THE LENGTH OF THE LINES +% AND VSIZE IS THE HEIGHT OF THE PRINTED PAGE NOT COUNTING HEADER OR FOOTER. +% \lefttopcropmark should be inserted at the beginning of the +% headline. It is a \llap and should not take space away from any other item +% in the headline. \righttopcropmark should be at the end of the headline. +% If there is no \hfil in the headline, use one to put the cropmark to +% the end of the headline. It is a \rlap and in theory it should not take +% space away +% from other items. Do not to put a space in front of \righttopcropmark be- +% cause the space will be typeset unless it is preceded by a control sequence. +% The bottom cropmarks should be inserted in the beginning and end of the +% \footline. Be sure to fill space in the middle with \hfil. +% Remember that the \footline definition has to come BEFORE the end of the +% first page. +% The values of \voffset and \hoffset can be adjusted to try to push the +% entire page including the cutmarks into the area your printer can print. +% The quantities you have to input are +% \paperheight, \paperwidth, \topmargin (measured from the top of the headline +% which is assumed to be 10-point size, and \outsidemargin which will be the +% right margin of odd-numbered pages and the left margin of even numbered +% pages. The other quantities which are needed are computed by the macros. +% The computations two empirical corrections. +% If the dimensions on your printout are slightly off, try over or under- +% stating the true dimensions of the above quantities. +% The macros ought to work for all values of \hsize and \vsize but if these +% are too large the cropmarks may not fit the area most printers can print. +% \nocropmarks replaces the cropmark macros by \relax (blanks). The cropmarks +% are needed only for phototypesetting and we may not want to see them on +% printout prepared for other purposes. +% TEX WILL NOT LET YOU KNOW IF YOU DID NOT ASSIGN A VALUE TO A DIMENSION. +% THAT MAY BE THE REASON IF YOU GET BIZARRE RESULTS. THE VALUES MUST COME +% BEFORE THE MACROS. + +%\magnification 1042 %% Needed to get exact dimensions on the MacPlus screen. + +\voffset=20mm\hoffset=15mm % Needed to bring cropmarks within printable area. +\overfullrule=0mm % To prevent overfullrules being added to cropmarks +\newdimen\paperheight +\newdimen\paperwidth +\newdimen\topmargin +\newdimen\outsidemargin +\newdimen\insidemargin +\newdimen\leftmargin +\newdimen\rightmargin +\newdimen\topliftadjustment +\newdimen\bottomliftadjustment +\newdimen\topcropmarklift +\newdimen\bottomcropmarklift +\newdimen\leftsideskip +\newdimen\rightsideskip +\newdimen\bclifta +\newdimen\bcliftb + +\vsize=182mm +\hsize=112mm +\paperheight=227.4mm % These six quantities specify the margins. +\paperwidth=152.3mm % The ones introduced below are either +\topmargin=14mm % computed from these by the macros or they +\outsidemargin=25mm % are auxiliary. + +\topliftadjustment=2.6mm +\bottomliftadjustment=15.5mm +\insidemargin=\paperwidth +\advance\insidemargin by -\outsidemargin +\advance\insidemargin by -\hsize + +\def\leftorright{\ifodd\pageno +\leftmargin=\insidemargin\rightmargin=\outsidemargin\else +\leftmargin=\outsidemargin\rightmargin=\insidemargin\fi +\leftsideskip=\leftmargin +\advance\leftsideskip by -4.05mm +\rightsideskip=\rightmargin +\advance\rightsideskip by -4.05mm} + +\def\lefttopcropmark{{\parindent=0mm\llap{\vtop{ +\hsize=\leftmargin +\vskip-\topliftadjustment +\vskip-\topmargin +\vrule height 0.05mm depth 4mm width 0.05mm +\vrule height 0.05mm depth0mm width 4mm +\hfill}}}} +\def\righttopcropmark{{\parindent=0mm\rlap{\vtop{\hsize=\rightmargin +\vskip-\topliftadjustment +\vskip-\topmargin +\hfill +\vrule height 0.05mm depth0mm width 4mm +\vrule height 0.05mm depth 4mm width 0.05mm +}}}} + +\bottomcropmarklift=-\paperheight +\advance\bottomcropmarklift by\topmargin +\advance\bottomcropmarklift by\vsize +\advance\bottomcropmarklift by\bottomliftadjustment + +\bclifta=\bottomcropmarklift +\advance\bclifta by 4mm +\bcliftb=\bottomcropmarklift +\advance\bcliftb by -0.05mm + +\def\leftbottomcropmark{{\parindent=0mm\llap{ +\hbox{\vrule height\bclifta depth -\bottomcropmarklift width 0.05mm +\vrule height \bottomcropmarklift depth -\bcliftb width 4mm +\hskip\leftsideskip}}}} + +\def\rightbottomcropmark{{\parindent=0mm\rlap{\hbox{\hskip\rightsideskip +\vrule height \bottomcropmarklift depth -\bcliftb width 4mm +\vrule height\bclifta depth -\bottomcropmarklift width 0.05mm}}}} + + +\def\nocropmarks{\def\lefttopcropmark{\relax} % THIS TURNS OFF CROPMARKS +\def\righttopcropmark{\relax} +\def\leftbottomcropmark{\relax} +\def\rightbottomcropmark{\relax}} +\endinput + +% END OF THE MACROS. AN EXAMPLE FOLLOWS. COMMENT OUT \endinput TO +% TYPESET IT. + +\headline={\leftorright\lefttopcropmark\ifodd\pageno +\hfil HEADLINE\hfil\folio\else +\folio\hfil HEADLINE\hfil \fi +\righttopcropmark} +\footline={\leftorright\leftbottomcropmark +\hfil +\rightbottomcropmark} + +\noindent Topliftadjustment=2.6mm bottomliftadjustment=15.5mm +\hfill H + +\noindent paperheight=227.4mm paperwidth=152.3mm + +\noindent topmargin=14mm outsidemargin=25mm + +\noindent vsize=182mm hsize=112mm + +NOTE THAT THE DIMENSION SPECIFICATIONS MUST COME BEFORE THE MACROS. +\vfill +\noindent\line{Here is the bottom left corner. \hfil Bottom right is H} +\eject +\noindent\line{Here is the top left corner.\hfil Top right is H} +\vfill +\noindent\line{Here is the bottom left corner. \hfil Bottom right is H} +\eject +\end diff --git a/macros/generic/misc/dayofweek.tex b/macros/generic/misc/dayofweek.tex new file mode 100644 index 0000000000..4ce46ac243 --- /dev/null +++ b/macros/generic/misc/dayofweek.tex @@ -0,0 +1,149 @@ +% +% \DayOfWeek expands to the day of the week ("Sunday", etc.) +% \PhaseOfMoon expands to the phase of the moon +% +% Written by Martin Minow of DEC (minow%bolt.dec@decwrl.dec.com). +% +\def\DayOfWeek{% +% +% Calculate day of the week, return "Sunday", etc. +% + \newcount\dow % Gets day of the week + \newcount\leap % Leap year fingaler + \newcount\x % Temp register + \newcount\y % Another temp register +% leap = year + (month - 14)/12; + \leap=\month \advance\leap by -14 \divide\leap by 12 + \advance\leap by \year +% dow = (13 * (month + 10 - (month + 10)/13*12) - 1)/5 + \dow=\month \advance\dow by 10 + \y=\dow \divide\y by 13 \multiply\y by 12 + \advance\dow by -\y \multiply\dow by 13 \advance\dow by -1 \divide\dow by 5 +% dow += day + 77 + 5 * (leap % 100)/4 + \advance\dow by \day \advance\dow by 77 + \x=\leap \y=\x \divide\y by 100 \multiply\y by 100 \advance\x by -\y + \multiply\x by 5 \divide\x by 4 \advance\dow by \x +% dow += leap / 400 + \x=\leap \divide\x by 400 \advance\dow by \x +% dow -= leap / 100 * 2; +% dow = (dow % 7) + \x=\leap \divide\x by 100 \multiply\x by 2 \advance\dow by -\x + \x=\dow \divide\x by 7 \multiply\x by 7 \advance\dow by -\x + \ifcase\dow Sunday\or Monday\or Tuesday\or Wednesday\or + Thursday\or Friday\or Saturday\fi +} +%% +%% +%% +\def\PhaseOfMoon{% Calculate the phase of the (civil) moon. +% +% The routine calculates the year's epact (the age of the moon on Jan 1.), +% adds this to the number of days in the year, and calculates the phase +% of the moon for this date. It returns the phase as a string, e.g., +% "new", "full", etc. +% +% In the algorithm: +% +% diy Is the day of the year - 1 (i.e., Jan 1 is day 0). +% +% golden Is the number of the year in the Mentonic cycle, used to +% determine the position of the calender moon. +% +% epact Is the age of the calender moon (in days) at the beginning +% of the year. To calculate epact, two century-based +% corrections are applied: +% Gregorian: (3 * cent)/4 - 12 +% is the number of years such as 1700, 1800 when +% leap year was not held. +% Clavian: (((8 * cent) + 5) / 25) - 5 +% is a correction to the Mentonic cycle of about +% 8 days every 2500 years. Note that this will +% overflow 16 bits in the year 409600. Beware. +% +% The algorithm is accurate for the Gregorian calender only. +% +% The magic numbers used in the phase calculation are as follows: +% 29.5 The moon's period in days. +% 177 29.5 scaled by 6 +% 22 (29.5 / 8) scaled by 6 (this gets the phase) +% 11 ((29.5 / 8) / 2) scaled by 6 +% +% Theoretically, this should yield a number in the range 0 .. 7. However, +% two days per year, things don't work out too well. +% +% Epact is calculated by the algorithm given in Knuth vol. 1 (calculation +% of Easter). See also the article on Calenders in the Encyclopaedia +% Britannica and Knuth's algorithm in CACM April 1962, page 209. +% + \newcount\cent % Century number (1979 == 20) + \newcount\epact % Age of the moon on Jan. 1 + \newcount\diy % Day in the year + \newcount\golden % Moon's golden number + \newcount\x % Temp + \newcount\m % Temp for modulus + \diy=\day \advance\diy by \ifcase\month % Jan 1 == 0 + -1\or -1\or 30\or 58\or 89\or 119\or 150\or % Jan .. Jun + 180\or 211\or 241\or 272\or 303\or 333\fi % Jul .. Dec +% if ((month > 2) && ((year % 4 == 0) && +% ((year % 400 == 0) || (year % 100 != 0)))) +% diy++; /* Leapyear fixup */ + \ifnum \month>2 + \x=\year \m=\x \divide\m by 4 \multiply\m by 4 \advance\x by -\m + \ifnum \x=0 % month > 2 and maybe leapyear + \x=\year \m=\x \divide\m by 400 \multiply\m by 400 \advance\x by -\m + \ifnum \x=0 % 2000 is a leap year + \advance\diy by 1 % so it's one day later + \else % not 2000, check other '00's + \x=\year \m=\x \divide\m by 100 \multiply\m by 100 \advance\x by -\m + \ifnum \x>0 % not some other '00' year + \advance\diy by 1 % it's still one day later + \fi % not odd century + \fi % not 2000-type century + \fi % not leapish year + \fi % not march or later +% cent = (year / 100) + 1; /* Century number */ +% golden = (year % 19) + 1; /* Golden number */ + \cent=\year \divide\cent by 100 \advance\cent by 1 + \golden=\year + \m=\year \divide\m by 19 \multiply\m by 19 \advance\golden by -\m + \advance\golden by 1 +% epact = ((11 * golden) + 20 /* Golden number */ +% + (((8 * cent) + 5) / 25) - 5 /* 400 year cycle */ +% - (((3 * cent) / 4) - 12)) % 30;/* Leap year correction */ + \epact=11 \multiply\epact by \golden + \advance\epact by 20 + \x=8 \multiply\x by \cent \advance\x by 5 + \divide\x by 25 \advance\x by -5 + \advance\epact by \x + \x=3 \multiply\x by \cent \divide\x by 4 \advance\x by -12 + \advance\epact by -\x + \m=\epact \divide\m by 30 \multiply\m by 30 \advance\epact by -\m +% if (epact <= 0) +% epact += 30; /* Age range is 1 .. 30 */ +% if ((epact == 25 && golden > 11) || epact == 24) +% epact++; + \ifnum \epact<0 + \advance\epact by 30 + \fi + \ifnum \epact=25 + \ifnum \golden>11 + \advance \epact by 1 + \fi + \else + \ifnum \epact=24 + \advance \epact by 1 + \fi + \fi +% +% Calculate the phase, using the magic numbers defined above. +% Note that phase may be equal to 8 (== 0) on two days of the year +% due to the way the algorithm was implemented. +% phase = (((((diy + epact) * 6) + 11) % 177) / 22) & 7; +% + \x=\diy \advance\x by \epact \multiply\x by 6 \advance\x by 11 + \m=\x \divide\m by 177 \multiply\m by 177 \advance\x by -\m + \divide\x by 22 + \ifcase\x new\or waxing crescent\or in its first quarter\or + waxing gibbous\or full\or waning gibbous\or + in its last quarter\or waning crescent\or new\fi +} diff --git a/macros/generic/misc/daytime.sty b/macros/generic/misc/daytime.sty new file mode 100644 index 0000000000..cfeeafb205 --- /dev/null +++ b/macros/generic/misc/daytime.sty @@ -0,0 +1,30 @@ +%% Save file as: DAYTIME.STY Source: FILESERV@SHSU.BITNET +%% Source: INFO-TeX@SHSU.edu (Wed, 2 Oct 1991 10:01:43 EDT) +%% Author: Mauro Orlandini <ORLANDINI@HEAVAX.GSFC.NASA.GOV> +%% Modified: George D. Greenwade <bed_gdg@SHSU.edu> -- added \Daytime +%% to not have the leading 0 on 1:00 --- 9:00 +\begingroup + \count0=\time + \count1=\count0 + \divide\count0 by 60 + \count2=\count0 + \multiply\count0 by 60 + \advance\count1 by -\count0 + \ifnum\count2>11 + \ifnum\count2>12 \advance\count2 by -12\fi + \def\ampm{pm}% + \else + \ifnum\count2=0 \advance\count2 by 12\fi + \def\ampm{am}% + \fi + \xdef\daytime{% + \ifnum\count2<10 0\fi \the\count2:% + \ifnum\count1<10 0\fi \the\count1 + \ampm + }% + \xdef\Daytime{% %GDG + \the\count2:% %GDG + \ifnum\count1<10 0\fi \the\count1 %GDG + \ampm %GDG + }% %GDG +\endgroup diff --git a/macros/generic/misc/default.sty b/macros/generic/misc/default.sty new file mode 100644 index 0000000000..b2a0f0c023 --- /dev/null +++ b/macros/generic/misc/default.sty @@ -0,0 +1,311 @@ +% DEFAULT.STY, version 1.3 July 1998, provides +% 1. macro parameter-defaulting mechanism. +% 2. user stack and dynamic array +% Particularly useful if you have macros with many parameters, and you +% don't want to remember all of them all the time. +% +% Author: Zhuhan Jiang, University of New England, Australia +% Email: zhuhan@neumann.une.edu.au +% +% NOTES: +% 1. This style file can be loaded in as many times as you want, +% without overrunning the resources for such as counter +% registers and etc. So different packages may all use it to +% default their macro parameters, without causing any conflict. +% 2. Macro parameters that can be defaulted through this style file +% are those included in square brackets. E.g. #1, #2, #3 in +% \foo[#1][#2][#3]#4#5 are defaultable while #4 and #5 here are +% not. +% 3. If \foo is a macro to be defaulted, the original macro \foo +% will be renamed as ``\foo@ raw'' (yes, there is a space) and +% the new macro \foo will be defined through the use of the +% original ``\foo@ raw''. +% +% MAIN MACRO: +% \setdefalut{cmdname}{n}{default1}{..}{default_n} +% - gives defaults to \cmdname[p_1][p_2]..[p_n] +% (the macro to be defaulted must be already defined +% when \setdefault is executed) +% EXAMPLES: +% 1. Suppose \foo is defined for \foo[#1][#2][#3]{#4}, we may default +% all (or some of) the parameters in the SQUARE BRACKETS to for +% instance 'one', 'two' and 'three' via +% \setdefault{foo}{3}{one}{two}{three} +% This way, command \foo{stuff} or \foo[]{stuff} or \foo[][]{stuff} +% or \foo[][][]{stuff} will all be translated as +% \foo[one][two][three]{stuff}. Command \foo[][2]{stuff} will be +% translated as \foo[one][2][three]{stuff}. +% 2. See how \placebox is defined and redefined via \setdefault +% in this file. +% +% TIP: +% The best strategy to define (e.g.) \foo[#1][#2]{#3} so that +% it has defaults for #1 and #2 +% 1. define \foo@[#1][#2]#3 as normal (what you wish) +% 2. define \foo[#1][#2]#{\foo@[#1][#2]} to make {#3} mandatory +% 3. use \setdefault{foo}{2}{one}{two} to default #1=one and #2 to two +% +% MINOR MACROS: +% \placebox[#1][#2][#3][#4][#5][#6]{#7} +% - place stuff #7 in a box at the position specified +% by parameters #1, ..., #6. (move mini page around) +% #1: box position (default 0) +% 1--6--2 <-- top of the box +% | | +% | | +% | | +% 9 5 7 0 is -5 <-- middle height of the box +% | | +% 10 11 12 <-height up <-- baseline +% | | depth down +% 4--8--3 <-- bottom of the box +% #1<=0: box has no width, no height +% #2: x shift (default 0pt) +% #3: y shift (default 0pt) +% #4,#5: extra x,y shift in multiple of box width/10, height/10 +% #6: box type: v=vbox, otherwise=hbox +% #7: content to be boxed +% \push{ ... } - push stuff to stack; anything can be saved to +% \pop - pop stack +% \popnil - delete stack top element (pop to nil) +% \fetch{#1} - fetch #1-th entry from the stack +% (illegal number #1 will produce \relax) +% if #1>0, fetch #1-th entry from bottom of stack +% if #1>=0, fetch (-#1)-th element from top of stack +% e.g. +% fetch{0} - fetch the element of the top of stack +% fetch{-1} - the element just below the top of stack +% fetch{2} - 2nd element from the bottom of stack +% +\ifx\EntryDefault\undefined + \message{1.3 13/7/98}% + {\catcode`\@=11\relax \def\temp@macro{\space\space\space\space}% + \wlog{\temp@macro DEFAULT.STY version 1.3 July 1998 By Z Jiang}% + \wlog{\temp@macro University of New England, Australia}% + \wlog{\temp@macro Email: zhuhan@neumann.une.edu.au}}% +\fi +\xdef\EntryDefault{\the\catcode`\@}\catcode`\@=11\relax % SAVE @'s STATUS +% +% +% NEW MEASURES etc (parameter defaulting mechanism given by macros below) +\def\new@measures{% + \def\temp@@macro##1##2##3{\expandafter\ifx\csname ##3temp##2##1\endcsname + \relax\edef\next{\noexpand\csname new##1\noexpand\endcsname + \csname ##3temp##2##1\endcsname}% + \else\let\next\relax\fi\next}% + \def\temp@macro##1{% + \temp@@macro{##1}{@}{}\temp@@macro{##1}{@@}{}\temp@@macro{##1}{@@@}{}}% + \temp@macro{count}\temp@macro{toks}\temp@macro{box}\temp@macro{read}% + \temp@@macro{if}{@}{if}\temp@@macro{if}{@@}{if}\temp@@macro{if}{@@@}{if}% + \def\temp@@macro##1{\expandafter\ifx\csname temp##1dim\endcsname + \relax\edef\next{\noexpand\csname newdimen\noexpand\endcsname + \csname temp##1dim\endcsname}% + \else\let\next\relax\fi\next}% + \temp@@macro{@}\temp@@macro{@@}\temp@@macro{@@@}% +}% +\let\temp@@@macro=\wlog\def\wlog#1{}\new@measures +% +%%% GENERAL STACK +\def\make@STKcount{\csname newcount\endcsname + \STKcount\global\STKcount=0\relax}% +\ifx\STKcount\undefined@ + \def\next{\make@STKcount}\else\def\next{}\fi +\next % ensures stack pointer not flushed if this piece of code + % is loaded again +% +\long\def\push#1{\global\advance\STKcount1\relax +\expandafter\gdef\csname STK\the\STKcount\string~\endcsname{#1}}% +% +\def\popnil{\expandafter\let\expandafter\temp@macro + \csname STK\the\STKcount\string~\endcsname + \ifnum\STKcount>0\global\expandafter\let + \csname STK\the\STKcount\string~\endcsname=\undefined@ + \global\advance\STKcount-1% + \else + \def\temp@macro{}\global\STKcount=0% + \fi\relax % \temp@macro for pop +}% +% +\def\pop{\popnil\temp@macro}% +% +\def\fetch@#1{\ifnum#1>0 \relax \temp@count=#1 \else + \temp@count=\STKcount \advance\temp@count by #1 \fi + \csname STK\the\temp@count\string~\endcsname +}% +\def\fetch#{\fetch@}% +% +%% GET PARAMETERS +\long\def\get@nepara[#1][#2]{{\def\next@{#2}% +\ifx\next@\empty\push{#1}\else\push{#2}\fi}\ag@in}% +% +\long\def\get@para\left@#1\right@{% +\def\check@{% + \ifx[\next@ \def\full@####1{\get@nepara[#1]####1}% + \else \def\full@{\get@nepara[#1][#1]}\fi + \full@}% +\futurelet\next@\check@}% +% +\long\def\do@nepara\left@#1\right@#2\p@r@end{% +\gdef\p@r@data{#2}\global\advance\p@r@count1\get@para\left@#1\right@}% +% +\def\ag@in{\ifx\p@r@data\empty \def\next@{\relax +\getp@r@s\run@CMD}\else +\def\next@{\expandafter\do@nepara\p@r@data\p@r@end}\fi +\next@}% +% +\def\run@CMD{\csname STK\the\STKcount\string~\endcsname}% +% +\def\num@to@word#1{\ifcase #1 \or + \def\temp@macro{one}\or \def\temp@macro{two}\or + \def\temp@macro{three}\or \def\temp@macro{four}\or + \def\temp@macro{five}\or \def\temp@macro{six}\or + \def\temp@macro{seven}\or \def\temp@macro{eight}\or + \def\temp@macro{nine}\else \def\temp@macro{}\fi +\temp@toks=\expandafter{\temp@macro}}% +% +\temp@@count=1 % make nine newtoks, if they don't already exist +\loop \num@to@word{\temp@@count}% + \expandafter\ifx\csname p@r@\the\temp@toks\endcsname\relax + \temp@@toks={newtoks}\expandafter\csname\expandafter\the + \expandafter\temp@@toks\expandafter\endcsname + \csname p@r@\the\temp@toks\endcsname\fi + \advance\temp@@count by 1 \ifnum\temp@@count<10 \repeat +% +\ifx\p@r@count\undefined@ \csname newcount\endcsname\p@r@count\fi +\long\def\st@ckparas#1\p@r@end{% +\global\p@r@count=0\gdef\p@r@data{#1}\ag@in}% +% +% PARAMETER ASSIGNMENT % use \temp@count +\def\getp@r@s{\temp@count=\p@r@count +{\loop + \ifnum\temp@count>0 % + \expandafter\let\expandafter + \temp@macro\csname STK\the\STKcount\string~\endcsname + \ifcase\temp@count + \or \global\p@r@one=\expandafter{\temp@macro}% + \or \global\p@r@two=\expandafter{\temp@macro}% + \or \global\p@r@three=\expandafter{\temp@macro}% + \or \global\p@r@four=\expandafter{\temp@macro}% + \or \global\p@r@five=\expandafter{\temp@macro}% + \or \global\p@r@six=\expandafter{\temp@macro}% + \or \global\p@r@seven=\expandafter{\temp@macro}% + \or \global\p@r@eight=\expandafter{\temp@macro}% + \or \global\p@r@nine=\expandafter{\temp@macro}% + \else \errmessage{Parameter capacity exceeded.}% + % this should never happen: TeX's max para no. is 9 + \fi + \global\expandafter\let + \csname STK\the\STKcount\string~\endcsname=\undefined@% + \global\advance\STKcount-1% + \global\advance\temp@count-1\relax + \fi + \ifnum\temp@count>0 % +\repeat}}% +% +\def\clrp@r@s{%GLOBALLY clear +\global\p@r@one={}\global\p@r@two={}\global\p@r@three={}% +\global\p@r@four={}\global\p@r@five={}\global\p@r@six={}% +\global\p@r@seven={}\global\p@r@eight={}\global\p@r@nine={}}% +% +\def\read@paras#1{\temp@@@count=1 %use \temp@@@count and \temp@@count + \loop \num@to@word{\the\temp@@@count}\csname p@r@\the\temp@toks\endcsname={}% + \advance\temp@@@count by 1 \ifnum\temp@@@count<10 \repeat + \temp@@@count=1 \temp@@count=#1 % + \def\read@one@para##1{\num@to@word{\temp@@@count}% + \def\temp@macro{\left@ ##1\right@}% + \temp@@@toks=\expandafter{\temp@macro}% + \csname p@r@\the\temp@toks\endcsname\expandafter{\temp@macro}% + \advance\temp@@@count by 1 \read@continue}% + \def\read@continue{\num@to@word{\temp@@@count}% which uses \temp@macro + \ifnum\temp@@@count>\temp@@count \let\next@@\make@default + \edef\temp@@macro{\the\p@r@one\the\p@r@two\the\p@r@three\the\p@r@four + \the\p@r@five\the\p@r@six\the\p@r@seven\the\p@r@eight\the\p@r@nine}% + \else \let\next@@\read@one@para + \fi \next@@}\read@continue}% +% +\def\make@@default#1#2{\temp@count=#2\relax \temp@@count=1 %used \temp@@macro + \loop \num@to@word{\temp@@count}% + \ifnum\temp@@count>\temp@count \csname p@r@\the\temp@toks\endcsname={}% + \else \csname p@r@\the\temp@toks\endcsname + =\expandafter{\expandafter[\expandafter + \the\csname p@r@\the\temp@toks\endcsname]}\fi + \advance\temp@@count by 1 % + \ifnum\temp@@count<10 \repeat + \edef\temp@macro{\the\p@r@one\the\p@r@two\the\p@r@three\the\p@r@four + \the\p@r@five\the\p@r@six\the\p@r@seven\the\p@r@eight\the\p@r@nine}% + \temp@toks=\expandafter{\temp@macro}% + \temp@@toks=\expandafter{\temp@@macro}% + \expandafter\let\expandafter\temp@macro\csname #1\endcsname + \expandafter\ifx\csname #1@ raw\endcsname\relax + \expandafter\let\csname #1@ raw\endcsname\temp@macro\fi + \expandafter\edef\csname#1\endcsname{% + \noexpand\push{\noexpand\edef\noexpand\next@@{% + \noexpand\noexpand \noexpand \csname \noexpand#1@ raw\noexpand\endcsname + \the\temp@toks}% + \noexpand\popnil\noexpand\clrp@r@s\noexpand\next@@}\noexpand\st@ckparas + \the\temp@@toks \noexpand\p@r@end}}% +% +% \setdefalut{cmdname}{n}{default1}{..}{default_n} +% then \cmdname[#1][..][#n] can be defaulted. +\def\setdefault#1#2{\def\make@default{\make@@default{#1}{#2}}\read@paras{#2}} +% +% DEFAULT MECHANISM END: this piece of code can be included in any +% package and can be reloaded any times without overruning the resources. +% +% Now an example to use \setdefault: +% lower a box +\long\def\xylower#1#2#3{\bgroup\hskip#1\hbox{% #1=x #2=y #3=content + \ifmmode\let\SoftLower\undefined\else\def\SoftLower{}$\fi + \mathop{\vtop{\ialign{##\crcr \noalign{\kern#2}#3\crcr}}}% + \ifx\SoftLower\undefined\else $\fi}\egroup}% +% +% #1=box position(0) #2=x shift(0pt) #3=y shift(0pt) #6=v (vbox) +% #4,#5=extra x,y shift in multiple of box width/10, height/10 #7=content +\long\def\placebox[#1][#2][#3][#4][#5][#6]#7{\begingroup +\def\temp@macro{#6}\def\temp@@macro{v}\ifx\temp@macro\temp@@macro +\setbox\temp@box=\vbox{#7}\else \leavevmode % #1 (box position) +\setbox\temp@box=\hbox{#7}\fi\temp@dim=-\wd\temp@box % 1--6--2 +\temp@@dim=\ht\temp@box \temp@@@dim=\dp\temp@box % | | +\ifnum#1<0 \temp@count=-#1 \else\temp@count=#1 \fi % | | +\ifnum\temp@count=0 \temp@count=5 \fi % | | +\ifcase\temp@count % 9 5 7 0 is -5 + \or \temp@dim=0pt \temp@@dim=0pt % | | + \or \temp@@dim=0pt % 10 11 12 <-height up + \or \advance\temp@@dim by \temp@@@dim % | | depth down + \temp@@dim=-\temp@@dim % 4--8--3 + \or \temp@dim=0pt \advance\temp@@dim by % + \temp@@@dim \temp@@dim=-\temp@@dim % -#1: box has no width etc + \or \divide\temp@dim by 2 \advance\temp@@@dim by \temp@@dim + \divide\temp@@@dim by 2 \temp@@dim=-\temp@@@dim + \or \divide\temp@dim by 2 \temp@@dim=0pt + \or \advance\temp@@dim by \temp@@@dim + \temp@@dim=-\temp@@dim \divide\temp@@dim by 2 + \or \advance\temp@@dim by \temp@@@dim + \temp@@dim=-\temp@@dim \divide\temp@dim by 2 + \or \temp@dim=0pt \advance\temp@@dim by \temp@@@dim + \temp@@dim=-\temp@@dim \divide\temp@@dim by 2 + \or \temp@dim=0pt \advance\temp@@@dim by \temp@@dim \temp@@dim=-\temp@@dim + \or \divide\temp@dim by 2 + \advance\temp@@@dim by \temp@@dim \temp@@dim=-\temp@@dim + \or \advance\temp@@@dim by \temp@@dim \temp@@dim=-\temp@@dim + \or \errmessage{Invalid range of first parameter: #1}\fi + \advance\temp@dim by #2 \advance \temp@@dim by #3 + \temp@@@dim=\wd\temp@box \divide \temp@@@dim by 10 + \multiply\temp@@@dim by #4 \advance\temp@dim by \temp@@@dim + \temp@@@dim=\ht\temp@box \advance\temp@@@dim by \dp\temp@box + \divide \temp@@@dim by 10 \multiply\temp@@@dim by #5 + \advance\temp@@dim by \temp@@@dim + \setbox\temp@box=\hbox{\xylower{\temp@dim}{\temp@@dim}{\box\temp@box}}% + \ifnum#1>0 \else \wd\temp@box=0pt \ht\temp@box=0pt \dp\temp@box=0pt \fi + \box\temp@box\endgroup +}% +% +\ifx\setdefault\undefined\else\setdefault{placebox}{6}{0}{0pt}{0pt}{0}{0}{h}\fi +% example ends +% +\let\wlog\temp@@@macro\let\temp@@@macro\undefined@ +\catcode`\@=\EntryDefault\relax +\endinput +% +%ENDMACROS +% diff --git a/macros/generic/misc/dow.tex b/macros/generic/misc/dow.tex new file mode 100644 index 0000000000..ea504ba375 --- /dev/null +++ b/macros/generic/misc/dow.tex @@ -0,0 +1,44 @@ +%%%------------Start Cutting------------------------------------------ +% \dowcomp returns integer day of week in \dow with Sunday=0. +% \downame returns the name of the day of the week. +% E.g., if \year=1963 \month=11 \day=22, +% then \dowcomp ==> \dow=5 and \downame ==> Friday which happened +% to be the day President John F. Kennedy was assasinated. + +% Converted from the lisp function DOW by Jon L. White given in +% the file LIBDOC DOW JONL3 on MIT-MC (which follows). + +%(defun dow (year month day) +% (and (and (fixp year) (fixp month) (fixp day)) +% ((lambda (a) +% (declare (fixnum a)) +% (\ (+ (// (1- (* 13. (+ month 10. +% (* (// (+ month 10.) -13.) 12.)))) +% 5.) +% day +% 77. +% (// (* 5. (- a (* (// a 100.) 100.))) 4.) +% (// a -2000.) +% (// a 400.) +% (* (// a -100.) 2.)) +% 7.)) +% (+ year (// (+ month -14.) 12.))))) + +\newcount\dow +\def\dowcomp{{\count3 \month \advance\count3 -14 \divide\count3 12 + \advance\count3 \year \count4 \month \advance\count4 10 + \divide\count4 -13 \multiply\count4 12 \advance\count4 10 + \advance\count4 \month \multiply\count4 13 \advance\count4 -1 + \divide\count4 5 \advance\count4 \day \advance\count4 77 + \count2 \count3 \divide\count2 100 \multiply\count2 -100 + \advance\count2 \count3 \multiply\count2 5 \divide\count2 4 + \advance\count4 \count2 \count2 \count3 \divide\count2 -2000 + \advance\count4 \count2 \count2 \count3 \divide\count2 400 + \advance\count4 \count2 \count2 \count3 \divide\count2 -100 + \multiply\count2 2 \advance\count4 \count2 \count2 \count4 + \divide\count2 7 \multiply\count2 -7 \advance\count4 \count2 + \global\dow \count4}} + +\def\dayname{\dowcomp \ifcase\dow Sunday\or Monday\or Tuesday\or + Wednesday\or Thursday\or Friday\else Saturday\fi} +%%%--------------Stop cutting----------------------------------------- diff --git a/macros/generic/misc/emtrees.tex b/macros/generic/misc/emtrees.tex new file mode 100644 index 0000000000..3c9c5e1a3f --- /dev/null +++ b/macros/generic/misc/emtrees.tex @@ -0,0 +1,87 @@ +%From: hwb@texnix.stgt.sub.org (Harald Boegeholz) +%Newsgroups: comp.text.tex +%Date: 14 Jan 91 13:44:29 GMT +% +%Hi! +% +%Some time ago I wrote some TeX-macros to typeset trees. Since +%two people asked recently, here they are (quite short, so I thought +%I might post). Be aware, though, of two possible problems: +% 1. The macros use the \specials defined by emTeX. If your DVI-driver +% doesn't support these, you won't see any lines. +% 2. The semantic nest size required is considerable (too many boxes +% inside of boxes inside of boxes...), so you'll possibly need +% a TeX which is "large" in this respect for typesetting complex trees. +% +%Hope this helps +%Harald +%------------------ cut here with a sharp knife ------------------------ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% tree macros by Harald Boegeholz +% This file uses the \specials defined by emTeX to draw the lines! +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newcount\pointnumber \pointnumber=0 +\newcount\father +\font\nodefont=cmr7 +\def\nextpoint{\global\advance\pointnumber by 1\relax} +\def\endsubtrees{\endsubtrees} +\def\tn#1{\vbox{% + \vskip.5mm + \hbox{\nodefont\hskip1ex\relax #1\hskip1ex} + \vskip.5mm + }% +} +\def\tree#1#2{% + \vtop{% + \nextpoint + \father=\pointnumber + \halign{\hfil##\hfil\cr + #1\cr + \special{em:point \number\father}\cr + \noalign{\vskip5mm} + \hbox{\subtrees#2\endsubtrees}\cr + }% + }% +}% +\def\subtrees#1{\ifx#1\endsubtrees\let\next\relax\else + \vbox{\halign{\hfil##\hfil\cr + \nextpoint + \special{em:point \number\pointnumber}% + \special{em:line \number\pointnumber h,\number\father h}\cr + #1\cr + }}% + \let\next\subtrees\fi + \next +} +\def\labeledtree#1#2{\vbox{\offinterlineskip\halign{\hfil##\hfil\cr + #1\cr + \noalign{\vskip3pt}% + $\scriptstyle#2$\cr +}}} + +\parindent0pt +\raggedbottom + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% macros end here ... sample follows: +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\endinput + +{\labeledtree{% + {\tree{\tn{1}}{% + {\tree{\tn{2}}{% + {\tn{3}}% + {\tn{4}}% + }}% + {\tree{\tn{5}}{% + {\tn{6}}% + }}% + }}% +}{[1,2,2,1,5]}}% + +\bye +------------------ cut here with a sharp knife ------------------------ +-- +Harald Boegeholz |Home: hwb@texnix.stgt.sub.org (read daily) + |University: boegehol@az3.informatik.uni-stuttgart.de + | ^ please use the latter for large (>100k) mails diff --git a/macros/generic/misc/endnote.tex b/macros/generic/misc/endnote.tex new file mode 100644 index 0000000000..6ca4cd8df9 --- /dev/null +++ b/macros/generic/misc/endnote.tex @@ -0,0 +1,36 @@ +% Use \endnote{1}{text}. At the end of your document, type +% \producenotes to actually flush all end notes to be printed. +% +% macros for making endnotes instead of footnotes +% We make @ signs act like letters, temporarily, to avoid conflict +% between user names and internal control sequences of plain format. +\catcode`@=11 +\newbox\endnotebox +\def\setendnotefont#1{\gdef\endnotefont{#1}} +\setendnotefont{\rm} +\def\endnote#1{\let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + #1\@sf\vendnote{{#1}}} +\def\vendnote#1{\global\setbox\endnotebox= + \vbox{\parindent=0pt\endnotefont\unvbox\endnotebox\bgroup + \indent\llap#1\ignorespaces\futurelet\next\aftergroup\no@te\relax}} +\def\no@te{\ifcat\bgroup\noexpand\next \let\next\n@@te + \else\let\next\n@t\fi \next} +\def\n@@te{\bgroup\aftergroup\@endnote\let\next} +\def\n@t#1{#1\@endnote} +\def\@endnote{\strut\egroup} +% +\newcount\enotecounter +\def\resetenotecount{\global\enotecounter=0 } \resetenotecount +\def\setenotecount#1{\global\enotecounter=#1 } +% +\def\setendnoteflagfont#1{\gdef\endnoteflagfont{#1}} +\setendnoteflagfont{\sevenrm} +\def\enote{\unskip + \global\advance \enotecounter by 1 % First bump the counter. + % Now convert the current value of the counter into a superscripted numeral + \endnote{{$^{\hbox{\endnoteflagfont\the\enotecounter}}$}}} +% +\def\producenotes{% +\ifvoid\endnotebox\else\medskip\unvbox\endnotebox\par\fi} +\catcode`@=12 % at signs are no longer letters diff --git a/macros/generic/misc/epigram.tex b/macros/generic/misc/epigram.tex new file mode 100644 index 0000000000..1542c87661 --- /dev/null +++ b/macros/generic/misc/epigram.tex @@ -0,0 +1,20 @@ +% From TeXMaG Volume 2, Number 6 +% Don Hosek. Public domain. +% +\long\def\epigram#1{% We use \long\def to allow the argument + % to span several paragraphs. + \bigskip % extra space above. + \setbox0=\hbox{#1} % put the text into a box + \ifdim\wd0>\critwidth %check the length + \centerline{\vtop{\hsize=\episize\noindent#1}} + % If the length is greater than + % the critical length, make a + % displayed paragraph + \else % otherwise, we just center the text. + \centerline{\box0} + \fi + \smallskip % extra space for the end. +} + +\newdimen\critwidth \critwidth=.75\hsize +\newdimen\episize \episize=.6\hsize diff --git a/macros/generic/misc/fakebold.tex b/macros/generic/misc/fakebold.tex new file mode 100644 index 0000000000..5699b405de --- /dev/null +++ b/macros/generic/misc/fakebold.tex @@ -0,0 +1,5 @@ +\def\fakebold#1{\leavevmode\setbox0=\hbox{#1}% + \kern-.025em\copy0 \kern-\wd0 + \kern .05em\copy0 \kern-\wd0 + \kern-.025em\raise.0433em\box0 +} diff --git a/macros/generic/misc/hep.tex b/macros/generic/misc/hep.tex new file mode 100644 index 0000000000..5a740da239 --- /dev/null +++ b/macros/generic/misc/hep.tex @@ -0,0 +1,12 @@ +\def\slasha#1{\setbox0=\hbox{$#1$}#1\hskip-\wd0\hbox to\wd0{\hss\sl/\/\hss}} +\def\slashb#1{\setbox0=\hbox{$#1$}#1\hskip-\wd0\dimen0=5pt\advance + \dimen0 by-\ht0\advance\dimen0 by\dp0\lower0.5\dimen0\hbox + to\wd0{\hss\sl/\/\hss}} +% Four macros for Dirac's bracket notation of expectation values +\def\bra#1{\left< #1\right|} +\def\ket#1{\left| #1\right>} +\def\bracket#1#2{\left<#1\mid #2\right>} +\def\EV#1#2#3{\bra{#1}#2\ket{#3}} +% And finally a macro for printing so-called `normal ordered' products +% They are denoted by a colon on either side +\normalord#1{\mathopen{:}#1\mathclose{:}} diff --git a/macros/generic/misc/hexdump.sty b/macros/generic/misc/hexdump.sty new file mode 120000 index 0000000000..8d2236a70e --- /dev/null +++ b/macros/generic/misc/hexdump.sty @@ -0,0 +1 @@ +../../latex/contrib/misc/hexdump.sty
\ No newline at end of file diff --git a/macros/generic/misc/inscrutable.tex b/macros/generic/misc/inscrutable.tex new file mode 100644 index 0000000000..1d45298cc6 --- /dev/null +++ b/macros/generic/misc/inscrutable.tex @@ -0,0 +1,11 @@ +% Date: Thu, 7 Feb 91 12:20:50 -0500 +%From: amgreene@ATHENA.MIT.EDU +%Subject: A response to perl hackers +\let~\catcode~`?`\ +\let?\the~`#?~`~~`]?~`~\let]\let~`\.?~`~~`,?~`~~`\%?~`~~`=?~`~]=\def +],\expandafter~`[?~`~][{=%{\message[}~`\$?~`~=${\uccode`'.\uppercase +{,=,%,{%'}}}~`*?~`~=*{\advance.by}]#\number~`/?~`~=/{*-1}\newcount. +=\-{*-}~`-?~`~]-\-~`^?~`~=^{*1}~`\ ?~`~= {.`\ $}~`@?~`~=@{,.,"#`@^$} +.`#*`'$.?~`~0-?~`~$//$^$ .``^$*?~`~$^$.?~`~0-?~`~/$-?~`~^$@*?~`~$ * +?~`~*?~`~*?~`~*?~`~$@-?~`~$ .?~`~0-?~`~-?~`~$.``^$^^$.`<-?~`~*`<$@* +?~`~$*?~`~-`(-`+$%}\batchmode diff --git a/macros/generic/misc/ipamacs.tex b/macros/generic/misc/ipamacs.tex new file mode 120000 index 0000000000..1b935cbbac --- /dev/null +++ b/macros/generic/misc/ipamacs.tex @@ -0,0 +1 @@ +../../../fonts/wsuipa/macros/ipamacs.tex
\ No newline at end of file diff --git a/macros/generic/misc/kbordermatrix.sty b/macros/generic/misc/kbordermatrix.sty new file mode 100644 index 0000000000..67d486929f --- /dev/null +++ b/macros/generic/misc/kbordermatrix.sty @@ -0,0 +1,151 @@ +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{kbordermatrix}[2011/09/21 Bordered matrix with brackets] + +% Author: Kim C Border <kcborder@caltech.edu> +% Date: SuperBowl XXXVII (Go Bucs) + +% Revised 2003/09/20 +% to allow flush right option. +% Revised 2011/09/21 +% at urging of Bruno Calfa (CMU) +% to coexist with package arydshln +% by adding \def\@xarraycr ... + +% Defines \kbordermatrix along the lines of plain tex's +% \bordermatrix (which is still available in LaTeX). + +% In particular, as with \bordermatrix, +% 1. It takes the array as an argument. It does not use \begin{}..\end{}. +% Is this a feature or a bug? +% 2. The first row is spaced a bit further apart from the rest. +% 3. The lower (n-1) by (n-1) block is set off by delimiters. +% 4. There is an invisible bottom row of the same height as the segregated +% top row that adds to the height of the equation. + +% Differences from \bordermatrix: +% 1. Square brackets are used in place of parentheses. +% 2. You may use \\ instead of \cr. +% 3. The line heights agree with LaTeX's line heights for the +% array environment, and \arraystretch is respected. This means +% the bottom (n-1) rows align with the rows of an (n-1)-rowed +% \begin{array}..\end{array} (with or without delimiters). +% 4. All columns are centered. +% ** Modified 2003-9-20 to allow flush right option. +% 5. The first column is spaced a bit further apart from the rest. + + +% Differences from \left\[\begin{array}...\end{array}\right\] +% 1. It takes the array as an argument. It does not use \begin{}..\end{}. +% Is this a feature or a bug? +% 2. Consequently, you cannot use a column specifier (e.g., {l|cr}). +% 3. Consequently the maximum number of columns is not specified. +% 4. Vertical rules must be put in each row in a separate column. +% 5. You can use \hline and \cline. + +% At least it works in the cases I have tried, but I offer no guarantees. + + + +% cf. \bordermatrix p. 361, and \vrulealign p. 392 of The TeXbook + + + +% Style parameters, they may be redefined according to taste. + \newcommand{\kbldelim}{[} % Left delimiter + \newcommand{\kbrdelim}{]}% Right delimiter + + \newcommand{\kbrowstyle}{\scriptstyle}% Style applied to first row + \newcommand{\kbcolstyle}{\scriptstyle}% Style applied to first column + + \newlength{\kbcolsep} % Extra separation after first border column + \newlength{\kbrowsep} % Extra separation after first border row + + \setlength{\kbcolsep}{.5\arraycolsep} + \setlength{\kbrowsep}{.2ex} + + \newif\ifkbalignright + +% Scratch lengths (to be computed) + \newlength{\br@kwd} % Width of delimiter + \newlength{\k@bordht} % Height of border column + +% This is it +\newcommand{\kbordermatrix}[1]{% +\begingroup + % \br@kwd depends on font size, so compute it now. + \setbox0=\hbox{$\left\kbldelim\right.$} + \setlength{\br@kwd}{\wd0} + % Compute the array strut based on current value of \arraystretch. + \setbox\@arstrutbox\hbox{\vrule + \@height\arraystretch\ht\strutbox + \@depth\arraystretch\dp\strutbox + \@width\z@} + % Compute height of first row and extra space. + \setlength{\k@bordht}{\kbrowsep} + \addtolength{\k@bordht}{\ht\@arstrutbox} + \addtolength{\k@bordht}{\dp\@arstrutbox} + % turn off mathsurround + \m@th + % Set the first row style + \def\@kbrowstyle{\kbrowstyle} + % Swallow the alignment into box0: + \setbox0=\vbox{% + % Define \cr for first row to include the \kbrowsep + % and to reset the row style + \def\cr{\crcr\noalign{\kern\kbrowsep + \global\let\cr=\endline + \global\let\@kbrowstyle=\relax}} + % Redefine \\ a la LaTeX: + \let\\\@arraycr + % The following are needed to make a solid \vrule with no gaps + % between the lines. + \lineskip\z@skip + \baselineskip\z@skip + % Compute the length of the skip after the first column + \dimen0\kbcolsep \advance\dimen0\br@kwd + % Here begins the alignment: + \ialign{\tabskip\dimen0 % This space will show up after the first column + \kern\arraycolsep\hfil\@arstrut$\kbcolstyle ##$\hfil\kern\arraycolsep& + \tabskip\z@skip % Cancel extra space for other columns + \kern\arraycolsep\hfil$\@kbrowstyle ##$\ifkbalignright\relax\else\hfil\fi\kern\arraycolsep&& + \kern\arraycolsep\hfil$\@kbrowstyle ##$\ifkbalignright\relax\else\hfil\fi\kern\arraycolsep\crcr + % That ends the template. + % Here is the argument: + #1\crcr}% End \ialign + }% End \setbox0. + % \box0 now holds the array. + % + % This next line uses \box2 to hold a throwaway + % copy of \box0, leaving \box0 intact, + % while putting the last row in \box5. + \setbox2=\vbox{\unvcopy0 \global\setbox5=\lastbox} + % We want the width of the first column, + % so we lop off columns until there is only one left. + % It's not elegant or efficient, but at 1 gHz, who cares. + \loop + \setbox2=\hbox{\unhbox5 \unskip \global\setbox3=\lastbox} + \ifhbox3 + \global\setbox5=\box2 + \global\setbox1=\box3 + \repeat + % \box1 now holds the first column of last row. + % + % This next line stores the alignment in \box2, + % while calculating the proper + % delimiter height and placement. + \setbox2=\hbox{$\kern\wd1\kern\kbcolsep\kern-\arraycolsep + \left\kbldelim + \kern-\wd1\kern-\kbcolsep\kern-\br@kwd + % + % Here is the output. The \vcenter aligns the array with the "math axis." + % The negative vertical \kern only shrinks the delimiter's height. + % BTW, I didn't find this in the TeXbook, + % I had to try various \kerns to see what they did in a + % \left[\vcenter{}\right]. + \vcenter{\kern-\k@bordht\vbox{\unvbox0}} + \right\kbrdelim$} + \null\vbox{\kern\k@bordht\box2} + % + \endgroup +} + diff --git a/macros/generic/misc/laps.tex b/macros/generic/misc/laps.tex new file mode 100644 index 0000000000..b8b2d54b64 --- /dev/null +++ b/macros/generic/misc/laps.tex @@ -0,0 +1,14 @@ +%%% File: Laps.TeX +\catcode`\@=11 % Let's pretend @ is a letter +% Vertical `laps'; cf. \llap and \rlap +\long\def\ulap#1{\vbox to \z@{\vss#1}} +\long\def\dlap#1{\vbox to \z@{#1\vss}} + +% And centered horizontal and vertical `laps' +\def\xlap#1{\hbox to \z@{\hss#1\hss}} +\long\def\ylap#1{\vbox to \z@{\vss#1\vss}} + +% And a `lap' centered on its midpoint +\long\def\zlap#1{\ylap{\xlap{#1}}} + +\catcode`\@=12 % That's enough pretending for one day. diff --git a/macros/generic/misc/letterspacing.tex b/macros/generic/misc/letterspacing.tex new file mode 100644 index 0000000000..d73d9ed533 --- /dev/null +++ b/macros/generic/misc/letterspacing.tex @@ -0,0 +1,319 @@ +% Self-documenting file
+
+\ifx \Comment \Undefined
+ \long \def \Comment #1\EndComment {}
+\else
+ \ifx \EndComment \Undefined
+ \def \EndComment
+ {\message {Error: \noexpand \EndComment encountered
+ without preceding \noexpand \Comment}}
+ \else %%% both defined; let's hope they're the right definitions!
+ \fi
+\fi
+
+\Comment
+This file, "letterspacing.tex", created by Philip Taylor of
+Royal Holloway, University of London (P.Taylor@Rhul.Ac.Uk) for
+Kaveh Bazargan of Focal Image (Kaveh@Focal.Demon.Co.Uk) may be
+freely distributed provided that the following licence conditions
+are honoured :
+\EndComment
+
+\Comment % The Licence
+ Unlimited copying and redistribution of this file
+ is permitted so long as the file is not modified
+ in any way.
+
+ Modifications may be made for private purposes (though
+ this is discouraged, as it could result in documents
+ typesetting differently on different systems) but if
+ such modifications are re-distributed, the modified
+ file must not be capable of being confused with the
+ original. In particular, this means
+
+(a) the filename (the portion before the extension, if any)
+ must not match any of :
+
+ LETTERSPACE LETTER-SPACE
+ LETTERSPACING LETTER-SPACING
+
+ regardless of case, and
+
+(b) the file must contain conditions identical to these,
+ except that the modifier/distributor may, if he or she
+ wishes, augment the list of proscribed filenames.
+\EndComment
+
+\Comment
+As far as is possible, `inaccessible' control sequences (i.e.~control sequences
+containing one or more commercial-at$\,$s) are used to minimise the risk of
+accidental collision with user-defined macros; however, the control sequences
+used to access the natural dimensions of the text are required to be user
+accessible, and therefore must contain only letters.
+\EndComment
+
+%%% Open control sequences
+
+\newdimen \naturalwidth
+\newdimen \naturaldepth
+\newdimen \naturalheight
+
+\Comment
+All control sequences defined hereafter are inaccessible to the casual user,
+including the control sequence used to store the category code of commercial-at;
+this catcode must be saved in order to be able to re-instate it at end of
+module, as we have no idea in what context the module will be |\input|. Having
+saved the catcode of commercial-at, we then change it to |11| (i.e.~that of a
+letter) in order to allow it to be used in the cs-names which follow.
+\EndComment
+
+%%% Concealed control sequences
+
+\expandafter \chardef
+ \csname \string @code\endcsname =
+ \the \catcode `\@
+\catcode `\@ = 11
+
+\Comment
+We will need a a box register in order to measure the natural dimensions of
+the text, and a token-list register in which to save the tokens to be
+letter-spaced.
+\EndComment
+
+\newbox \l@tterspacebox
+\newtoks \l@tterspacetoks
+
+\Comment
+We will need to test whether a particular macro expands to a space, so we will
+need another macro which does so expand with which to compare it; we will
+also need a `more infinite' variant of |\hss|.
+\EndComment
+
+\def \sp@ce { }
+\def \hsss
+ {\hskip 0 pt plus 1 fill minus 1 fill\relax}
+
+\Comment
+Many of the macros will used delimited parameter structures, typically
+terminated by the reserved control sequence |\@nd|; we make this a synonym
+for the empty macro (which expands to nothing), so that should it accidentally
+get expanded there will be no side effects. We also define a brief synonym
+for |\expandafter|, just to keep the individual lines of code reasonably short.
+\EndComment
+
+\let \@nd = \empty
+\let \@x = \expandafter
+
+\Comment
+We will also need to compare a token which has been peeked at by |\futurelet|
+with a space token; because of the difficulty of accessing such a space
+token (which would usually be absorbed by a preceding control word), we
+establish |\sp@cetoken| as a synonym. The code to achieve this is messy,
+because of the very difficulty just outlined, and so we `waste' a control
+sequence |\t@mp|; we then return this to the pool of undefined tokens.
+\EndComment
+
+\let \sp@cetoken = \relax
+\edef \t@mp {\let \sp@cetoken = \sp@ce}
+\t@mp \let \t@mp = \undefined
+
+\Comment
+The user-level macro |\letterspace| has exactly the same syntax as that for
+|\hbox| and |\vbox|, as explained in the introduction; the delimited parameter
+structure for this macro ensures that everything up to the open brace which
+delimits the beginning of the text to be letter-spaced is absorbed as parameter
+to the macro, and the brace-delimited text which follows is then assigned to the
+token-list register |\l@tterspacetoks|; |\afterassignment| is used to regain
+control once the assignment is complete.
+\EndComment
+
+%%% Primary (user-level) macro
+
+\def \letterspace #1#%
+ {\def \hb@xmodifier {#1}%
+ \afterassignment \l@tterspace
+ \l@tterspacetoks =
+ }
+
+\Comment
+Control then passes to |\l@tterspace|, which starts by setting an |\hbox|
+containing the text to be typeset; the dimensions of this box (and therefore
+of the text) are then saved in the open control sequences previously declared,
+and the |\hbox| becomes of no further interest.
+
+A new |\hbox| is now created, in which the same text, but this time
+letter-spaced, will be set; the box starts and ends with |\hss| glue so that if
+only a single character is to be letter-spaced, it will be centered in the box.
+If two or more characters are to be letter-spaced, they will be separated by
+|\hsss| glue, previously declared, which by virtue of its greater degree of
+infinity will completely override the |\hss| glue at the beginning and end;
+thus the first and last characters will be set flush with the edges of the box.
+
+The actual mechanism by which letter-spacing takes place is not yet apparent,
+but it will be seen that it is crucially dependent on the definition of
+|\l@tt@rspace|, which is expanded as the box is being set; the |\@x|
+(|\expandafter|) causes the actual tokens stored in |\l@tterspacetoks| to be
+made available as parameter to |\l@tt@rspace| rather than the token-list
+register itself, as it is these tokens on which |\l@tt@rspace| will operate.
+The |\@nd| terminates the parameter list, and the |{}| which immediately
+precedes it ensures that that there is always a null element at the end of the
+list: without this, the braces which are needed to protect an accent/character
+pair would be lost if such a pair formed the final element of the list, at the
+point where they are passed as the second (delimited) parameter to |\p@rtiti@n|;
+by definition, <TeX> removes the outermost pair of braces from both simple and
+delimited parameters during parameter substitution if such braces form the first
+and last tokens of the parameter, and thus if a brace-delimited group ever
+becomes the second element of a two-element list, the braces will be irrevocably
+lost. The |{}| ensure that such a situation can never occur.
+\EndComment
+
+%%% Secondary (implementation-level) macro
+
+\def \l@tterspace
+ {\setbox \l@tterspacebox = \hbox
+ {\the \l@tterspacetoks}%
+ \naturalwidth = \wd \l@tterspacebox
+ \naturaldepth = \dp \l@tterspacebox
+ \naturalheight = \ht \l@tterspacebox
+ \hbox \hb@xmodifier
+ \bgroup
+ \hss
+ \@x \l@tt@rspace
+ \the \l@tterspacetoks {}\@nd
+ \hss
+ \egroup
+ }
+
+\Comment
+The next macro is |\l@tt@rspace|, which forms the crux of the entire operation.
+The text to be letter-spaced is passed as parameter to this macro, and the
+first step is to check whether there is, in fact, any such text; this is
+necessary both to cope with pathological usage (e.g.~|\letterspace {}|), and to
+provide an exit route, as the macro uses tail-recursion to apply itself
+iteratively to the `tail' of the text to be letter-spaced; when no elements
+remain, the macro must exit.
+
+Once the presence of text has been ensured, the token-list representing
+this text is partitioned into a head (the first element), and the tail
+(the remainder); at each iteration, only the head is considered, although
+if the tail is empty (i.e.~the end of the list has been reached), special
+action is taken.
+
+If the first element is a space, it is treated specially by surrounding it
+with two globs of |\hsss| glue, to provide extra stretchability when compared
+to the single glob of |\hsss| glue which will separate consecutive non-space
+tokens; otherwise, the element itself is yielded, followed by a single glob
+of |\hsss| glue. This glue is suppressed if the element is the last of the
+list, to ensure that the last token aligns with the edge of the box.
+
+When the first element has been dealt with, the macro uses tail
+recursion to apply itself to the remaining elements (i.e.~to the tail);
+|\@x| (|\expandafter|) is again used to ensure that the tail is expanded
+into its component tokens before being passed as parameter.
+\EndComment
+
+%%% Tertiary (implementation-level) macro
+
+\def \l@tt@rspace #1\@nd
+ {\ifx \@nd #1\@nd
+ \let \n@xt = \relax
+ \else
+ \p@rtition #1\@nd
+ \ifx \h@ad \sp@ce \hsss \h@ad \hsss
+ \else
+ \h@ad
+ \ifx \t@il \@nd \else \hsss \fi
+ \fi
+ \@x \def \@x \n@xt \@x
+ {\@x \l@tt@rspace \t@il \@nd}%
+ \fi
+ \n@xt
+ }
+
+\Comment
+The operation of token-list partitioning is conceptually simple: one passes the
+token list as parameter text to a macro defined to take two parameters, the
+first simple and the second delimited; the first element of the list will be
+split off as parameter-1, and the remaining material passed as parameter-2.
+Unfortunately this na\"\i ve approach fails when the first element is a bare
+space, as the semantics of <TeX> prevent such a space from ever being passed as
+a simple parameter (it could be passed as a delimited parameter, but as one
+does not know what token follows the space, defining an appropriate delimiter
+structure would be tricky if not impossible). The technique used here relies
+upon the adjunct macro |\m@kespacexplicit|, which replaces a leading bare space
+by a space protected by braces; such spaces may legitimately be passed as simple
+parameters. Once that operation has been completed, the re-constructed token
+list is passed to |\p@rtiti@n|, which actually performs the partitioning as
+above; again |\@x| (|\expandafter|) is used to expand |\b@dy| (the
+re-constructed token list) into its component elements before being passed as
+parameter text.
+\EndComment
+
+%%% Adjunct macros -- list partitioning
+
+\def \p@rtition #1\@nd
+ {\m@kespacexplicit #1\@nd
+ \@x \p@rtiti@n \b@dy \@nd
+ }
+
+\def \p@rtiti@n #1#2\@nd
+ {\def \h@ad {#1}%
+ \def \t@il {#2}%
+ }
+
+\Comment
+The operation of making a space explicit relies on prescience: the code needs
+to know what token starts the token list before it knows how to proceed.
+Prescience in <TeX> is usually accomplished by |\futurelet|, and this code
+is no exception: |\futurelet| here causes |\h@ad| to be |\let| equal to
+the leading token, and control is then ceded to |\m@kesp@cexplicit|.
+
+The latter compares |\h@ad| with |\sp@cetoken| (remember the convolutions we
+had to go through to get |\sp@cetoken| correctly defined in the first place),
+and if they match (i.e.~if the leading token is a space), then |\b@dy|
+(the control sequence through which the results of this operation will
+be returned) is defined to expand to a protected space (a space surrounded by
+braces), followed by the remainder of the elements; if they do not match
+(i.e.~if the leading token is \stress {not} a space), then |\b@dy| is simply
+defined to be the original token list, unmodified. If the leading token
+\stress {was} a space, it must be replaced by a protected space: this is
+accomplished by |\pr@tectspace|.
+
+The |\pr@tectspace| macro uses a delimited parameter structure, as do most
+of the other macros in this suite, but the structure used here is unique,
+in that the initial delimiter is a space. Thus, when a token-list starting
+with a space is passed as parameter text, that space is regarded as matching
+the space in the delimiter structure and removed; the expansion of the macro
+is therefore the tokens remaining once the leading space has been removed,
+preceded by a protected space |{ }|.
+\EndComment
+
+%%% Adjunct macros -- <space>... -> {<space>}...
+
+\def \m@kespacexplicit #1\@nd
+ {\futurelet \h@ad \m@kesp@cexplicit #1\@nd}
+
+\def \m@kesp@cexplicit #1\@nd
+ {\ifx \h@ad \sp@cetoken
+ \@x \def \@x \b@dy
+ \@x {\pr@tectspace #1\@nd}%
+ \else
+ \def \b@dy {#1}%
+ \fi
+ }%
+
+\@x \def \@x \pr@tectspace \sp@ce #1\@nd {{ }#1}
+
+\Comment
+The final step is to re-instate the category code of commercial-at.
+\EndComment
+
+%%% re-instate category code of commercial-at
+
+\catcode `\@ = \the \@code
+
+\Comment
+Thus letter-spacing is accomplished. The author hopes both that the code will
+be found useful and that the explanation which accompanies it will be found
+informative and interesting.
+\EndComment
diff --git a/macros/generic/misc/longdiv.tex b/macros/generic/misc/longdiv.tex new file mode 100644 index 0000000000..4c9a1d4fd1 --- /dev/null +++ b/macros/generic/misc/longdiv.tex @@ -0,0 +1,53 @@ +% longdiv.tex v.1 (1994) Donald Arseneau +% +% Work out and print integer long division problems. Use: +% \longdiv{numerator}{denominator} +% The numerator and denominator (divisor and dividend) must be integers, and +% the quotient is an integer too. \longdiv leaves a remainder. +% Use this in any type of TeX. + +\newcount\gpten % (global) power-of-ten -- tells which digit we are doing +\countdef\rtot2 % running total -- remainder so far +\countdef\LDscratch4 % scratch + +\def\longdiv#1#2{% + \vtop{\normalbaselines \offinterlineskip + \setbox\strutbox\hbox{\vrule height 2.1ex depth .5ex width0ex}% + \def\showdig{$\underline{\the\LDscratch\strut}$\cr\the\rtot\strut\cr + \noalign{\kern-.2ex}}% + \global\rtot=#1\relax + \count0=\rtot\divide\count0by#2\edef\quotient{\the\count0}%\show\quotient + % make list macro out of digits in quotient: + \def\temp##1{\ifx##1\temp\else \noexpand\dodig ##1\expandafter\temp\fi}% + \edef\routine{\expandafter\temp\quotient\temp}% + % process list to give power-of-ten: + \def\dodig##1{\global\multiply\gpten by10 }\global\gpten=1 \routine + % to display effect of one digit in quotient (zero ignored): + \def\dodig##1{\global\divide\gpten by10 + \LDscratch =\gpten + \multiply\LDscratch by##1% + \multiply\LDscratch by#2% + \global\advance\rtot-\LDscratch \relax + \ifnum\LDscratch>0 \showdig \fi % must hide \cr in a macro to skip it + }% + \tabskip=0pt + \halign{\hfil##\cr % \halign for entire division problem + $\quotient$\strut\cr + #2$\,\overline{\vphantom{\big)}% + \hbox{\smash{\raise3.5\fontdimen8\textfont3\hbox{$\big)$}}}% + \mkern2mu \the\rtot}$\cr\noalign{\kern-.2ex} + \routine \cr % do each digit in quotient +}}} + +\endinput % Demonstration below: + +\noindent Here are some long division problems + +\indent +\longdiv{12345}{13} \quad +\longdiv{123}{1234} \quad +\longdiv{31415926}{2} \quad +\longdiv{81}{3} \quad +\longdiv{1132}{99} \quad +\longdiv{86491}{94} +\bye diff --git a/macros/generic/misc/mandel.tex b/macros/generic/misc/mandel.tex new file mode 100644 index 0000000000..e008dc98f2 --- /dev/null +++ b/macros/generic/misc/mandel.tex @@ -0,0 +1,139 @@ +% TeX Mandelbrot Program +% +% My entry for the contest ``The most useless TeX program ever written''. +% Can anyone top that? (Don't mention MusicTeX in this context. That's not +% meant to be a joke.) +% Also welcome: Improvements of this saving on TeX's resources. This takes +% more than five minutes on my NeXT 486/66.
+%
+% Seb, 6.7.94
+% +% (seb@balu.afp.ruhr-uni-bochum.de) +% +%
+% parameters that you can modify:
+%
+% \x, \y, \xmax, \ymax in units of 10000
+\newcount\x
+\x=-20000 % means -2.000 for real part of start value
+\newcount\y
+\y=-20000 % imaginary part
+\newcount\xmax
+\xmax=20000 % end value, real
+\newcount\ymax
+\ymax=20000 % end value, imaginary
+%
+% calculation depth
+\newcount\mandeldepth
+\mandeldepth=100
+%
+%
+% recursation depth = number of pixels.
+\newcount\xsize % (Don't go wild, tail recursion
+\xsize=100 % uses loads of TeX memory!)
+\newcount\ysize
+\ysize=100
+%
+% picture size
+\newdimen\height
+\newdimen\width
+\height=10cm
+\width=10cm
+%
+% that was all the parameters!
+%
+%
+% pixel size:
+\newdimen\xgrid
+\xgrid=\height
+\divide\xgrid by\xsize
+\newdimen\ygrid
+\ygrid=\width
+\divide\ygrid by\ysize
+%
+\nopagenumbers
+%
+\newcount\stepX % work out step sizes
+\stepX=\xmax
+\advance\stepX by -\x
+\divide\stepX by\xsize
+\newcount\stepY
+\stepY=\ymax
+\advance\stepY by -\y
+\divide\stepY by\ysize
+%
+\def\cout#1{\immediate\write16{#1}} % type out debug message
+%
+\def\yes{Y} % some stupid logical macros
+\def\no{N}
+\def\notyet{x}
+%
+\newcount\u % variables for calculation
+\newcount\v
+\newcount\newV
+\newcount\newU
+\newcount\d
+\newcount\h
+\def\runmandel{% % recursive Mandelbrot macro
+ \newU=\u%
+ \multiply\newU by \u% % newU := u^2
+ \h=\v%
+ \multiply\h by \v% % h := v^2
+ \advance\newU by -\h% % newU := u^2 - v^2
+ \h=\x%
+ \multiply\h by 10000% % h := x * 10000 (normalize)
+ \advance\newU by \h% % newU := newU + h
+ \divide\newU by 10000% % renormalize u
+ \newV=\u%
+ \multiply\newV by \v%
+ \multiply\newV by 2% % newV := 2 *u * v
+ \h=\y%
+ \multiply\h by 10000% % h := y * 10000
+ \advance\newV by \h% % newV := newV + h
+ \divide\newV by 10000% % renormalize v
+ \u=\newU% % newU = u^2 - v^2 + x
+ \v=\newV% % newV = 2 * u * v + y
+ \advance\d by 1%
+ % \cout{d: \the\d, u: \the\u, v: \the\v}%
+ \ifnum\d>\mandeldepth% % member ofthe Mandelbrot set
+ \def\result{\yes}%
+ \fi%
+ \ifnum\u<-20000%
+ \def\result{\no}% % real part exceeded -2
+ \fi%
+ \ifnum\u>20000%
+ \def\result{\no}% % real part exceeded 2
+ \fi%
+ \ifnum\v<-20000%
+ \def\result{\no}% % imaginary part exceeded -2
+ \fi%
+ \ifnum\v>20000%
+ \def\result{\no}% % real part exceeded 2
+ \fi%
+ \if\notyet\result\runmandel\fi% % play it again...
+}%
+\def\result{\yes}%
+\def\makeline{\advance\x by \stepX%
+ %\cout{testing \the\x = i * \the\y}%
+ \u=0%
+ \v=0%
+ \d=0%
+ \def\result{\notyet}%
+ \runmandel% result expands to either yes or no now
+ \if\result\yes%
+ \vrule height \xgrid depth 0pt width \ygrid%
+ \else%
+ \vrule height \xgrid depth 0pt width 0pt\hskip\xgrid%
+ \fi%
+ \ifnum\x<\xmax%
+ \makeline%
+ \else\fi}%
+\def\makepicture{\advance\y by \stepY%
+ \hbox{\makeline}%
+ %\cout{y in makepicture: \the\y}%
+ \ifnum\y<\ymax%
+ \makepicture%
+ \else\fi}%
+\vbox{\offinterlineskip\makepicture} % now, let's go tail
+\bye % recursive!
+
diff --git a/macros/generic/misc/mathlig.tex b/macros/generic/misc/mathlig.tex new file mode 100644 index 0000000000..04194b8493 --- /dev/null +++ b/macros/generic/misc/mathlig.tex @@ -0,0 +1,131 @@ +% +% mathlig.tex +% +% (c) 2001 Jules Bean <jules@jellybean.co.uk> +% Permission is granted to freely use, copy, and distribute +% without restriction. Permission is also granted to distribute +% modified versions and incorporate into your own macro packages +% if a brief acknowledgement is given. +% +% Version 1.0 11 May 2001 + +% Define 'mathmode' ligatures, as in +% +%\mathlig{->}{\rightarrow} +%\mathlig{<-}{\leftarrow} +%\mathlig{<->}{\leftrightarrow} +% +% Works even if they have common prefixes (takes the longest match, +% then backtracks). +% +% Can be used to create ligatures even if the second +% and subsequent characters have weird catcodes, but I don't recommend +% it. + +\count255\catcode`@ +\catcode`@=11 +\chardef\mathlig@atcode\count255 + +% Let or def an 'active' version of a token. Thanks to Donald +% Arseneau and groups.google.com +\def\actively#1#2{\begingroup\uccode`\~=`#2\relax\uppercase{\endgroup#1~}} +% Eat the next token, and then pass control to mathlig@next@cmd +\def\mathlig@gobble{\afterassignment\mathlig@next@cmd\let\mathlig@next= } +% Used to delimit delimited arguments, and ifx tests for emptyness. +\def\mathlig@delim{\mathlig@delim} +% Some macros to help dealing with 'computed names' (csnames). +% Just like def, but first parameter is evaluated as a csname +\def\mathlig@defcs#1{\expandafter\def\csname#1\endcsname} +% A version of \let <normal cs><computed cs> +\def\mathlig@let@cs#1#2{\expandafter\let\expandafter#1\csname#2\endcsname} +% Maintain a 'list' of tokens as a macro which expands to them +\def\mathlig@appendcs#1#2{\expandafter\edef\csname#1\endcsname{\csname#1\endcsname#2}} + +% The main externally visible macro. +% Defines '#1' as a 'ligature' to expand to #2 +% First uses \mathlig@checklig to make sure that all initial segments of +% #1 as set up as ligatures. +% Then sets the ligature #1 to expand to #2. +\def\mathlig#1#2{\mathlig@checklig#1\mathlig@end\mathlig@defcs{mathlig@back@#1}{#2}\ignorespaces} + +% All the @check macros should be idempotent: they set up the definitions +% only if it hasn't already been done. + +%Check #1#2 can be a ligature: +% Check #1 is math-active. +% If not, save the mathcode, set the macros #1 +%Now check the suffix tables with \checkrest +\def\mathlig@checklig#1#2\mathlig@end{% + \expandafter\ifx\csname mathlig@forw@#1\endcsname\relax + \expandafter\mathchardef\csname mathlig@back@#1\endcsname=\mathcode`#1% + \mathcode`#1"8000\actively\def#1{\csname mathlig@look@#1\endcsname}% + \mathlig@dolig#1\mathlig@delim +\fi +\mathlig@checksuffix#1#2\mathlig@end +} + +%Two-part macro. +%Check suffix tables. If #2 is empty, no suffix! +%Otherwise, we make sure #2 is a valid suffix for #1, +%then recurse for #3 on #1#2 +\def\mathlig@checksuffix#1#2\mathlig@end{% +\ifx\mathlig@delim#2\mathlig@delim\relax\else\mathlig@checksuffix@{#1}#2\mathlig@end\fi +} +\def\mathlig@checksuffix@#1#2#3\mathlig@end{% +\expandafter\ifx\csname mathlig@forw@#1#2\endcsname\relax\mathlig@dosuffix{#1}{#2}\fi +\mathlig@checksuffix{#1#2}#3\mathlig@end +} + +% The do macros should not be called more than once for a given ligature. + +% Add #2 to the list of valid suffixes for #1 +% Then make the ligature for #1#2 one which only backtracks, for now +\def\mathlig@dosuffix#1#2{% +\mathlig@appendcs{mathlig@toks@#1}{#2}% +\mathlig@dolig{#1}{#2}\mathlig@delim +} + +% Setup #1#2 so that ligatures beginning #1#2 work. +% Such ligatures will look at what's coming next (in case +% of a longer ligature) and, failing that, +% backtrack to just #1 + +\def\mathlig@dolig#1#2\mathlig@delim{% +%The look macro just \futurelets what's coming up and +%then passes control to forw + \mathlig@defcs{mathlig@look@#1#2}{% + \mathlig@let@cs\mathlig@next{mathlig@forw@#1#2}\futurelet\mathlig@next@tok\mathlig@next}% +%The forw macro uses chck to try all possible suffixes, passing control +%either to one of those, or to the back macro + \mathlig@defcs{mathlig@forw@#1#2}{% + \mathlig@let@cs\mathlig@next{mathlig@back@#1#2}% + \mathlig@let@cs\checker{mathlig@chck@#1#2}% + \mathlig@let@cs\mathligtoks{mathlig@toks@#1#2}% + \expandafter\ifx\expandafter\mathlig@delim\mathligtoks\mathlig@delim\relax\else + \expandafter\checker\mathligtoks\mathlig@delim\fi + \mathlig@next + }% +%The toks macro just stores the suffixes + \mathlig@defcs{mathlig@toks@#1#2}{}% +%The chk macro goes through the suffixes one by one +%tail recursing until it runs out, or finds one. + \mathlig@defcs{mathlig@chck@#1#2}##1##2\mathlig@delim{% + %\message{Lig so far '#1#2', checking for '##1'}% + \ifx\mathlig@next@tok##1% + \mathlig@let@cs\mathlig@next@cmd{mathlig@look@#1#2##1}\let\mathlig@next\mathlig@gobble + \fi + \ifx\mathlig@delim##2\mathlig@delim\relax\else + \csname mathlig@chck@#1#2\endcsname##2\mathlig@delim + \fi + }% +% +% The back macro, defined only if this is a ligature of at least +% two characters, is a default fallback: go back to the previous char. +% (If this is a ligature of only one character, the mathcode will have +% been saved and set as the fallback elsewhere) + \ifx\mathlig@delim#2\mathlig@delim\else + \mathlig@defcs{mathlig@back@#1#2}{\csname mathlig@back@#1\endcsname #2}% + \fi +}% + +\catcode`@\mathlig@atcode diff --git a/macros/generic/misc/nth.sty b/macros/generic/misc/nth.sty new file mode 100644 index 0000000000..8a96c73903 --- /dev/null +++ b/macros/generic/misc/nth.sty @@ -0,0 +1,56 @@ +% nth.sty version 2002/27/02 Donald Arseneau +% Ordinal numbering style, 1st 2nd 3rd 4th 5th... 12th... 101st 102nd... +% +% (Public domain: take, include, extract, whatever) +% +% In LaTeX: +% \usepackage[super,negative]{nth} +% where option [super] gives superscript `th' +% and option [negative] allows ``st, nd, rd'' suffixes on negative numbers. +% +% example: \renewcommand{\thesection}{\ordinal{section}} +% or \renewcommand{\thesection}{\@ordinal\c@section} +% or \renewcommand{\thesection}{\nth\c@section} +% +% In plain TeX: +% \input nth.sty +% use: \nth{<number>}. +% Change formatting by redefining \nthscript and \nthtest + +\def\nth#1{% First print number: + \expandafter\nthM \number #1\relax + \nthscript{% + \ifnum#1\nthtest0 th\else % negatives are all ``th'' (depending on \nthtest) + \expandafter \nthSuff \expandafter 0\number\ifnum #1<0-\fi#1\delimiter + \fi + }} + +% Minus sign using math mode: +\def\nthM#1{\if -#1\ifmmode-\else$-$\fi\else #1\fi} + +% Print suffix depending on last two digits: +\def\nthSuff#1#2#3{% + \ifx \delimiter#3% #1#2 are last two digits + \ifnum #1=1 th% teens are always ``th'' + \else % use appropriate suffix + \ifcase #2 th\or st\or nd\or rd\else th\fi + \fi + \else % continue scanning for last two digits + \expandafter \nthSuff \expandafter #2\expandafter #3% + \fi} + +% Formatting hook for ordinals (\let\nthscript\textsuperscript) +\def\nthscript#1{#1}% alternate: \def\nthscript#1{$\rm^{#1}$} + +% Formatting hook for all negative numbers giving ``th'' +\def\nthtest{<} % alternate: \def\nthtest{=} + +\ifx\Alph\undefined\else + \def\ordinal#1{\expandafter\@ordinal\csname c@#1\endcsname} + \let\@ordinal\nth + \ProvidesPackage{nth}[2002/02/27] + \DeclareOption{super}{\def\nthscript{\textsuperscript}} + \DeclareOption{negative}{\def\nthtest{=}} + \ProcessOptions +\fi + diff --git a/macros/generic/misc/outerhbox.sty b/macros/generic/misc/outerhbox.sty new file mode 100644 index 0000000000..75b618dc9a --- /dev/null +++ b/macros/generic/misc/outerhbox.sty @@ -0,0 +1,86 @@ +% Copyright (c) 2005 Jonathan Fine <jfine@pytex.org> +% License: GPL version 2 or (at your option) any later version. +% $Source: /cvsroot/pytex/pytex/texmacros/outerhbox.sty,v $ + +% $Log: outerhbox.sty,v $ +% Revision 1.2 2005/10/06 07:00:19 jfine +% Added description, as provided to CTAN +% +% Revision 1.1 2005/10/06 06:32:18 jfine +% As posted to comp.text.tex, but \outerhbox instead of \outerbox + +% Collects horizontal mode material into an \hbox, suitable for later +% \unhbox'ing into a paragraph. For use with plain, LaTeX, ConTeXt, etc. + +% Provides \outerhbox, which is roughly similar to \hbox, except that +% material is set in outer horizontal mode. This prevents TeX from +% optimising away math penalties and the like, that are needed when the +% material is \unhbox'ed. + +% Based on code I posted to comp.text.tex + +% Message-ID: <43399D5A.50803@pytex.org> +% Date: Tue, 27 Sep 2005 20:28:26 +0100 +% Newsgroups: comp.text.tex +% Subject: Re: overlong lines in List of Figures +% <http://groups.google.com/group/comp.text.tex/msg/56ea490ad6d13dae> + +\ifx\undefined\outerhbox +\else\endinput\fi + +\ifx \documentstyle \undefined \else + \ifx \documentclass \undefined + \else \ProvidesPackage{outerhbox}[2005/09/29] \fi +\fi + + +\long\def\outerhbox #1% +% like \hbox, but sets material in outer horizontal mode +% #1 - horizontal material, to be set in outer horizontal mode +% Note: inappropriate commands in #1 can cause an \outerhboxerror +{% + \hbox{% + \setbox0 \vbox{% + \hsize\maxdimen + \pretolerance -1 + \rightskip 0pt + \parfillskip 0pt plus 1fil + \noindent #1\endgraf + \global\setbox1 \lastbox + }% + % check that size of \box 0 is 0.0+0.0x0.0 + \ifcase + % skip to \else if any dimension is non-zero + \ifcase\wd0 \else 1 \fi + \ifcase\ht0 \else 1 \fi + \ifcase\dp0 \else 1 \fi + 0 % satisfy the \ifcase + % + % place material into \hbox + \unhbox 1 + \unskip % remove \rightskip glue + \unskip % remove \parfillskip glue + \unpenalty % remove paragraph ending \penalty 10000 + \else + % there's something left in \box 0 + \outerhboxerror % default handler is to be \undefined + \fi + }% +} + +% \endinut % some test code follows + +\tracingall +\tracingonline = 1 +% \nonstopmode + +\setbox 0 \hbox{$2+2=2$} \showbox 0 +\setbox 0 \outerhbox{$2+2=2$} \showbox 0 +{ \leftskip 1in + \setbox 0 \outerhbox{$2+2=2$} \showbox 0 +} + +\setbox 0 \outerhbox{a\par b} \showbox 0 +\setbox 0 \outerhbox{} \showbox 0 +\setbox 0 \outerhbox{\ } \showbox 0 +\end diff --git a/macros/generic/misc/pagereference.tex b/macros/generic/misc/pagereference.tex new file mode 100644 index 0000000000..34ebc44c68 --- /dev/null +++ b/macros/generic/misc/pagereference.tex @@ -0,0 +1,67 @@ +%%%%%%%% PAGEREFERENCE MACROS +% May 2nd, 1994 +% Peter Ungar, 914 723 7187, laxa@acfcluster.nyu.edu +% 109 Lee Road, Scarsdale, N.Y. 10583-5229 +% +\long\def\COMMENT#1!E{} +% +% MACROS BEGIN HERE +\newwrite\inpr +\message{Is this the second pass? (y or n)} +\read16 to\answer +\if n\answer\immediate\openout\inpr=\jobname.pgn% +\def\wrx{\write\inpr}% +\def\plbl*#1*{\wrx{\noexpand\let\csname prec#1\endcsname=\folio}} +\def\pref*#1*{XX} +\fi +\if y\answer\closeout\inpr +\input \jobname.pgn +\def\plbl*#1*{} +\def\pref*#1*{\csname prec#1\endcsname} +\fi +% MACROS END HERE + +\COMMENT + + We use the macros as follow. Suppose you want to refer to a page +where you say something about Pythagoras. Put at the place to +which you want to refer +\plbl*pyth* Where you want to refer to this page, put +\pref*pyth* Here, in the place of pyth, one may use any sequence +of small and capital letters. Since the sequence will end up as +part of a TEX control sequence, digits are unfortunately not +allowed. (If that is very burdensome, we suggest encoding digits +as capitals, A for 1 etc.) In the second pass, the macros insert +a page number where there is a \pref. + + The macro \plbl (pagelabel), as defined when the answer to the +question, Is this the second pass, was n, writes the page number +into the file filename.pgn. To be precise, it creates a new +control sequence, consisting of \prec followed by the letters +identifying the label, which would result in \precpyth in the +example we gave, and sets it equal to the page number. In the +meanwhile, the \pref (page reference) macro is defined to print XX. + For the second pass, we input the file of labels and the page +numbers they signify which we wrote in the first pass. The +pagenumber recording macro +\plbl is redefined as vacuous, and the page reference macro \pref +is set to insert the page number. + +!E + + +This is a test of the page reference macro pair, +$\backslash$plbl (pagelabel) and $\backslash$pref (pagereference) +control sequences. There is a pagelabel command, with no effect on +the tpyeset output, just before the period at the end of this +sentence\plbl*aaa*. + +Reference to the page label on the next page: p.\pref*bb*; +reference to the pgae label on this page: p.\pref*aaa*. +\vfill +\eject Here is a second pagelabel, just before the +period\plbl*bb*. A reference to the first page label: +p.\pref*aaa*, and a reference to the second page page label: +p.\pref*bb*. + +\end diff --git a/macros/generic/misc/patch.doc b/macros/generic/misc/patch.doc new file mode 100644 index 0000000000..92582583a5 --- /dev/null +++ b/macros/generic/misc/patch.doc @@ -0,0 +1,555 @@ +%\iffalse This is patch.doc, and it's -*-LaTeX-*- text +%% patch.doc/patch.tex +%% (c) 1994 by David Kastrup (dak@pool.informatik.rwth-aachen.de) +%% Version 0.91 +%% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either +% version 1.3c 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.3c or later is part of all distributions of +% LaTeX version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `not maintained'. +% +% The work consists of the source file patch.doc +% and the derived file patch.tex +% +% This file is provided marked up according to an early version of LaTeX +% `doc' format markup. Unfortunatly, docstrip for that version of doc is +% no longer available; therefore stripping is to be done by removing all +% lines starting with a single percent sign. +% You may extract a driver file for printing the documentation with +% the doc style package by extracting all lines starting with +% %<+driver>, while removing the %<+driver> directive. +%\fi +% \CheckSum{360} +% \title{Using {\tt patch.tex}} +% \author{David Kastrup\\dak@gnu.org} +% \date{January 22, 1994} +% \maketitle +% \MakeShortVerb\" +% \begin{abstract} +% Often one has the need to use a preestablished format, such +% as~\LaTeX, but with some slight changes to some of the macros. +% Of~course, it is possible to just copy the offendin maco +% definitions into your application or style file, and~modify them +% there. This can lead to parts of your macros being from different +% versions of \LaTeX{} resp.~\TeX. +% +% This input file is a tool for replacing just parts of existing macros +% by user defined parts. If those parts are no longer recognizable, +% an~error message is produced, calling the user to~attention. +% \end{abstract} +% \tableofcontents +% \section{User Interface} +% The macros defined here will allow ``patching'' up already existing +% macros. A~typical example, included from a~style file used for +% typesetting Greek text (to~appear in "kdgreek") is the following: +%\begin{verbatim} +%\input patch.tex +%\ifx\descriptionlabel\undefined\else +%\gpatch\descriptionlabel#1{{#1}}{% +% \bf {\grbf}} \fi +%\ifx\@part\undefined\else +%\gpatch\@part[#1]#2{[#1]{#2}}{% +% \bf\partname~{\grbf\partname\nobreak\ }% +% \bf {\grbf}} \fi +%... +%\endpatch +%\end{verbatim} +%This shows almost all features that are really there. You start by +%inputting "patch.tex". This, among other things, opens a~local +%group in which all of the definitions of~"patch.tex" are read~in. +%In~order not to use up unnecessary hash~space, almost all local +%commands are in the form~"\^^80" and upwards. For this reason, +%you cannot {\em use\/} any macros of yours with such names +%(Note: they are {\em +%not\/} active characters, but rather regular one-letter control +%sequences), and you should not patch them, but you can patch any +%macros containing them, or patch them into macros. +% +%One macro is {\em very\/} special and must not appear in any macro +%you patch, nor in any arguments to~"\patch": this is~"\@ndp@tch". +% +%\DescribeMacro{\patch} +%\DescribeMacro{\gpatch} +%You follow the "\input" by several "\patch" or "\gpatch" +%commands. These commands +%consist of several parts: +%\begin{itemize} +%\item[Optional "\bslash long"] for definition of macros possibly containing +% "\par" tokens in their arguments. Note that the prefixes "\global" +% and~"\outer" are not supported. "\global"ness is achieved by~usage +% of~"\gpatch" as opposed to~"\patch", and is explained later, and +% "\outer" macros are detestable. +%\item ["\bslash patch" or "\bslash gpatch"] To be expected. +%\item [\meta{Argument list}] which is the argument list the macro will +% have in the patched version (usually the same as the original one). +% It~is terminated by the opening brace of +%\item [\meta{Argument replacement}] which is enclosed in braces. This +% is fed as an argument list into the old macro, in order to get the +% replacement text for the new macro. Basically this means that you +% will have to use, say, "{#1}" for an undelimited parameter~"#1", +% "#1@" for a delimited parameter "#1@", and "@$#!?!!" for a brace +% delimited parameter "#1#{" (don't try patching any macros like +% that. Presume you have never heard of~them). +%\item [\meta{Substitution list}] This contains a~brace enclosed list +% of~replacements. Each replacement consists of +% \begin{itemize} +% \item [\meta{Matching sequence}] which is a sequence of tokens not +% containing any braces. If really need to match braces, you can +% match by using implicit braces you get by saying something like +% "\let\openbrace={". If you think of using the default implicit +% braces "\bgroup" and~"\egroup", forget~it. They are used in +% several macros we might want to~patch, and thus are disabled +% by~default. +% \item [\meta{Replacement sequence}] which is enclosed in~braces. +% Again, if you want braces to appear in your replacement, you can +% make that happen by using implicit braces. Matched braces, +% however, you may include explicitly. +% \end{itemize} +%\end{itemize} +%\DescribeMacro{\endpatch} +%Then the patches are followed by~"\endpatch", which closes the group +%opened by~"\input", thus freeing up almost all \TeX{} space +%"patch.tex" took up. Since~mismatched patches can be hard to +%diagnose, "\endpatch" is defined as being~"\outer". As~long as +%the "\outer" nuisance prevails, we~might use it for what it~is +%useful~for. +% +%That's all there is to it! Except for the "\global" issue we promised +%to explain\dots{} +%Usually you will be patching macros of some style, and there will be no +%point in using~"\patch" instead of~"\gpatch". So~mostly "\gpatch" does +%no harm, and will cause a~global definition. "\patch", on the other +%hand, has the problem that its definitions should hold in the group +%ended by~"\endpatch", but not globally. So~"\patch" cannot just make +%the definitions. Instead, it collects the new definitions, and~does +%them all at~"\endpatch". +% +%\DescribeMacro{\globaldefs} +%Here is one friendly feature: If "\globaldefs" is negative, +%"\gpatch"~will invoke "\patch" instead of its own behaviour, so that +%local patches will be performed instead of none at~all (since the then +%non-global definition would disappear at~"\endpatch"). This feature was +%deemed desirable\footnote{Reason: +%I~made an example file showing the effects of several +%"\bslash documentstyle" commands with my Greek macro set. The Greek style +%patched up some \LaTeX{} macros, and this was wanted only +%locally, namely for the length of the demonstration of one particular +%document style.}. +%\subsection{Things to beware of (aka bugs)} +%"patch.doc" is a very simple package (sort~of). It can fail for +%a~number of reasons, and is not applicable in every situation. You +%will have problems if +%\begin{enumerate} +%\item You use implicit tokens which are implicit at the time the +% patches are applied. "\bgroup" and~"\egroup" are explicitly disabled +% for this reason. Implicit spaces will be regarded as explicit ones +% by~"\patch". Implicit macro parameter characters I~am not so sure +% about. \TeX~behaves pretty wierd with regard to them anyhow. Other +% implicits should do no~harm. "\patch"~will take the problematic +% implicit +% tokens for explicit ones while it is analyzing tokens. It analyzes +% both matching and replacement tokens, and all tokens in the original +% macro up to the last replacement performed. This means that, for +% example, matching implicit braces in locations where you did not +% intend it can lead to mismatched explicit braces and lots +% of~confusion. +%\item You use outer tokens in any respect. +% "\patch" does not care for them. +%\item When "\@ndp@tch" appears anywhere, namely in a~macro to be +% patched, or in a matching or replacement sequence. It~is used for +% internal purposes, and you can cause lots of confusion when +% using~it. This means, for one thing, that you should not try +% "\patch"ing up any macros of this package with itself. +%\item And this is harsh: if the macro you patch contains "#" marks +% (which originally were produced by writing "##") these will not be +% reduplicated, leading to missing parameter number errors (which will +% do the right thing if you ignore them, but that's ugly), or to +% recombination with a following number, which is plain wrong. You can +% work around this ugliness in an~ugly way: specify a~replacement +% "#{##}" for any such token. I~am pretty much afraid I~know no +% better way around this one. +%\item Since "\bgroup" and~"\egroup" are disabled, using any macro that +% in turn uses those will not work while in patch~mode. What +% I~guarantee to keep working in future versions is "\let" (locally, +% for making implicit tokens), +% all expandable constructs (like conditionals) not +% using any of the macros of this package, and~"\patch"es. +% Other things are not necessarily supported in patch~mode. +% Specifically, do not use "\def" or~"\gdef", since manipulation of +% localness might unnecessarily be thwarted if you~do. +%\item Do not change "\toks@" in any way, or use a~macro changing it. +% Cannot happen really, if you listen to the last advice. +%\item Do not rely on the patches either taking place or not before the +% final "\endpatch"! This means, do not use a~patched macro before +% "\endpatch" in ways which require specifically the patched or +% the unpatched version. For example, do not patch one and the same macro +% with two separate "\patch" commands in the same patch session! The +% reason for this is the collecting behaviour for non-global patches. +% And you never really know when a~package of yours might come handy +% non-globally. +%\item For similar reasons, +% do not use "\input patch.tex" in a local group when you are doing +% "\gpatch"es (unless you know what you are doing, as in the case of +% negative~"\globaldefs"). It~might get to~being a~problem sometime. +%\item Never set "\globaldefs" to a~non-zero {\em positive\/} value +% while working with~"\patch", since it will interfere disastrously with +% "patch.tex"'s internals, which heavily work with local groups. +% Anyway, "patch.tex" is by its nature intended for local use only. +%\item Just as a note aside: it is a~very bad idea to set "\globaldefs" +% to non-zero values longer than strictly necessary. It is especially +% a~bad idea to set it to a~negative value while {\em typesetting\/} +% anything, +% because the output routine (implicitly enclosed in a~group) will +% never be able to get anything done permanently, and will therefore +% be repeated over and~over. +%\end{enumerate} +% +%Ok, this should be all there really is to it. If I~look that list over +%again, it seems like groups really occupy my fantasy. +% +%Happy "\patch"ing! +%\StopEventually{\PrintIndex} +%\section{The Implementation} +%We begin by opening our local group and making private control +%sequences accessible: +% \begin{macrocode} +\begingroup +\catcode`@=11 +% \end{macrocode} +%We then set "\toks@" to the initial set of~actions to~perform at the +%end of the~patches. +% \begin{macrocode} +\toks@={\endgroup} +% \end{macrocode} +% \begin{macro}{\endpatch} +% Rather simple. "\outer"~seems not to do much harm here. It might +% help better pinpointing severe failures when using~"\patch". +% \begin{macrocode} +\outer\def\endpatch{\the\toks@} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\futuredef} +% This is somewhat similar to "\futurelet", only not at~all. It +% defines the macro which is its first argument as~code which can +% by use of~"\aftergroup" reproduce the third argument~token, +% and after doing that it will call the second argument. +% All~arguments are removed from the input, unlike "\futurelet"'s +% behaviour. +% \begin{macrocode} +\def\futuredef#1#2{\begingroup +% \end{macrocode} +% We do this locally, and set up a few things to do after the +% group. Since a~"\def" is going to finish what we want, we can +% insert the ``do-after'' token via "\afterassignment". +% \begin{macrocode} + \aftergroup\afterassignment \aftergroup#2% + \aftergroup\def \aftergroup#1% + \futurelet\next\^^90} +% \end{macrocode} +% \end{macro} +% We still have the token in our input stream, but also a copy of +% its meaning in "\next". We first try out some cases which will +% not allow us to treat the next token as an undelimited macro +% parameter. Of course we cannot distinguish explicit from implicit +% tokens, but we rely on the user to explicitly unimplicate possibly +% implicit characters. We will do this ourselves with the following +% two ones: +% \begin{macrocode} +\let\bgroup\relax \let\egroup\relax +% \end{macrocode} +% Now we start checking all problematic cases. +% "\^^90" will substitute an appropriate definition given +% explicitly instead of the following token. If we can, however, we +% rather use the token we get. If you wonder about this name, here +% is why: we have to use hosts of macros because of various +% "\futurelet"-like constructions. Patches occur just in a local group, +% and should not permanently require resources. If we did not use +% one-letter control sequences here, the hash table size would be +% somewhat reduced, permanently, because entries never leave the +% hash table. One letter control sequences, however, are not +% hashed, and can disappear without a trace again. +% \begin{macrocode} +\def\^^90{% + \ifcat\noexpand\next{% + \^^91{\aftergroup{\iffalse}\fi}% + \else\ifcat\noexpand\next}% + \^^91{\iffalse{\fi\aftergroup}}% + \else\ifcat\noexpand\next\space + \^^91{\expandafter\aftergroup\space}% + \else\ifcat\noexpand\next## + \^^91{\aftergroup########}% + \else + \let\next\^^93% + \fi\fi\fi\fi\next} +% \end{macrocode} +% "\^^91" is rather simple. We save the definition in +% "\next@", and we'll call upon this after disposing of the next +% token. +% \begin{macrocode} +\def\^^91#1{\def\next@{\endgroup{#1}}% + \let\next\^^92} +\def\^^92{\afterassignment\next@ \let\next= } +% \end{macrocode} +% "\^^93" will actively get the next token, and produce an +% "\aftergroup" definition from that. It is "\long" in case we are +% dealing with a "\par" token. +% \begin{macrocode} +\long\def\^^93#1{\endgroup{\aftergroup#1}} +% \end{macrocode} +% \begin{macro}{\@ndp@tch} +% This is supposed to be used as a delimiter. So that we may +% check for its appearance conveniently, we define it as its own +% "\futuredef" expansion. +% \begin{macrocode} +\def\@ndp@tch{\aftergroup\@ndp@tch} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\gpatch} +% This is it. If you are in doubt as to what the "\def\next{}" is +% supposed to~achieve, this is~easy. We want to detect whether you +% want a~long macro to be~patched. In that case, you say +% "\long\gpatch"\dots. We can figure this out by comparing +% "\next" to the non-long~"\empty". Of course, we do not +% explicitly check for "\outer"ness. You should not even think of +% wanting to make an "\outer" definition. +% +% We start by defining~"\gpatch", which will in the case +% of~disabled "global"ness revert to~"\patch". Both~"\patch" +% and~"\gpatch" define "\next" as a~macro getting one +% "\@ndp@tch"-delimited argument: +% it is all what should appear after a~"\def". +% "\next"~should make all necessary actions for doing +% the~definition. After setting~up "\next", "\^^a0"~is called, for +% which we wrap up the argument list as a~separate argument. +% \begin{macrocode} +\def\gpatch{\ifnum\globaldefs<\z@ + \expandafter\patch + \else + \expandafter\^^98% + \fi} +\long\def\^^98#1#2#{\def\next{}% + \long\edef\next##1\@ndp@tch% + {\ifx\next\empty\else\long\fi\gdef##1}% + \^^a0#1{#2}} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\patch} +% "\patch"~is a~bit more complicated, because we need to~make +% additions to the current "\toks@"~list. +% \begin{macrocode} +\def\patch#1#2#{\def\next{}% + \long\edef\next##1\@ndp@tch + {\toks@ \noexpand\expandafter {\noexpand\the \toks@ + \ifx\next\empty\else\long\fi \def##1}}% + \^^a0#1{#2}} +% \end{macrocode} +% \end{macro} +% +% Now the real fun starts. We get the argument replacement list, +% and the macro body replacement list. We define a~macro~"\^^e0" +% (the "e" means error) just for knowing the proper macro name for +% error messages. +% +% We prepare in a local +% "\toks@" the definition (because we could not simply +% "\aftergroup" the argument replacement, which could consist of +% any number of~tokens). Note that we start yet another group, +% making the definitions of "\toks@" and "\next" stable. +% +% \begin{macrocode} +\long\def\^^a0#1#2#3#4{\begingroup + \def\^^e0{#1}% + \toks@{\endgroup\next#1#2}% + \begingroup + \aftergroup\the\aftergroup\toks@ +% \end{macrocode} +% We collect the replacement in a continually shrinking token list. +% Do not get annoyed, but we'll use "\toks@" for that, too. +% When we are through with replacements, we'll say "\endgroup", +% after which the definition takes place. +% +% The replacement needs +% to be in a token list instead of a macro in order not to break upon +% encountering hash marks. The use of "\toks@" for this does not +% conflict with its other uses due to the grouping. +% +% After that, we are ready to start the fun by expanding our macro, +% and putting~"\p@check" to~work. +% \begin{macrocode} + \toks@{#4}% + \expandafter\p@check\expandafter{#1#3}\@ndp@tch} +% \end{macrocode} +% \begin{macro}{\p@match} +% \begin{macro}{\p@replace} +% These are token lists holding the current string to be matched +% next, and its replacement string. We +% use token lists~1 and~2 for that. +% \begin{macrocode} +\toksdef\p@match=\@ne +\toksdef\p@replace=\tw@ +% \end{macrocode} +% \end{macro} +% \end{macro} +% \begin{macro}{\p@check} +% We check for any remaining replacements. If there are none, we +% may quit. "\toks@"~is the list of +% remaining substitutions. "\endgroup"~stops and makes the +% definition (check~"\^^a0" to~see~why), "\^^a1"~continues. By the +% way, in case of an~error, we will later use~"\next@" in order to +% tell what replacements were not carried out. +% \begin{macrocode} +\def\p@check{\edef\next@{\the\toks@}% + \ifx\empty\next@ \expandafter\endgroup + \else \expandafter\^^a1\fi} +% \end{macrocode} +% \end{macro} +% \begin{macro}{\p@first} +% This sets "\p@first" to the "\futuredef" expansion of the first +% token we want to~match. "\^^a2"~will rewrap the rest of~"\toks@", +% and needs an (as~to~yet) unmatched closing brace for that. +% It~will provide the matching open one by~itself. +% \begin{macrocode} +\def\^^a1{\iffalse{\fi + \expandafter\futuredef \expandafter\p@first + \expandafter\^^a2\the\toks@}} +% \end{macrocode} +% \end{macro} +% Ok, we rewrap the rest to be matched into~"\p@match", and the +% replacement into~"\p@replace", after which we continue with~"\^^a3". +% \begin{macrocode} +\def\^^a2#1#{\p@match{#1}\afterassignment\^^a3\p@replace} +% \end{macrocode} +% The remaining substitutions we repack into~"\toks@". Now we need to +% insert the matching opening brace for the closing one we put~before. +% \begin{macrocode} +\def\^^a3{\afterassignment\^^a4\toks@\expandafter{\iffalse}\fi} +% \end{macrocode} +% We now get the first (or next) token of the original macro. +% \begin{macrocode} +\def\^^a4{\futuredef\next\^^a5} +% \end{macrocode} +% If this token matches~"\p@first", we check the rest in~"\^^a6". We +% collect in~"\toks@" all tokens matched so far (excluding "\p@first"), +% so that we can +% reinsert them if the match cannot be completed successfully. This~is +% done in a~separate group. If~"\next" turns out to +% be~"\@ndp@tch", however, +% this is an~error indication. It~means that the end of patchable +% material was reached. We call then~"\^^e1", which quits in that +% case in a somewhat unusual (but relatively fast) way, reinserting +% the gotten~"\@ndp@tch". +% +% It does not do any harm that "\next" is contained in conditional +% context. Coming from~"\futuredef", it cannot be "\let" to an +% unmatched conditional, and will correctly be~skipped. +% \begin{macrocode} +\def\^^a5{\ifx\next\p@first + \begingroup \toks@{}\expandafter\^^a6% + \else\ifx\next\@ndp@tch \^^e1\fi + \next \expandafter \^^a4% + \fi} +% \end{macrocode} +% In case of an error, we give the original macro (which has not yet +% been patched). And at definition time, we will show how the macro +% looks like afterwards. +% \begin{macrocode} +\def\^^e1{\let\^^a4\endgroup + \newlinechar`\^^J + \toks@\expandafter{\next@}% + \errorcontextlines\m@ne + \errhelp{I am ignoring inapplicable patches. Go on.}% + \errmessage{When trying to patch + \expandafter\string\^^e0, which was defined as^^J% + \expandafter\meaning\^^e0^^J% + the following patches remained inapplicable:^^J% + \the\toks@^^J% + I will show the results of the succeeded patches as soon^^J% + as I can without further comment, so do not be surprised.}% + \aftergroup\show \expandafter\aftergroup\^^e0% +} +% \end{macrocode} +% Ok, we look whether there are any tokens remaining to be matched. If +% there are not, replacement can go~forth. In~that case, we end our +% local group, and go over to~"\^^ac". If~there are, we continue +% with~"\^^a7". +% \begin{macrocode} +\def\^^a6{\edef\next{\the\p@match}% + \ifx\next\empty \endgroup\expandafter\^^ac% + \else \expandafter\^^a7\fi} +% \end{macrocode} +% We get the next token to be matched into~"\next@" from~"\p@match". +% We~will have to adjust "\p@match" again with a token list +% reassignment. For this we need to insert an unmatched closing brace +% after its expansion, which will again be matched later. +% \begin{macrocode} +\def\^^a7{\iffalse{\fi + \expandafter\futuredef\expandafter\next@ + \expandafter\^^a8\the\p@match}} +% \end{macrocode} +% Ok, here we gather the rest into~"\p@match" and~continue. +% \begin{macrocode} +\def\^^a8{\afterassignment\^^a9\p@match\expandafter{\iffalse}\fi} +% \end{macrocode} +% Now we get the next token from the original macro into~"\next". +% \begin{macrocode} +\def\^^a9{\futuredef\next\^^aa} +% \end{macrocode} +% In case of a match, we continue with~"\^^ab". Otherwise, if~we have +% reached the illegal end of~macro ("\next" set to~"\@ndp@tch"), +% we~stop. +% If~we have no match legally, we reinsert~"\p@first", continue +% scanning with~"\^^a4", reinserting everything matched with the help +% of the "\futuredef" generated "\aftergroup"-sequence in~"\toks@". +% This will hapen also if "\@ndp@tch" indicates something went +% haywire, because "\@ndp@tch" cannot be in a~match sequence (if you +% do not put it there, and you are not allowed to). +% this we do also in the case of error, as you can easily see. +% \begin{macrocode} +\def\^^aa{\ifx\next@\next + \expandafter\^^ab% + \else \aftergroup\p@first + \aftergroup\^^a4% + \the\toks@\next\expandafter\endgroup\fi} +% \end{macrocode} +% We now have to append the "\aftergroup" sequence of the next matched +% token in~"\next" to~"\toks@". After that, we can loop. +% \begin{macrocode} +\def\^^ab{\toks@\expandafter\expandafter\expandafter{% + \expandafter\the\expandafter\toks@\next}% + \^^a6} +% \end{macrocode} +% Ok, here follows the code if a~match {\em was\/} completed. We +% insert the tokens of~"\p@replace". We~have to scan "\p@replace" +% token by~token, so that implicit braces work like in the match +% code sequences. We do this until "\p@replace" is exhausted. Which we +% can detect by finding "\@ndp@tch". +% \begin{macrocode} +\def\^^ac{\expandafter\^^ad\the\p@replace\@ndp@tch} +% \end{macrocode} +% The following analysis loop is about as straight as it can get. +% \begin{macrocode} +\def\^^ad{\futuredef\next\^^ae} +\def\^^ae{\ifx\next\@ndp@tch + \expandafter\p@check + \else + \next \expandafter\^^ad% + \fi} +% \end{macrocode} +% We end here by giving the driver file for the documentation, which +% will typically be extracted using~"docstrip.sty". +% \begin{macrocode} +%<+driver>\documentstyle[doc]{article} +%<+driver> \EnableCrossrefs +%<+driver>% \DisableCrossrefs +%<+driver> +%<+driver> \CodelineIndex +%<+driver>\begin{document} +%<+driver> \DocInput{patch.doc} +%<+driver>\end{document} +% \end{macrocode} +%\Finale diff --git a/macros/generic/misc/quotation.tex b/macros/generic/misc/quotation.tex new file mode 100644 index 0000000000..357a113816 --- /dev/null +++ b/macros/generic/misc/quotation.tex @@ -0,0 +1,5 @@ +\def\quotation#1#2{{% An extra group to keep changes to \tabskip local + \tabskip=0pt plus 1fill\let\\=\cr + \halign to\hsize{##\hfil\cr + #1\cr + \hfill#2\crcr}}} diff --git a/macros/generic/misc/ragged.sty b/macros/generic/misc/ragged.sty new file mode 100644 index 0000000000..909de8695c --- /dev/null +++ b/macros/generic/misc/ragged.sty @@ -0,0 +1,781 @@ + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%% ragged.sty by Laurent Siebenmann, March 1996 -- + %% beta version of Mar 30, 1996. + %% Aim: Maintain hyphenation and raggedness control + %% while providing the following for all formats. + %% --- to make a paragraph ragged on left and justified + %% on right, use the syntax + %% \raggedL <paragraph> + %% --- to make a paragraph ragged on both left and right + %% (and symmetric), use the syntax + %% \raggedC <paragraph> + %% \raggedR is essentially equivalent \raggedright of Plain + %% or to \RaggedRight of raggedri.sty of G. Schr"oder. + %% All three \raggedX should give the same linebreaks; they + %% just provide different horizontal positioning of the lines. + %% Documentation of options etc. follows \endinput. + %% Run this file alone to see a demo. + + \ifx\undefined\raggedL\else\expandafter\endinput\fi + + \chardef\raggedcatAT=\catcode`\@ \catcode`\@=11 + + %%temporarily suppress Plain's logging of allocations + \let\R@Gtemp\wlog + \def\wlog#1{\relax} + + \newbox\R@Gvbox + \newbox\R@Ghbox + \newbox\R@Ghbox@ + + \newcount\R@Glinect + + \newskip\R@Gfillskip + + \newdimen\R@Gauxdim + \newdimen\R@Gindentdim + \newdimen\R@Ghsize + \newdimen\raggedStretch + + \raggedStretch=10\p@ %% default + + \newtoks\raggedEnv + \newtoks\raggedEnvOnce + + \let\wlog\R@Gtemp + + \R@Gfillskip=\z@ plus 1fil + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%% Core macros + + \def\R@Gprep{\ifhmode + \errmessage{ Do not use + \noexpand\raggedX commands in horizontal mode}% + \expandafter\par\fi} + + \def\R@Gcore{% + \setbox\R@Gvbox=\vbox\bgroup + \hsize=\maxdimen \leftskip=\z@ + \hskip\z@skip} + + \def\CalcR@GIndent@{% + %% first set \R@Gindentdim to excess of \R@Ghsize over remainder + \R@Gindentdim=\hsize + \advance\R@Gindentdim by -\rightskip + \advance\R@Gindentdim by -\wd\R@Ghbox@ + %% second convert to hang as l,c,r demand + \fixR@Ghang@ %% \R@Gindentdim=.5\R@Gindentdim for \raggedC + }% + + \def\endR@Gcore{\endgraf + \global\R@Glinect=\prevgraf + \global\setbox\R@Ghbox=\lastbox + \egroup % + \ifcase\R@Glinect\relax %% 0 + \or \endR@Gcore@ %% 1 + \else \errmessage{\noexpand\raggedX is failing. + Read about \string\RaggedX}\endR@Gcore@ %% >1 + \fi} + + \def\endR@Gcore@{% + \setbox\R@Gvbox=\vbox{% + \unhcopy\R@Ghbox\unpenalty\unskip\unskip + \endgraf\global\R@Glinect=\prevgraf %\showthe\prevgraf + \global\setbox\R@Ghbox@=\lastbox}% + \setbox\R@Ghbox@=\hbox{% + \unhbox\R@Ghbox@\unpenalty\unskip\unskip}% + \CalcR@GIndent@ %% + \ifdim\R@Gindentdim>\z@ + \hangindent=\R@Gindentdim %\showthe\R@Gindentdim + \else + \hangindent=\z@ + %% Rmk: neg hangindents are from right margin + \fi + \advance\R@Glinect by -1\relax + \hangafter\R@Glinect + \unhbox\R@Ghbox + \endgraf} + + \def\endR@@G{\endR@Gcore\let\par\R@Goldpar\endgroup} + + \def\raggedFrac#1{\def\R@GFrac{#1 }} + + \raggedFrac{1} %% default + + \def\R@GEnv@{% + %\parskip=4pt plus 1pt + %\baselineskip=12pt + %\parfillskip=0pt plus 1fil + %\emergencystretch=20pt + \finalhyphendemerits=20000 % 5000 is Plain default + \parindent=\z@ %% 0 + \pretolerance=\@M %% 10000 + %% end of options easily changeable + %% via \raggedEnv{...} and \raggedEnvOnce{...} + \let\R@Goldpar\par + \let\par\endR@@G + \R@Gauxdim=\hsize + \advance\R@Gauxdim by -\leftskip + \advance\R@Gauxdim by -\rightskip + \R@Ghsize=\R@GFrac\R@Gauxdim + \advance\R@Gauxdim by -\R@Ghsize + \R@GRedefs + \the\raggedEnv + \the\raggedEnvOnce\global\raggedEnvOnce{}% + }% + + \def\R@GRedefs{\let\break\R@Gbreak + \let\vadjust\R@Gvadjust@ + \everydisplay{\R@Geverydisplaymole@}} + + \def\R@Gnono{ is forbidden with \string\raggedX} + \def\R@Gbreak{\errmessage{\noexpand\break\R@Gnono}\penalty-\@M}% + \def\R@Gvadjust@#1{{\tt (USE OF vadjust)}% + \errmessage{\noexpand\vadjust\R@Gnono.\space See output}}% + \def\R@Geverydisplaymole@#1$${$${\tt (DISPLAY)}% + \errmessage{Display math\R@Gnono. See output}}% + + \def\raggedHrule{\unskip\penalty0 + \vrule height0.3\p@ depth-0\p@ width \R@Ghsize \penalty0}% + + %%% \R@GEnv@@ corrects \R@Ghsize if user has modified it + %% through \leftskip, \rightskip via \raggedEnv{...} + %% then does other last minute tasks tasks + \def\R@GEnv@@{% + \R@Ghsize=\hsize + \advance\R@Ghsize by -\leftskip + \advance\R@Ghsize by -\rightskip + \parfillskip=\R@Gfillskip + } + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%% User macros + + %%% \raggedC + \def\raggedC{\R@Gprep\begingroup + \leftskip=1\leftskip \rightskip=1\rightskip + \R@GEnv@ + \advance\leftskip by .5\R@Gauxdim plus .5\raggedStretch + \advance\rightskip by .5\R@Gauxdim plus .5\raggedStretch + \def\fixR@Ghang@{\R@Gindentdim=.5\R@Gindentdim}% + \R@GEnv@@ + \R@Gcore} + + %%% \RaggedC + \def\RaggedC{\R@Gprep\begingroup\let\R@Gcore\relax + \let\R@GRedefs\relax\raggedC + \parfillskip=\z@ + \def\par{\let\par\R@Goldpar\par\endgroup\endgroup}% + } + + % %%% \raggedR@ is strict analog of \raggedR@, \raggedC@ + % %% present for testing only + % \def\raggedR@{\R@Gprep\begingroup + % \R@GEnv@ %% not needed + % \advance\rightskip by \R@Gauxdim plus \raggedStretch + % \def\fixR@Ghang@{\R@Gindentdim=0\p@}% + % \R@GEnv@@ + % \R@Gcore + % } + + %%% \raggedR is more robust then \raggedL, \raggedC as it + %% it allows $$...$$ and \vadjust, \break etc. in paragraph. + \def\raggedR{\R@Gprep\begingroup + \let\R@GRedefs\relax + \R@GEnv@ %% initial part + \advance\rightskip by \R@Gauxdim plus \raggedStretch + \R@GEnv@@ + \def\par{\let\par\R@Goldpar\par\endgroup}% + } + + %%% \RaggedR + \def\RaggedR{\R@Gprep\raggedR + \parfillskip=\z@\relax} + + \def\raggedL{\R@Gprep\begingroup + \R@GEnv@ + \advance\leftskip by \R@Gauxdim plus \raggedStretch + \def\fixR@Ghang@{}% + \R@GEnv@@ + \R@Gcore} + + %%% \RaggedL + \def\RaggedL{\R@Gprep\begingroup\let\R@Gcore\relax + \let\R@GRedefs\relax\raggedL + \parfillskip=\z@ + \def\par{\let\par\R@Goldpar\par\endgroup\endgroup}% + } + + \def\gobble#1{} + + \catcode`\@=\raggedcatAT + + %%%% END INPUT IF THIS IS NOT A DEMO RUN ! + \edef\temp{\csname\jobname\endcsname}% + \edef\Temp{\csname ragged.sty\endcsname}% + \ifx\temp\Temp\else + \expandafter\endinput + \fi + + %%%% END OF MACROS + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%% BEGINNING OF DEMONSTRATION + %%% TESTS FOR \raggedX + + \ifx\documentstyle\undefined + \let\documentstyle\gobble \let\begin\gobble + \fi + \documentstyle{article} + \begin{document} + + \hsize=400pt + + \raggedStretch=1000pt + \RaggedC + THESE ARE TESTS FOR ragged.sty\break + EXPORT THE TESTS BEFORE PLAYING WITH THEM + \bigskip + + \widowpenalty=10000 + \leftskip=0\hsize %plus 10pt + \rightskip=0\hsize %plus 10pt + \raggedStretch=10pt %% 10pt dafault + \raggedFrac{.5} + \raggedEnv{\parskip=4pt plus 3pt + \emergencystretch=20pt + %\pretolerance=100 + } + \parskip=0pt plus 2pt + \parindent=0pt + +\def\TESTTEXT{It is the union of passionate interest in detailed +facts with equal devotion to abstract generalization which forms +the novelty in \hbox{our present society}. } + + \TESTTEXT + + %\raggedEnvOnce{\raggedStretch=0pt} + \raggedL\raggedHrule + % $$dfd$$ %\vadjust{\hrule}% \break + \TESTTEXT + + \raggedL + {\sl A.N. Whitehead} + + \raggedC\raggedHrule\TESTTEXT + + %\raggedEnvOnce{\parskip=0pt} + \raggedC{\sl A.N. Whitehead} + + + \raggedR\raggedHrule\TESTTEXT + + \raggedR +{\sl A.N. Whitehead} + + %\end + %{document} + + %%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%% TESTS FOR \RaggedX + + \raggedStretch=1000pt %% default 10pt %% play with this + \raggedEnv{% + %\linepenalty=0 %% default 50 %% play with this + \parskip=4pt plus 3pt + %\pretolerance=0 %% default 100 + %\hyphenpenalty=0 %% default 50 + } + + \bigskip \hrule \bigskip + + \TESTTEXT + + \RaggedL\raggedHrule\TESTTEXT + + \raggedL +{\sl A.N. Whitehead} + + + \RaggedC\raggedHrule\TESTTEXT + + %\raggedEnvOnce{\parskip=0pt} + \raggedC{\sl A.N. Whitehead} + + + \RaggedR\raggedHrule\TESTTEXT + + \raggedR +{\sl A.N. Whitehead} + +\end +{document} + + %%%% END OF TESTS + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + ***** USER DOCUMENTATION FOR ragged.sty ***** + + + + *** TYPICAL EXAMPLE + + \input ragged.sty + + \raggedFrac{.4} + \raggedEnv{\parskip=4pt plus 3pt} + \raggedL\raggedHrule +I was not a Child~Prodigy, because a Child~Prodigy is +a child who knows as much when it is a child as it +does when it~grows~up. + +\raggedL +{--- Will Rogers} + +The above will produce a quotation that is aligned to the right margin, +ragged on the left and having about .4 the width of a normal line. + + Just compose this file itself to see to see a more extensive +example instantly composed. + + + + *** INTENDED USES + +(i) For "ragged-left-and-flush-right" formatting of short prose +quotations tradionally placed at the end of book chapters. + +(ii) For captions on figures in an artistic page layout. + +(iii) For notes in a left hand margin ragged on the left and aligned +on the right. + + (iv) For "raggedleft" composition of left-hand pages of of narrow +brochures --- matching "raggedright" composition of right hand pages. + + Admittedly, hand specification of linebreaks is often the best +option, and that is how Don Knuth proceeds for use (i) in most of his +books. But in case reformatting for different page sizes or screen sizes +is anticipated, Knuth's alternative should be avoided like the plague; +this should apply to all documents distributed in ".tex" typescript +format. The last 3 applications seem to demand good control on +raggedness and hyphenation. + + + + *** NOVELTY + + It is too early to assert with confidence that ragged.sty offers +genuinely new capabilities in all formats. + + Hopefully \raggedL and \raggedC offer something new even for LaTeX +users. The standard "center" and "flushright" environments of LaTeX do +*roughly* the same thing by a different method. But the macros +\raggedL and \raggedC seem a necessery innovation in case one wants +control on raggedness and/or hyphenation. + + Outside LaTeX, even the offer even the more limited LaTeX features +are little known; thus, particularly sturdy macros \RaggedC and \RaggedL +are also offered by ragged.sty to provide just the LaTeX features in +other formats --- which means all features except raggedness control and +hyphenation. + + + + *** USER CONTROL SEQUENCE SUMMARY + +The \raggedX trio: +\raggedL <paragraph> %% sets paragraph ragged on left justified on right +\raggedC <paragraph> %% sets paragraph ragged on both left and right +\raggedR <paragraph> %% sets paragraph ragged on right justified on left +See also the companion trio \RaggedX below. + +With the default configuration, each of these leaves an arbitrarily +short last line while maintaining some tension on earlier lines +(\raggedStretch=10pt, total raggedness stretch). + +Only the following paragraph is affected by each. + + --- \raggedHrule provides a horizontal line of the ragged text width +if put *immediately after* \raggedX. + + --- \raggedFrac{<decimal fraction>} sets the length of the lines of +the ragged-set paragraphs as a fraction of current line length. +The current line length is + + (\hsize diminished by \leftskip and \rightskip) + + --- \raggedEnv{...} is to be placed before \raggedX; it allows the user +to redefine parameters for the line breaking environment of \raggedX. +Inspect the definition of the internal macro \R@GEnv@ for hints on +which parameters to change. Never change the code in ragged.sty; +your modifications belong in \raggedEnv{...} within your typescripts. + + \raggedEnv{...} and \raggedFrac{...} need not be repeated before +each use of \raggedX. If you want once-only temporary ragged +environment change, you can use grouping or \raggedEnvOnce{...} + + \raggedFrac, \hsize, \leftskip, \rightskip should not appear in the +argument of \raggedEnv; this is roughly because they relate to external +parameters. + + By default, paragraph indentation of the ragged paragraph is +zero. Hyphenation is by default switched off. However +\raggedEnv{\parindent=20pt \pretolerance=100} would change this back +to Plain defaults. + + You may want to adjust the new dimension \raggedStretch, which is +10pt by default. Incidentally, if the total stretch in lines falls +below about 20pt, you may have to add, say \emergencystretch=20pt +inside \raggedEnv{...}. + + In tuning stretch and hyphenation, consider also the following: +\fontdimen3\font=<dimension>, \spaceskip=<skip> and \xspaceskip=<skip>. +Cf. Plain's \raggedright. + + A companion trio \RaggedL, \RaggedC, \RaggedR are simpler, +robuster, and faster macros that perform two services already available +in LaTeX: + + (i) If used with default parameters, they force the last paragraph line +to have roughly the same length as all others. Results are good if +there are many lines. + + (ii) If used with parameter value \raggedStretch=1000pt, they behave +like the competing LaTeX environments with default parameters: lines are +relaxed and filled in natural order. + + + *** INSTALLATION + + For any format, \input ragged.sty will install the package. + + For LaTeX (version 2e), place \usepackage{ragged} in the article header +between \documentclass{...} and \begin{document}. + + + + *** OCCASIONAL PROBLEMS AND THEIR REMEDIES + + \raggedL and \raggedC (not \raggedR and \RaggedX) are only +moderately robust: they work correctly only when the paragraph contents +will form a single line if composed on an "infinitely" long line. +Therefore, they misbehave if they contain *for example* displayed math +or \break or material inserted by \vadjust; and also if the paragraph +exceeds about a page of typing; error warnings are given. + + The most annoying failing is the unavailability of \break; it can +be replaced by \hbox{...} and the tie ~ ; indeed without introducing the +inflexibility which \break does. + + Fortunately such limitations do not much interfere with the use +intended. (Indeed the unavailability of \break is a blessing in +disguise.) + + If difficulty is nevertheless encountered, use the *fast* and +*robust* \RaggedL and \RaggedC where necessary (search out "\Ragged" +instructions and tests!). + + On a given paragraph, all 3 \raggedX should always produce the +*same* linebreaks; any exception is a bug. Similarly for all three +\RaggedX. + + Please report undocumented bugs to lcs@topo.math.u-psud.fr. + + + + *** A TRIVIAL SOLUTION WHEN RAGGEDNESS IS NULL + + Donald Arseneau pointed out (Info-TeX, Sat Mar 9, 1996) that if +left and right margins are justified (i.e. \raggedStretch is zero) then +the last line of paragraphs can be center or right aligned by a simple +"trick" setting as follows: + + *** Center Alignment + + \leftskip=1\leftskip plus 1fil %% use \setlength in LaTeX + \rightskip=-\leftskip + \parfillskip=0pt plus 2fil + + *** Right Alignment + + \leftskip=1\leftskip plus 1fil %% use \setlength in LaTeX + \rightskip=-\leftskip + \parfillskip=0pt plus 1fil + +Donald considers this *well known*; he learned of it first from +Barbara Beeton. + + This device will also work in ragged environments IF AND WHEN +*extended* TeX allows skips to have *both* finite and infinite stretch +-- analogous to ordinals of the form integer + \omega. This is not +yet planned. + + As always in TeX, there may yet be another "deus ex machina"! Time +will tell. + + + + *** WHY USE ragged.sty WITH LATEX? + + LaTeX (in all versions) has the environments "flushleft", "center", +and "flushright" that perform very nearly the services of \RaggedL, +\RaggedC, and \RaggedR. LaTeX also has macros \raggedright and +\raggedleft roughly equivalent to "flushleft" and "flushright" minus +the grouping that goes along with an environment. + + These LaTeX environments/macros perform reliably, and like \RaggedX +do *not* suffer the fragility mentioned above for \raggedX. + + All these LaTeX features are programmed by a mare parameter setting +(cf. programmer documentation below): they simply use the infinite value +1fil for the stretch component of \leftskip and/or \rightskip, and this +permits quite excessive raggedness -- as testing shows. If one just +makes this stretch finite and modest, then the last line becomes +excessively stretched and/or all lines tend to become equal. This matter +seems to have been first recorded and remedied by Jan van der Steen and +Martin Schr\"oder who wrote raggedri.sty (1993) (see CTAN) producing a +macro \RaggedRight more or less equivalent to Plain's \raggedright -- +but no \RaggedCenter nor \RaggedLeft. + + Consequently LaTeX users have reason to use my macros \raggedL and +\raggedC when controlled raggedness is wanted. In addition, I suspect +the ragged.sty syntax will prove helpful in adjusting up width's and +margins. + + Since the competing LaTeX environments are deeply imbricated in +the complicated "list" environment apparatus, I have not attempted to +tinker directly with the LaTeX code to make the new ragged.sty features +a well integrated patch for LaTeX; that is a job for those working on +LaTeX3. + + + + *** HISTORY + + These macros were initially programmed to respond to a request of +Laszlo Battha <battha@apollo.ggki.hu>, Mon Mar 4, 1996 on the Info-TeX +list. + + Laurent Siebenmann + Math'ematique, Bat. 425, + Univ de Paris-Sud, + 91405-Orsay, + France + + + + + + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + ***** PROGRAMMER DOCUMENTATION FOR ragged.sty ***** + + In essence, \RaggedX is a mere parameter setting; indeed, it sets +the stretch components of \leftskip and \rightskip to total +\raggedStretch. What is a miracle preordained by Knuth is that as +soon as \raggedStretch is huge (say 1000pt), while \linepenalty +remains substantial (say 50) all lines but the last are as full as +they can be without puting interword spaces under tension. +Hyphenation occurs only to prevent line length overrun. LaTeX +operates similarly but using infinite stretch. + + In contrast, \raggedL and \raggedC are hopefully original; they +are more devious than outright difficult; what will be more +difficult is to make them work in absolutely all circumstances where +Plain's \raggedright works. They already give perfect typography +or else complain. + + Permit me to set the scene with an overstatement. Analogs of all +three \raggedX exist in every competent wordprocessor since 1984 -- +beginning with MacWrite. However, in TeX (1982) there was an +unfortunate oversight; there should be not just one \parfillskip but +two: \leftparfillskip and \rightparfillskip=\parfillskip. These +should be "skip"s (elastic spaces) inserted at the left and right of +the last line of each paragraph. If these become available (say in +an e-TeX or Omega), one will be able to program \raggedL and +\raggedC by merely setting these parameters along with \leftskip, +\rightskip and a few others. + + This makes it clear that the moderately complicated programming +I have used is just a "workaround". Fortunately it is neither slow +nor bulky. + + Here is the logic of the present programming of \raggedL; it +will be followed by some promising alternatives. + + + + *** CURRENT METHOD (A) + + --- Sweep the paragraph text into \vbox of huge \hsize so that the +paragraph text fits on one line. The use of a \vbox instead of an +\hbox; here is the one recent "breakthrough" involved; it surfaced as a +result of investigations of Barbara Beeton, Michael Downes and Don +Knuth -- in this order! -- see TUGboat 11 (Nov 1991), pages 605--612. + + --- Extract the line as an \hbox and \unhbox it into a \vbox with +the "raggedleft" environment as desired, except for \parfillskip=0pt +plus 1fil where we would really want \leftparfillskip=0pt plus 1fil +and \rightparfillskip=0pt. Here we learn the number of lines in the +paragraph by use of \lastgraph. + + --- We find out the length of the the last line by using \lastbox to +pick off the last \hbox in the above \vbox, and then \unhbox'ing it +into another \hbox stripping off a penalty10000, \rightskip and +\parfillskip (going right to left). + + --- From this, we can calculate the indentation by which to push the +last box right to make it flush with the right margin. + + But we do *not* do that since it entails unpleasant technical +complications related to vertical placement. Instead we more +simply: + + --- unhbox onto the current page (essentially) the first \hbox +encountered above, using the last mentioned environment modified only by +a \hangindent equal to the measured indent, which is scheduled by +\hangafter to intervene on the last line of the paragraph. + + In a real sense the current page receives the final paragraph +just like a normal paragraph. Therefore (hopefully!) no vertical +mode complications will occur. + + Far *more* complex tricks of this sort, *the last one excepted*, are +exploited in Donald Arseneau's shapepar.sty on CTAN. Fortunately, +ragged.sty and shapepar.sty do not compete on the performance +front. + + + + *** ALTERNATIVE METHOD (B) + + This is the method I first attempted in a preliminary "hack" posted +on Info-teX Sat Mar 9, 1996. The raggedleft paragraph can contain +\vadjust and \break since the "one-long-line" requirement of (A) +disappears. + + --- first compose the paragraph \vbox with the ultimately desired +\hsize, \leftskip, \rightskip, but use \parfillskip=0pt plus 1fil. + + --- obtain the relaxed length of the last paragraph line much as +as above, using \lastbox etc. The last line is thus "deleted". + + --- reconstruct the last line as an \hbox to assure the correct +horizontal location. + + --- restore the last line into the \vbox. This requires careful +vertical placement, possibly involving \lastskip, \lastdepth, +\lastpenalty, + + --- \unvbox the corrected \vbox onto the current page. +This again requires careful vertical placement, eg. as regards +space both above and below, penalties etc. + + The last step requires that one be able to perfectly emulate, by +hand as it were, important parts of TeX's paragraph builder. It is by +far a more delicate task than the first method. Donald Arseneau called +it "painful" (Info-TeX, Sat Mar 9, 1996). + + Indentations above *displayed equations* have not been discussed +(but they are in alternative C below); that would redouble complexity. + + + + *** ALTERNATIVE METHOD (C) + + This last alternative is my proposed improvement of the first +method by use of an auxiliary file for storing widths between TeX +jobs and by possible use of two passes on each paragraph. + + This method seems to fully eliminate the failings of \raggedX, +ie. refusal of: displays, \break, \vadjust. Very desirable for a +narrow brochure with left-hand pages composed "raggedleft". But I +have done only fragmentary prototyping. + + Two passes on a paragraph are executed (when that is necessary) +by taking up the whole paragraph in a macro argument, storing it +temporarily in unexpanded token list form, and then rereading it so +that category assignments are those for normal progressive input. +This will be done by fast internal primitives in all versions of +e-TeX. But in Knuth's TeX it requires writing the unexpanded token +list out to a file, with help of the the \meaning primitive and +then rereading. + + An auxiliary file with indentation widths may indicate that a +preliminary pass is unnecessary; thus, on the average, composition +should be very fast. + + --- during a possible preliminary composition of a paragraph one +keeps \parfillskip equal 0pt plus 1fil, and merely records, in the +order of occurrence: + + (a) the widths of remainders on the last line before each display, +using \predisplaysize and a temporary addition to the token list +\everydisplay. + + (b) the width of the remainder on the paragraph's last line. This +is gotten using \lastbox much as in methods (A) or (B). + +Note that \lastbox operates in internal vertical mode, and not in +vertical mode. Hence all preliminary composition is to be done in a +\vbox. This \vbox is discarded once the necessary indentation +information has been extracted --- just as in method (A) but +contrary to method (B). + + --- during final raggedleft composition of a paragraph, the width +information is applied with help from \lastgraf, \hangindent, +\hangafter much as in method (A). + +In this final raggedleft composition of a paragraph, the width +information used may be either from the current job or from a +previous job. But it is always obtained from some preliminary +composition. + + In the case of a paragraph that is composed by \raggedL in a +single pass, it would be highly desirable to have a check that the +composed paragraph is OK; it would for example probably *not* be OK +if changes had intervened there since last composition. The +unavailability of \lastbox in ordinary vertical mode seems to make +a *sure* check difficult. Perhaps one must be content with checks +that are less than sure --- such as variation of the number of +typescript lines occupied by the paragraph as found via +\inputlineno. The user could also signal changes using a syntax like +\raggedL[changed 1647]. Also, \raggedTwoPass in the header could +force slow but sure two-pass treatment. + + + Incidentally, a simple way to make a brochure with left pages +raggedleft and right pages raggedright and *without* altering the +output routine is to compose the brochure twice, once raggedleft +and once raggedright; then one can mix the two at the .dvi (or +postscript) level. + + It is clear that, for such brochures, vertical spacing in and +among paragraphs should be perfectly normal, and identical for +raggedleft and raggedright composition. Method (C) seems to +promise this without pain. + + + + I recommend (C) as next method to program. But I could +be wrong. + + Laurent Siebenmann + Math'ematique, Bat. 425, + Univ de Paris-Sud, + 91405-Orsay, + France + + 30 March 1996 + + diff --git a/macros/generic/misc/random.tex b/macros/generic/misc/random.tex new file mode 100644 index 0000000000..d1a818558b --- /dev/null +++ b/macros/generic/misc/random.tex @@ -0,0 +1,94 @@ +% RANDOM.TEX v.1 (Donald Arseneau) +% Generating "random" numbers in TeX. +% +% Random integers are generated in the range 1 to 2147483646 by the +% macro \nextrandom. The result is returned in the counter \randomi. +% Do not change \randomi except, perhaps, to initialize it at some +% random value. If you do not initialize it, it will be initialized +% using the time and date. (This is a sparse initialization, giving +% fewer than a million different starting values, but you should use +% other sources of numbers if they are available--just remember that +% most of the numbers available to TeX are not at all random.) +% +% The \nextrandom command is not very useful by itself, unless you +% have exactly 2147483646 things to choose from. Much more useful +% is the \setrannum command which sets a given counter to a random +% value within a specified range. There are three parameters: +% \setrannum {<counter>} {<minimum>} {<maximum>}. For example, to +% simulate a die-roll: \setrannum{\die}{1}{6} \ifcase\die... . +% +% If you need random numbers that are not integers, you will have to +% use dimen registers and \setrandimen. For example, to set a random +% page width: \setrandimen \hsize{3in}{6.5in}. The "\pointless" macro +% will remove the "pt" that TeX gives so you can use the dimensions +% as pure `real' numbers. In that case, specify the range in pt units. +% For example, +% \setrandimen\answer{2.71828pt}{3.14159pt} +% The answer is \pointless\answer. +% +% The random number generator is the one by Lewis, Goodman, and Miller +% (1969) and used as "ran0" in "Numerical Recipies" using Schrage's +% method for avoiding overflows. The multiplier is 16807 (7^5), the +% added constant is 0, and the modulus is 2147483647 (2^{31}-1). The +% range of integers generated is 1 - 2147483646. A smaller range would +% reduce the complexity of the macros a bit, but not much--most of the +% code deals with initialization and type-conversion. On the other hand, +% the large range may be wasted due to the sparse seed initialization. + +\newcount\randomi % the random number seed (while executing) +\global\randomi\catcode`\@ % scratch variable during definitions +\catcode`\@=11 + +\def\nextrandom{\begingroup + \ifnum\randomi<\@ne % then initialize with time + \global\randomi\time + \global\multiply\randomi388 \global\advance\randomi\year + \global\multiply\randomi31 \global\advance\randomi\day + \global\multiply\randomi97 \global\advance\randomi\month + \message{Randomizer initialized to \the\randomi.}% + \nextrandom \nextrandom \nextrandom + \fi + \count@ii\randomi + \divide\count@ii 127773 % modulus = multiplier * 127773 + 2836 + \count@\count@ii + \multiply\count@ii 127773 + \global\advance\randomi-\count@ii % random mod 127773 + \global\multiply\randomi 16807 + \multiply\count@ 2836 + \global\advance\randomi-\count@ + \ifnum\randomi<\z@ \global\advance\randomi 2147483647\relax\fi + \endgroup +} + +\countdef\count@ii=2 % use only in boxes! +\ifx\@tempcnta\undefined \csname newcount\endcsname \@tempcnta \fi +\ifx\@tempcntb\undefined \csname newcount\endcsname \@tempcntb \fi + +\def\setrannum#1#2#3{% count register, minimum, maximum + \@tempcnta#3\advance\@tempcnta-#2\advance\@tempcnta\@ne + \@tempcntb 2147483645 % = m - 2 = 2^{31} - 3 + \divide\@tempcntb\@tempcnta + \getr@nval + \advance\ranval#2\relax + #1\ranval +} + +\def\setrandim#1#2#3{% dimen register, minimum length, maximum length + \dimen@#2\dimen@ii#3\relax + \setrannum\ranval\dimen@\dimen@ii + #1\ranval sp\relax +} + +\def\getr@nval{% The values in \@tempcnta and \@tempcntb are parameters + \nextrandom + \ranval\randomi \advance\ranval\m@ne \divide\ranval\@tempcntb + \ifnum\ranval<\@tempcnta\else \expandafter\getr@nval \fi +} + +\def\pointless{\expandafter\PoinTless\the} +{\catcode`p=12 \catcode`t=12 +\gdef\PoinTless#1pt{#1}} + +\catcode`\@=\randomi +\global\randomi=0 +\newcount\ranval diff --git a/macros/generic/misc/rotate-textures.sty b/macros/generic/misc/rotate-textures.sty new file mode 100644 index 0000000000..89454382b6 --- /dev/null +++ b/macros/generic/misc/rotate-textures.sty @@ -0,0 +1,111 @@ +% Rotation of TeX output with TeXtures (and maybe? other PostScript drivers) + +% Written by +% Charles Karney +% Plasma Physics Laboratory Phone: +1 609 243 2607 +% Princeton University MFEnet: Karney@PPC.MFEnet +% PO Box 451 ARPAnet: Karney%PPC.MFEnet@NMFECC.ARPA +% Princeton, NJ 08543-0451 Bitnet: Karney%PPC.MFEnet@ANLVMS.Bitnet + +% User instructions: + +% If you use TeXtures (TeX on the Macintosh), you can rotate portions of TeX +% output by arbitrary angles. In order to accomplish this you need to: + +% (1) Transfer the file TEX$INPUTS:ROTATE.STY to your Macintosh and it in the +% "TeX inputs" folder. +% (2) Specify rotate as an optional argument to \documentstyle, e.g., +% \documentstyle[11pt,rotate]{article} +% (3) Use the construction +% {\rotate{angle}Text-to-be-rotated} + +% Notes: + +% (1) The rotation is made only with TeXtures outputting to a PostScript +% printer (e.g., a LaserWriter). The screen preview and the ImageWriter +% output will show the text unrotated. + +% (2) The rotation angle is measured in degrees. It can be positive or +% negative, real or integer. The best results are obtained when the angle is +% a multiple of 90 degrees. + +% (3) The point about which the text is rotated is the location of the +% \rotate command. In the example above it would be the bottom left corner +% of the initial "T". + +% (4) Normal TeX grouping serves to delimit the scope of the rotation. +% \rotate should always appear in a group. If you want to get all the TeX +% output rotated by 90 degrees, select Landscape mode in the Print Setup +% Dialog. + +% (5) \rotate is effectively a no-op with drivers other than TeXtures. Thus +% you can include \rotate's in a file which you print on the QMS printers. +% In order to get the rotation, however, you must transfer either the TeX +% source or the DVI file to the Mac for printing with TeXtures. + +% (6) The position of the text outside the scope of the rotation is the same +% as if the \rotate command were a no-op. Thus for example +% abc{\rotate{-90}def}ghi +% prints as +% abc ghi +% d +% e +% f + +% (7) Rotations can be stacked, e.g., +% abc{\rotate{-90}def\rotate{-90}ghi}jkl +% would print as +% abc jlk +% d +% e +% f +% ihg +% except that the letters ``def'' would be sideways, and ``ghi'' would be +% upside down. This is to be compared with +% abc{\rotate{-90}def}{\rotate{-90}ghi}jkl +% which prints as +% abc jlk +% d g +% e h +% f i + +% (8) \rotate can be useful in picture environments, e.g., when writing the y +% axis label. E.g., +% \put(-50,100){\rotate{90}\makebox(0,0){$\tan\theta$}} +% Here the \makebox centers the argument at the location of the \put. Thus +% the text is rotated about the bottom-center of $\tan\theta$. + +% Technical details: + +% The following assumptions are made about the PostScript that TeXtures +% generates: +% (1) A single transform is used for all TeXtures output. +% (2) The PostScript \special is bracketed by gsave ... grestore. +% (3) Immediately after the gsave, the coordinate system is translated so the +% origin is at the current point; and the y axis is flipped. +% (4) TeXtures doesn't leave anything on the stack for long periods. (This +% simplifies restoring the default coordinate system.) + +\def\rotate#1{\aftergroup\@unrotate +\special +{postscript + 0 0 transform % Current location in device coordinates. + grestore % Undoes TeXtures gsave. + matrix currentmatrix % Save default transform on stack + 3 1 roll % Put transform at back of current location. + itransform % Current location in TeXtures coords + dup 3 -1 roll % Duplicate the location + dup 4 1 roll exch % x y ==> x y x y + translate % Translate origin to current location. + #1\space neg % Negate angle because of flip of y axis. + rotate % Rotate. + neg exch neg exch translate % Translate origin back. + gsave}} % To match grestore. + +\def\@unrotate{\special +{postscript + grestore % Undoes TeXtures gsave + setmatrix % Restore saved transform + gsave}} % To match grestore + +\endinput diff --git a/macros/generic/misc/ruler.tex b/macros/generic/misc/ruler.tex new file mode 100644 index 0000000000..c35928e6a6 --- /dev/null +++ b/macros/generic/misc/ruler.tex @@ -0,0 +1,656 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Typographic ruler for TeX, version 1.1 +% Copyright Victor Eijkhout 1999 +% file name: ruler.tex +% +% Author: +% Victor Eijkhout +% Department of Computer Science +% University of Tennessee, Knoxville TN 37996 +% +% victor@eijkhout.net +% +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% For a copy of the GNU General Public License, write to the +% Free Software Foundation, Inc., +% 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA, +% or find it on the net, for instance at +% http://www.gnu.org/copyleft/gpl.html +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% This file is identical to an earlier version which was on ctan and +% other archive sites; only the license and copyright information +% has changed. +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +\hsize=14.5cm \vsize=32cm \voffset=-1.5cm +\nopagenumbers \raggedbottom +\overfullrule=0pt +%\tracingoutput=1 +\showboxbreadth=20 \showboxdepth=7 + +\font\tiny=cmr5 \font\ss=cmr8 +\font\big=cmss10 scaled \magstep3 +\font\manual=cmr10 + +%\font\tiny=helv at 5pt \font\ss=helv at 8pt +%\font\big=helv at 16pt +%\font\manual=times at 10pt + +\let\tt=\ss \let\rm=\ss +\parindent=0cm \offinterlineskip +\def\\{\hfill\break} + +\newdimen\margin \margin=.5cm +\newdimen\linewidth \linewidth=0.05mm +\newdimen\scalewidth \scalewidth=6mm \newdimen\magboxwidth +\newdimen\gridheight \gridheight=8cm +\newdimen\rulewidth \rulewidth=\scalewidth +\newdimen\ruleboxheight \ruleboxheight=6mm + +\newbox\magscalenames \newbox\scale \newbox\grid +\newbox\stairs \newbox\ruler +\newcount\ncol \newcount\nrow +\newcount\tempcount \newcount\tempcountb \newcount\tempcounth +\newbox\tempboxa \newbox\tempboxb +\newskip\tempskip \newskip\tempskipb +\newdimen\tempdimen \newdimen\tempdimenb \newdimen\tempdimenc + +\newbox\storea \newbox\storeb \newbox\storec +\newbox\stored \newbox\storee \newbox\storef +\newbox\storeg \newbox\storeh \newbox\storei +\newbox\storej + +\def\gobble#1{} +\def\gobbletwo#1#2{} +\def\gobblethree#1#2#3{} +\def\gobblefive#1#2#3#4#5{} + +\def\hfilll{\hskip 0cm plus 1filll\relax} + +%%%%%%%%%%%%%%%% trace +%\tracingonline=1 +%\tracingmacros=1 + +%%%%%%%%%%%%%%%% auxiliaries +\def\decimala %% #1=getal; a-> 1 plaats achter de komma + #1{{\tempcounth=#1\relax + \tempcountb=\tempcounth + \divide\tempcountb by 10\relax + \number\tempcountb.% + \multiply\tempcountb by 10\relax + \advance\tempcounth by -\tempcountb + \number\tempcounth}} + +\def\decimalb %% #1=getal; b-> 2 plaatsen achter de komma + #1{{\tempcounth=#1\relax + \tempcountb=\tempcounth + \divide\tempcountb by 100\relax + \number\tempcountb.% + \multiply\tempcountb by 100\relax + \advance\tempcounth by -\tempcountb + \ifnum\tempcounth<10 0\fi + \number\tempcounth}} + +\def\hundred#1{{\tempcounth=#1 + \tempcountb=\tempcounth + \divide\tempcounth by 100\relax + \ifnum\tempcounth>0 + \number\tempcounth.\fi + \multiply\tempcounth by 100 + \advance\tempcountb by -\tempcounth + \ifnum\tempcountb<10 0\fi + \number\tempcountb}} + +\def\thousand#1{{\tempcount=#1 \tempcountb=\tempcount + \divide\tempcount by 1000 + \ifnum\tempcount>0 \number\tempcount.\fi + \multiply\tempcount by 1000 + \advance\tempcountb by -\tempcount + \ifnum\tempcountb<100 0\fi + \ifnum\tempcountb<10 0\fi + \number\tempcountb}} + +\def\headedbox %% #1=heading text #2=vbox + #1#2{\vtop{\vbox to 0cm{\vss\setbox0=\hbox to 0cm{\tt #1\hss} \dp0=0cm + \box0 \vskip2pt} + #2}} +\def\boxit#1{\vbox{\hrule + \hbox{\vrule #1\vrule} + \hrule}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%% baseline measurement %%%%%%%%%%%%%%%%%%%%%%%% +\newskip\liftskip +%% what baselineskips are needed? +\def\baselinedist#1{\ifcase#1\or 5\or 6\or 7\or 8\or 9\or 10\or + 11\or 12\or 13\or 14\or 15\or 16\or 17\or + 18\or 20\or 22\or 25\or 30\fi} + +%% first one step in a ladder of baselineskips +\def\baselinebox %% #1=size #2=number label + #1#2{\vbox to #1pt{\vfil + \moveright .5\hsize\vbox{\hrule height \linewidth + width .5\hsize} + \vfil\vbox to 0cm{\vss\hskip2pt\tiny\number#2\vskip\liftskip} + \hrule height \linewidth}} + +%% next a whole ladder of baselineskips +\def\baselinescale %% #1=number of steps #2=point size + #1#2{\ifnum#2<7 \liftskip=0pt \else \liftskip=2pt \fi + \setbox\scale=\vbox{}% + \baselinescalei 1{#1}{#2}% + \edef\tcs{{#2}{\box\scale}}\expandafter\headedbox\tcs} +\def\baselinescalei %% #1=label #2=number of steps #3=point size + #1#2#3{\ifnum#1>#2 \def\tcs{0}\let\next=\gobblethree + \else\tempcount=#1 \advance\tempcount by 1 + \setbox\scale=\vtop{\hsize=\scalewidth + \advance\hsize by -\linewidth + \unvbox\scale + \baselinebox{#3}{#1}}% + \let\next\baselinescalei \edef\tcs{{\number\tempcount}}\fi + \expandafter\next\tcs{#2}{#3}} + +%% finally a grid of ladders of baselineskips +\def\baselinegrid %% #1=number of baseline scales #2=storage box + #1#2{\setbox\grid=\hbox{}% + \setbox#2=\vtop{\hrule height 0pt depth \linewidth + \baselinegridi 1{#1} + \hrule height \linewidth}} +\def\baselinegridi %% #1=current number #2=total number of baseline scales + #1#2{\ifnum#1>#2 \hbox{\vsize=\gridheight \unhbox\grid + \vrule width \linewidth} + \else\tempcount=\gridheight \tempskip=\baselinedist{#1}pt + \divide\tempcount by \tempskip \edef\tcs{{\number\tempcount}} + \setbox\grid= + \hbox{\vsize=\gridheight \unhbox\grid + \vrule width \linewidth + \expandafter\baselinescale\tcs{\baselinedist{#1}}} + \tempcount=#1 \advance\tempcount by 1 \edef\tcs{{\number\tempcount}} + \expandafter\baselinegridi\tcs{#2}\fi} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%% magnified font sizes %%%%%%%%%%%%%%%%%%%%%%%%% +\newcount\honcor +\long\def\bungeltext#1#2{ + \hrule height \linewidth + \kern1mm + \vbox{\hsize=#1\relax \rightskip=0cm plus 1fil + \lineskiplimit=0pt \lineskip=0pt \baselineskip=6pt + \tiny #2\par}} + +\def\magstep#1{\ifcase#1 1000\or 1095\or 1200\or 1440\or 1728\or + 2074\or 2488\fi} +\def\tienstep#1{\ifcase#1 10\or 10.95\or 12\or 14.4\or 17.28\or + 20.74\or 24.88\fi} +\def\zevenstep#1{\ifcase#1 7\or 7.67\or 8.4\or 10.08\or 12.10\or + 14.52\or 17.42\fi} +\def\vijfstep#1{\ifcase#1 5\or 5.48\or 6\or 7.2\or 8.64\or + 10.37\or 12.44\fi} + +\def\magname#1{\ifcase#1 0\or half\or 1\or 2\or 3\or 4\or 5\fi} +\def\cmmagbox#1{{\divide\tempdimen by 1000 + \multiply\tempdimen by \magstep#1% + \tempdimenb=.01mm \tempdimenc=\tempdimen + \divide\tempdimenc by \tempdimenb + \tempcount=\tempdimenc + \edef\next{\the\tempcount}% + \divide\honcor by 1000 + \multiply \honcor by \magstep#1\relax + \tempdimenc=.01pt \divide\honcor by \tempdimenc + \edef\mixt{\the\honcor}% + \edef\next{\noexpand\magbox{\the\tempdimen}{\magname#1}% + {\noexpand\hundred{\next}} + {\noexpand\corrout#1}}\next}} +\def\magbox %% #1=height #2=first text #3=second #4=third + #1#2#3#4{\vtop{\hbox{\vrule width\linewidth + \vbox{\hrule width \magboxwidth height \linewidth + \kern #1}} + \bungeltext\magboxwidth + {#2\par #3\par #4\par} + }} + +\def\magsteps{\vtop{\hbox{\cmmagbox0\cmmagbox1\cmmagbox2% + \cmmagbox3\cmmagbox4\cmmagbox5\cmmagbox6% + \vrule width \linewidth depth 0cm}}} + +\def\magrow %% #1=name #2=unit numerator #3=unit denominator + %% #4=unit size #5=design size #6=store box + #1#2#3#4#5#6{\tempdimen=#4 \divide\tempdimen by #3 + \multiply\tempdimen by #2 + \tempdimenb=#5pt \honcor=\tempdimenb + \ifnum#5=10 \let\corrout\tienstep + \else\ifnum#5=7 \let\corrout\zevenstep + \else \let\corrout\vijfstep \fi\fi + \magboxwidth=\scalewidth \setbox\tempboxa=\magsteps + \setbox\tempboxb= + \vtop{\vbox{\hsize=1.2cm + \lineskiplimit=0pt \lineskip=0pt + \baselineskip=6pt + \def\\{\hfil\break} \tiny #1 + \par \kern1mm} + \setbox0=\hbox{\tiny point size } + \bungeltext{\wd0}{magstep\par + mm \par point size\par}} + \tempdimen=\wd\tempboxa \advance\tempdimen by \wd\tempboxb + \advance\tempdimen by 2mm + \setbox#6= + \hbox to \tempdimen{\box\tempboxa \kern2mm \box\tempboxb}} + +\def\magsizebox %% #1=text + #1{\hbox to 1.5\scalewidth{\hfil \tiny #1\hfil}} + +%%%%%%%%%%%%%%%%%%%%%%%% general magrows %%%%%%%%%%%%%%%%%%%%%%%%%%% + +\def\gmagsteps %% #1=from #2=by #3=to + #1#2#3{\tempcount=#1\relax + {\multiply\tempdimen by \tempcount \tempcountb=\tempdimen + \tempdimenc=.01mm \divide\tempcountb by \tempdimenc + \edef\next{\the\tempcountb}% + \edef\next{\noexpand\magbox{\the\tempdimen}{\the\tempcount}% + {\noexpand\hundred{\next}}{}}% + \next}% + \advance\tempcount by #2% + \ifnum\tempcount=#3\relax\vrule width \linewidth depth 0cm + \else\edef\next{\noexpand\gmagsteps + {\number\tempcount}{#2}{#3}}\next\fi} + +\def\gmagrow %% #1=name #2=unit numerator #3=unit denominator + %% #4=unit size #5=from #6=by #7=to #8=store box + #1#2#3#4#5#6#7#8{\tempdimen=#4 \divide\tempdimen by #3 + \multiply\tempdimen by #2 + \setbox#8=\hbox{\magboxwidth\scalewidth \gmagsteps{#5}{#6}{#7} + \ {} + \vtop{\kern0cm + \setbox0=\hbox{\tiny point size } + \bungeltext{\wd0}{point size\\mm}}}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%% rulers %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\newif\ifleftruler \newdimen\stapje \newdimen\Stap \newdimen\hstapje +\newcount\halfway \newcount\alltheway +\newbox\onerulerbox +\newdimen\vollebreedte \newdimen\vollebreedteplus +\newdimen\overschot \overschot=.75mm + +\def\doalltheway + #1#2#3{#3{#1}\relax + \ifnum#1=#2\relax\else + \tempcount=#1 \advance\tempcount by 1 + \expandafter\doalltheway\expandafter + {\number\tempcount}{#2}{#3}\fi} + +\def\centimeterruler{\Stap=1cm \leftrulerfalse + \vollebreedte=1cm\relax + \def\rulename{centimeter}% + \let\ruledigitfont=\rm + \alltheway=10 \doruler{cm}} +\def\inchruler{\Stap=1in \leftrulertrue + \vollebreedte=1cm\relax + \def\rulename{inch}% + \let\ruledigitfont=\rm + \alltheway=8 \doruler{inch}} +\def\picaruler{\Stap=12pt \leftrulerfalse + \vollebreedte=1cm\relax + \def\rulename{pica}% + \let\ruledigitfont=\tiny + \alltheway=6 \doruler{pica}} +\def\rulerpiece + #1{\vbox to \stapje{\vfil \rulerhalfline \vfil \rulerline{#1}}} +\def\rulerline %% streepje over aantal mm; halfweg volle breedte + #1{\ifnum#1=\halfway \tempskipb=\vollebreedteplus + \else \tempskipb=#1\hstapje + \advance\tempskipb by \overschot \fi + \hbox to \vollebreedteplus + {\maybeleft \vrule width\tempskipb height\linewidth + \mayberight }} +\def\rulerhalfline + {\tempskipb=.5\hstapje \advance\tempskipb by \overschot + \hbox to \vollebreedteplus + {\maybeleft\vrule width\tempskipb height\linewidth + \mayberight}} +\def\rulerbox %% #1=label + #1{\vbox to 0cm{\kern.75mm\relax %was .5\stapje + \hbox to \vollebreedteplus + {\mayberight + \kern.75mm\ruledigitfont + #1\kern.75mm + \maybeleft} + \vss} + \copy\onerulerbox} +\def\makerulerbox{\global\setbox\onerulerbox= + \vbox to \Stap{\vbox to 0cm + {\hbox{\ifleftruler\kern\overschot\fi + \kern.5\vollebreedte + \vrule depth \Stap width\linewidth} + \vss} + \doalltheway1{\alltheway}{\rulerpiece} + \vss}} +\def\doruler %% #1=unit name #2=length #3=storage box + #1#2#3{\ifleftruler \let\maybeleft\relax \let\mayberight\hfil + \else \let\maybeleft\hfil \let\mayberight\relax + \fi + \bgroup \halfway=\alltheway \divide\halfway by 2\relax + \stapje=\Stap \divide\stapje by \alltheway + \hstapje=\vollebreedte \divide\hstapje by \alltheway + \vollebreedteplus=\vollebreedte + \advance\vollebreedteplus by \overschot + \makerulerbox + \setbox\ruler=\vbox{\hrule width \vollebreedteplus height\linewidth}% + \doruleri 0{#2}\relax + \global\setbox\ruler= + \hbox{\ifleftruler\else\vrule width\linewidth\fi + \box\ruler + \ifleftruler \vrule width\linewidth \fi}% + \xdef\tcs{{#1}{\box\ruler}}\egroup + \setbox#3\expandafter\headedbox\tcs} + \def\doruleri + #1#2{\ifnum#1>#2 \let\next=\gobbletwo \def\tcs{0}% + \else \setbox\ruler= + \vtop{\unvbox\ruler\rulerbox{#1}}% + \let\next=\doruleri + \tempcount=#1\relax \advance\tempcount by 1 + \edef\tcs{{\number\tempcount}}\fi + \expandafter\next\tcs{#2}} + +%%%%%%%%%%%%%%%%%%%%%%%%%% paper size %%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\papersize#1#2{\vtop + {\kern0cm\vbox to #2{ + \vbox to #1{\vfil\hrule width 2mm height 0cm depth \linewidth} + \vfil\hrule width 2mm height 0cm depth \linewidth}}} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%% rule thickness %%%%%%%%%%%%%%%%%%%%%%%%%% +\newdimen\rulelength \rulelength=.75\scalewidth +\newdimen\interruleskip \interruleskip=.5\scalewidth + +\def\ruleboxh %% #1=rule thickness #2=label + #1#2{\setbox\tempbox= + \vbox{\hsize=\rulewidth + \vfill \vskip10pt \hbox{\tiny \rulenum{#2}} + \vskip1pt \hrule height #1 width \rulewidth}% + \ifdim\ht\tempbox<\ruleboxheight + \vbox to \ruleboxheight{\unvbox\tempbox}% + \else\box\tempbox\fi} +\def\ruleboxv %% #1=rule thickness #2=label + #1#2{\vtop{\kern0cm + \hbox{\hbox to 5mm{\tiny \hfil \rulenum{#2}\kern1mm}% + \vrule height \rulelength width #1} + \kern \interruleskip}} +\let\rulebox=\ruleboxv +\def\rulestackhead %% #1=minimal label #2=label step + %% #3=minimal dimen #4=dimen step + %% #5=maximal label #6=storage box #7=header + #1#2#3#4#5#6#7{\setbox\scale=\vbox{}% + \rulestacki{#1}{#2}{#3}{#4}{#5}% + \setbox#6=\headedbox{#7}{\box\scale}} +\def\rulestack %% #1=minimal label #2=label step + %% #3=minimal dimen #4=dimen step + %% #5=maximal label #6=storage box + #1#2#3#4#5#6{\setbox\scale=\vbox{}% + \rulestacki{#1}{#2}{#3}{#4}{#5}% + \setbox#6=\box\scale} +\def\rulestacki %% #1=curr label #2=label step + %% #3=curr dimen #4=dimen step #5=total dimen + #1#2#3#4#5{\ifnum#1>#5% + \setbox\scale= + \vtop{\unvbox\scale \setbox0=\lastbox}% + \let\next=\gobblefive \def\tcs{0}% + \else \setbox\scale= + \vtop{\unvbox\scale + \rulebox{#3}{#1}}% + \tempskip=#3\relax \advance\tempskip by #4\relax + \tempcount=#1\relax \advance\tempcount by #2\relax + \let\next=\rulestacki + \edef\tcs{{\number\tempcount}}\fi + \expandafter\next\tcs{#2}{\tempskip}{#4}{#5}} + + +%%%%%%%%%%%%%%%%%%%%%%%%%% conversion table %%%%%%%%%%%%%%%%%%%%%%%% +\def\num{\ss\enspace\hfill} +\def\me#1{\ifcase#1\relax\or pt\or pc\or dd\or cc\or bp\or mm\or in\fi} +\def\table{\halign{\strut\hbox to 1cm{\tt##\hfil}\vrule\enspace + &\num##&\num##&\num##&\num##&\num##&\num##&\num##\cr + \hfill&\tt \me1&\tt \me2&\tt \me3&\tt \me4&\tt \me5&\tt \me6&\tt \me7\cr + \noalign{\hrule} + \me1&1&.0833&&&&.351&.0138\cr + \me2&12&1&&&&4.218&.166\cr + \me3&&&1&.0833&&.376&.0148\cr + \me4&&&12&1&&4.513&.1777\cr + \me5&&&&&1&.383&.0139\cr + \me6&2.845&.237&2.659&.222&2.835&1&.0394\cr + \me7&72.27&6.0225&67.54&5.628&72&25.4&1\cr + }} +%%%%%%%%%%%%%%%%%%%%%%%%%% the whole sheet %%%%%%%%%%%%%%%%%%%%%%%%% + +\def\opskip{\vskip.5mm\relax} +\let\neerskip\opskip + +\output{} + +\begingroup\hsize=12cm \vsize=8in +\parindent=0pt \parskip=6pt +\rightskip=0cm plus 5cm \normalbaselines + +\hbox{}\vskip3cm +\big The \TeX\ ruler + +\manual +This is the \TeX\ ruler, a measuring device for +typographical designers working with \TeX. It includes ordinary +rulers in inches, centimeters, and picas. +It can be used to measure font sizes, baseline distances, +and rule weights. The design is based on a ruler +by Inge~Eijkhout, implementation in \TeX\ is by +Victor~Eijkhout. + +The \TeX\ ruler is shareware, distributed under the GNU Public License. +If you want to show your appreciation, send a contribution +to the address below. + +How to format and print this file + +This file will give you three pages. Most likely the second one +cannot be handled by your printer, but I've included it for +completeness. At the top of the source file, 3 fonts are +declared. Please change the CM fonts to something more pretty, +eg Helvetica. + +How to use the \TeX\ ruler + +Rulers. Use them like ordinary rulers. It is suggested +that you print the \TeX\ ruler on transparent plastic and +cut the edges along the rulers. + +Baseline distances. Put the top line along the baseline +of some line of text. Then see in what column the other +lines of text line up. + +Font sizes: cap height. Take an uppercase letter +such as `K' or `H'. Find the line with its font name, +or use the first line. See what box on that line +it fits in best, with the character completely between +the lines. Read out the magnification and size of the +font. Alternately check on all lines which box fits +best, then read out the size. + +General remark: all lines have a width of .05 millimeter. +This is less than the dot width of a 300dpi +laser printer, so beware of some inaccuracies. +Also your printer driver may introduce +inaccuracies. + +\leavevmode +{\obeylines \parskip=0pt % +Victor Eijkhout +Department of Computer Science +University of Tennessee +Knoxville, TN 37996 +USA\par {\tt victor@eijkhout.net}} + +\vfil +Copyright 1990-99 by Victor Eijkhout +\eject +\endgroup + +\endlinechar-1 + +\def\BigSheet{\leavevmode +\leftrulertrue \inchruler{11}{\storea} +\box\storea +\papersize{8.5in}{11in} +% +\vtop{ + \baselinegrid{18}\storea \box\storea + \kern1mm + \moveright2mm + \vbox{\hbox{\ss Baseline distances} + \neerskip \hrule} + \kern5mm + % + \moveright2mm + \hbox{ + \vtop{\vbox{\hrule \opskip \hbox{\ss Cap heights}} + \kern-3mm + \def\a{\kern2mm} + \magrow{cmr10\\cmbx10\\cmss10\\cmmi10}{250}{36}{1pt}{10}\storec + \magrow{cmtt10\\cmff10}{220}{36}{1pt}{10}\stored + \magrow{cmr7\\cmbx7\\cmmi7}{175}{36}{1pt}7\storee + \magrow{cmr5\\cmbx5\\cmmi5}{125}{36}{1pt}5\storef + \vbox{\a\box\storec \a\box\stored + \a\box\storee \a\box\storef} + % + \gmagrow{cmr10}{25}{36}{1pt}51{14}\storec + \gmagrow{cmr10}{25}{36}{1pt}{15}1{24}\stored + \gmagrow{cmr10}{25}{36}{1pt}{26}2{44}\storee + \gmagrow{cmr10}{25}{36}{1pt}{46}2{64}\storef + \vbox{\a\box\storec \a\box\stored + \a\box\storee \a\box\storef} + % + \leftrulertrue \picaruler{19}{\storea} + \setbox\storeb=\vtop{\kern0cm + \def\a{}%{\moveright1cm} + \a\vbox{\hrule \opskip + \hbox{\strut\ss Conversion of units}} + \kern2mm + \halign{\vrule height8pt depth3pt width0pt + \ss##\ &${}={}$\hfil\ \ss##&$\,$##\cr + 1{\tt in}& 72.27&{\tt pt}\cr + 1{\tt in}& 72&{\tt bp}\cr + 1{\tt in}& 25.4&{\tt mm}\cr + 1157{\tt dd}& 1238&{\tt pt}\cr + 1{\tt pt}& 65536&{\tt sp}\cr} + \kern2mm \table + \kern8mm + \hbox{\hskip1cm \big The \TeX\ Ruler} + \kern2pt + \hbox{\hskip1cm \tiny Design:\ {} + Inge and Victor Eijkhout 1990--96}} + \kern4mm + \hbox{\box\storea \kern2mm \box\storeb} + }%end of \vtop + \kern-1cm + \vtop{\vbox{\hrule \opskip \hbox{\ss Rule weights}} + \kern5mm + \let\rulenum=\decimalb + \rulestackhead{5}{5}{0.05mm}{0.05mm}{100}\storeg{mm} + \rulestack {100}{25}{1mm}{0.25mm}{525}\storeh + \let\rulenum=\decimala + \rulestackhead{5}{5}{.5pt}{.5pt}{151}\storei{pt} + \hbox{\box\storeg \kern3mm \box\storeh \kern3mm \box\storei} + }%end of second \vtop + }%end of \hbox + } +% +\kern2mm\relax +\leftrulerfalse \centimeterruler {29}{\storea} +\papersize{21cm}{29.7cm} +\box\storea +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\def\smallsheet{\leavevmode +\leftrulertrue \inchruler{9}{\storea} +\box\storea \kern2mm +% +\vtop{ + \baselinegrid{18}\storea \box\storea + \kern1mm + \moveright2mm + \vbox{\hbox{\ss Baseline distances} + \neerskip \hrule} + \kern5mm + % + \moveright2mm + \hbox{ + \vtop{\vbox{\hrule \opskip \hbox{\ss Cap heights}} + \kern-3mm + \def\a{\kern2mm} + \magrow{cmr10\\cmbx10\\cmss10\\cmmi10}{250}{36}{1pt}{10}\storec + \magrow{cmtt10\\cmff10}{220}{36}{1pt}{10}\stored + \magrow{cmr7\\cmbx7\\cmmi7}{175}{36}{1pt}7\storee + \magrow{cmr5\\cmbx5\\cmmi5}{125}{36}{1pt}5\storef + \vbox{\a\box\storec \a\box\stored + \a\box\storee \a\box\storef} +% + \leftrulertrue \picaruler{19}{\storea}%\showbox\storea + \setbox\storeb=\vtop{\kern0cm + \def\a{}%{\moveright1cm} + \a\vbox{\hrule \opskip + \hbox{\strut\ss Conversion of units}} + \kern2mm + \halign{\vrule height8pt depth3pt width0pt + \ss##\ &${}={}$\hfil\ \ss##&$\,$##\cr + 1{\tt in}& 72.27&{\tt pt}\cr + 1{\tt in}& 72&{\tt bp}\cr + 1{\tt in}& 25.4&{\tt mm}\cr + 1157{\tt dd}& 1238&{\tt pt}\cr + 1{\tt pt}& 65536&{\tt sp}\cr} + \kern2mm \table + \kern8mm + \hbox{\hskip1cm \big The \TeX\ Ruler} + \kern2pt + \hbox{\hskip1cm \tiny Design:\ {} + Inge and Victor Eijkhout 1990--96}} + \kern4mm + \hbox{\box\storea \kern2mm \box\storeb} + }%end of \vtop + \kern-1cm + \vtop{\vbox{\hrule \opskip \hbox{\ss Rule weights}} + \kern5mm + \let\rulenum=\decimalb + \rulestackhead{5}{5}{0.05mm}{0.05mm}{50}\storeg{mm} + \rulestack {50}{10}{.5mm}{0.1mm}{160}\storeh + \let\rulenum=\decimala + \rulestackhead{5}{5}{.5pt}{.5pt}{101}\storei{pt} + \hbox{\box\storeg \kern3mm \box\storeh \kern3mm \box\storei} + }%end of second \vtop + }%end of \hbox + } +% +\kern2mm\relax +\leftrulerfalse \centimeterruler {23}{\storea} +\box\storea +} + + +\count0=2 +\BigSheet +\vfill\eject +\count0=3 +\smallsheet + +\end +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% diff --git a/macros/generic/misc/selectpage.tex b/macros/generic/misc/selectpage.tex new file mode 100644 index 0000000000..5a1405d3c4 --- /dev/null +++ b/macros/generic/misc/selectpage.tex @@ -0,0 +1,30 @@ +%From Tugboat volume 8, number 2 july 1987 +%by Donald Knuth +% +% The idea is to make TeX look for a file called pages.tex. if such a +%file doesn't exit, everything works as before, Otherwise the file +%should contain a list of apge numbers, one per line, in the order that +%they will be generated. After the last page number has been matched, +%all further pages will be printed. Thus, if you want ot print pages +%123 and all pages from 300 onwards, your file pages.tex should say +% 123 +% 300 +%but if you want to print pages 123 and 300 only, the file should say, +%e.g., +% 123 +% 300 +% -99999999999 % impossible number +%so that the end of file will never occur. +% + +\let\Shipout=\shipout +\newread\pages \newcount\nextpage \openin\pages=pages +\def\getnextpage{\ifeof\pages\else + {\endlinechar=-1\read\pages to\next \ifx\next\empty % in this case we +should have eof now \else\global\nextpage=\next\fi}\fi} +\ifeof\pages\else\message{OK, I'll ship only the requested pages!} + \getnextpage\fi +\def\shipout{\ifeof\pages\let\next=\Shipout + \else\ifnum\pageno=\nextpage\getnextpage\let\next=\Shipout + \else\let\next=\Tosspage\fi\fi \next} +\newbox\garbage \def\Tosspage{\deadcycles=0\setbox\garbage=} diff --git a/macros/generic/misc/shadebox.tex b/macros/generic/misc/shadebox.tex new file mode 100644 index 0000000000..da352d44b4 --- /dev/null +++ b/macros/generic/misc/shadebox.tex @@ -0,0 +1,171 @@ +%% Save file as: SHADEBOX.TEX Source: FILESERV@SHSU.BITNET
+%% Author: Leo@vaxc.cc.monash.edu.au
+%% Original Source: Posted by Jim Hefferon <HEFFERON@SMCVAX.BITNET> to
+%% INFO-TeX on Thu, 16 Jan 1992 11:21 EST
+
+%% Small (and subtle) bug correction on 25 July 2002
+%% by Danilo {\v S}egan <mm01142@alas.matf.bg.ac.yu>
+%%
+%% The mysterious factor of 65782 is number of sp in 1bp, or 1bp/1pt * 65536.
+%% 1pt - printer point 1/72.27"
+%% 1bp - ps point aka bigpoint 1/72"
+%% 65536 - a number of TeX's scaled points (sp) in 1pt.
+%%
+%% The other solution is to use temporary registers for dividing all
+%% dimensions by 1bp, but who would want to do that?
+
+
+%----------------------------------------------------------------------------
+\newbox\graybox
+\newdimen\xgrayspace
+\newdimen\ygrayspace
+%----------------------------------------------------------------------------
+%
+% The following \TeX code was based on previous work by
+%
+% Je'ro^me Maillot, maillot@bora.inria.fr
+%
+%----------------------------------------------------------------------------
+%
+% Use the following for one or more words within a line.
+%
+\def\textshade#1#2{%
+ \xgrayspace=4pt%
+ \ygrayspace=4pt%
+ \def\grayshade{0.95}%
+ \def\linewidth{1}%
+ \def\theradius{5}%
+ \setbox\graybox=\hbox{\surroundboxa{#2}}%
+ \hbox{%
+ \hbox to 0pt{%
+ \special{"gsave newpath 0 0 moveto %
+ 0 1 copy /xmin exch store %
+ \number\dp\graybox \space -65782 div 1 copy /ymin exch store %
+ \number\wd\graybox \space 65782 div 1 copy /xmax exch store %
+ \number\ht\graybox \space 65782 div 1 copy /ymax exch store %
+ \theradius\space /radius exch store
+ \linewidth\space /linewidth exch store
+ \grayshade\space /grayshade exch store
+ #1 grestore}}%
+ \box\graybox}}%
+%
+% Use the following for paragraphs.
+%
+\def\parashade#1#2{%
+ \xgrayspace=10pt%
+ \ygrayspace=10pt%
+ \def\grayshade{0.95}%
+ \def\linewidth{2}%
+ \def\theradius{10}%
+ \def\thevskip{15pt}%
+ \setbox\graybox=\hbox{\surroundboxb{#2}}%
+ \vskip\thevskip
+ \hbox{%
+ \hbox to 0pt{%
+ \special{"gsave newpath 0 0 moveto %
+ 0 1 copy /xmin exch store %
+ \number\dp\graybox \space -65782 div 1 copy /ymin exch store %
+ \number\wd\graybox \space 65782 div 1 copy /xmax exch store %
+ \number\ht\graybox \space 65782 div 1 copy /ymax exch store %
+ \theradius\space /radius exch store
+ \linewidth\space /linewidth exch store
+ \grayshade\space /grayshade exch store
+ #1 grestore}}%
+ \box\graybox}%
+ \vskip\thevskip%
+}%
+%----------------------------------------------------------------------------
+%
+% A pair of box macros. Each builds a slightly oversized box
+% containing the text. The text is centred both in the vertical
+% horizontal directions.
+%
+% Use the following for one or more words within a line.
+%
+\long\def\surroundboxa#1{\leavevmode\hbox{\vtop{%
+\vbox{\kern\ygrayspace%
+\hbox{\kern\xgrayspace#1%
+ \kern\xgrayspace}}\kern\ygrayspace}}}
+%
+% Use the following for a paragraphs.
+%
+\long\def\surroundboxb#1{\leavevmode\hbox{\vtop{%
+\vbox{\kern\ygrayspace%
+\hbox{\kern\xgrayspace\vbox{\advance\hsize-2\xgrayspace#1}%
+ \kern\xgrayspace}}\kern\ygrayspace}}}
+%----------------------------------------------------------------------------
+%
+% Here are some simple PostScript routines.
+%
+% The TeX command \PScommands must be called before any of the
+% shading routines can be used.
+%
+\long\def\PScommands{\special{! TeXDict begin
+%
+/sharpbox{%
+ newpath
+ xmin ymin moveto
+ xmin ymax lineto
+ xmax ymax lineto
+ xmax ymin lineto
+ xmin ymin lineto
+ closepath
+ }bind def
+%
+/roundbox{%
+ newpath
+ xmin radius add ymin moveto
+ xmax ymin xmax ymax radius arcto
+ xmax ymax xmin ymax radius arcto
+ xmin ymax xmin ymin radius arcto
+ xmin ymin xmax ymin radius arcto 16 {pop} repeat
+ closepath
+ }bind def
+%
+/sharpcorners{%
+ sharpbox gsave grayshade setgray fill grestore
+ linewidth setlinewidth stroke
+ }bind def
+%
+/plainbox{%
+ sharpbox grayshade setgray fill
+ }bind def
+%
+/roundcorners{%
+ roundbox gsave grayshade setgray fill grestore
+ linewidth setlinewidth stroke
+ }bind def
+%
+end}% Closes dictionnary
+}%
+
+\PScommands
+
+This is a test of a\ \textshade{roundcorners}{shaded box} routine.
+%
+This is another test of a\ \textshade{sharpcorners}{shaded box} routine
+
+\parashade{roundcorners}{%
+This is one very long line which I expect will be broken over one or more
+lines. The idea is to have this paragraph enclosed in a shaded box. I'll
+just keep on typing until I can be sure that there are more than two lines
+in this paragraph. I expect that this should be well and truely sufficient
+to test this macro.
+}
+\parashade{sharpcorners}{%
+This is one very long line which I expect will be broken over one or more
+lines. The idea is to have this paragraph enclosed in a shaded box. I'll
+just keep on typing until I can be sure that there are more than two lines
+in this paragraph. I expect that this should be well and truely sufficient
+to test this macro.
+}
+
+The field equations of General Relativity are\ %
+%
+\textshade{roundcorners}{\hbox{$G_{\mu\nu} = kT_{\mu\nu}$}}
+
+They can also be written as
+
+\parashade{sharpcorners}{$$R_{\mu\nu}-{1\over2}g_{\mu\nu}R = kT_{\mu\nu}$$}
+
+\bye
diff --git a/macros/generic/misc/swrule.sty b/macros/generic/misc/swrule.sty new file mode 100644 index 0000000000..1632cf3c9d --- /dev/null +++ b/macros/generic/misc/swrule.sty @@ -0,0 +1,89 @@ +% swrule.sty +% Written by Tobias G. Dussa <tdussa@sdhs.de> +% 09oct01 +% Copyright (C) by Tobias G. Dussa <tdussa@sdhs.de> +% +% Provides two macros to create english lines a.k.a. swelled rules (i.e. +% lines % that become thicker towards the middle, much like a very +% far-stretched diamond) that only use plain tex means. +% +% The macros provided are +% - \swrule{length}{maximum width} +% - \swrulex{length}{minimum width}{maximum width} +% +% The \swrule macro is just a shortcut for \swrulex{length}{0pt}{max width}. +% +% The minimum width is the width of the line at the far left and +% right ends, while the maximum width is the width of the line in +% the very middle. +% +% The english line is made up of many short lines of different widths. +% The counter variable \swrulecount specifies how many small line pieces +% should be used to approximate the english line. It is set to 50 by +% default. The larger this value is, the finer-grained the resulting +% english line will be, so that the steps will not be as obvious. +% The \swrulecount variable should never be set to one, as a division +% by zero would occur. Likewise, any value smaller than 1 is pointless, +% albeit possible. +% +% The style package is a quick hack. If any error should occur, then +% I would greatly appreciate learning about it. +% Likewise, any suggestion is appreciated. +% +% The style package is copyrighted but may be used and extended in +% any way, as long as a pointer to the original author is maintained. +% The author is not liable for any problem that may or may not result +% from using this package. Use at your own risk. +% +% Enjoy. + +\newcount\swrulecount +\newcount\swrulestep +\newdimen\swrulemin +\newdimen\swrulemax +\newdimen\swrulelength +\newdimen\swruleraise +\newdimen\swrulewidth +\newdimen\swruledelta +\newdimen\swrulepiece + +\swrulecount=50 + +\def\swrulex#1#2#3{% +\swrulestep=\swrulecount% +\advance\swrulestep by -1% +\swrulelength=#1% +\swrulemin=#2% +\swrulemax=#3% +\swrulewidth=\swrulemin% +\swruleraise=\swrulemax% +\advance\swruleraise by -\swrulemin% +\divide\swruleraise by 2% +\swruledelta=\swrulemax% +\advance\swruledelta by -\swrulemin% +\divide\swruledelta by \swrulestep% +\multiply\swrulestep by 2\advance\swrulestep by 1% +\swrulepiece=\swrulelength% +\divide\swrulepiece by \swrulestep% +\swrulestep=1% +\hbox{% +\loop% +\raise\swruleraise\hbox{\rule{\swrulepiece}{\swrulewidth}}% +\ifnum\swrulestep<\swrulecount% +\advance\swrulestep by 1% +\advance\swruleraise by -\swruledelta% +\advance\swrulewidth by 2\swruledelta% +\repeat% +\advance\swrulestep by -1% +\advance\swruleraise by \swruledelta% +\advance\swrulewidth by -2\swruledelta% +\loop% +\raise\swruleraise\hbox{\rule{\swrulepiece}{\swrulewidth}}% +\ifnum\swrulestep>1% +\advance\swrulestep by -1% +\advance\swruleraise by \swruledelta% +\advance\swrulewidth by -2\swruledelta% +\repeat% +}} + +\def\swrule#1#2{\swrulex{#1}{0pt}{#2}} diff --git a/macros/generic/misc/tabto.tex b/macros/generic/misc/tabto.tex new file mode 100644 index 0000000000..457bd9e4ed --- /dev/null +++ b/macros/generic/misc/tabto.tex @@ -0,0 +1,39 @@ +%-------------- tabto.tex ------------ +% Donald Arseneau <asnd@triumf.ca> +% +% This software is contributed to the public domain. +% See tabto.sty for more useful definitions for LaTeX. +% +% Tab to a position relative to the left margin in a paragraph: +% some text \tabto{1in} more text, and \tabto 3in final text. +% If the text on the line already goes past the desired position, +% the tab starts a new line. +% Note that braces are allowed, but not required. +% + +\newdimen \scratchdim % or use \@tempdima in LaTeX +\newdimen \scratchDIM % or use \@tempdimb in LaTeX + +% this preliminary mess is just TeX's awful way of reading a parameter +% with or without braces. + +\def\tabto{\futurelet\nExt\tabtO} +\def\tabtO{\ifx\nExt\bgroup\let\nExt\TabTo\else\let\nExt\tabtOO\fi\nExt} +\def\tabtOO{\afterassignment\tabTOO\scratchDIM } +\def\tabTOO{\TabTo\scratchDIM} + +\def\TabTo#1{\begingroup\leavevmode +\ifinner\scratchdim=0pt\relax % in a \hbox, so ignore +\else % unrestricted horizontal mode + \parfillskip=0pt plus 1fill % must swamp the -1fil glue + \hfil\null\penalty20 \hskip0ptplus-1fil + \hbox{\mathstrut\kern\hsize\kern-#1}\vadjust{\nobreak}\par + \scratchdim=\prevdepth + \prevdepth=-999pt % make sure I get an exact \baselineskip + \parskip=-999pt % but cancel the extra space + \advance\parskip-\baselineskip % cancel the \baselineskip + \advance\parskip-\scratchdim + \noindent +\fi \hbox to#1{\vrule depth\scratchdim width0pt\hss}\endgroup +\ignorespaces} + diff --git a/macros/generic/misc/tex.logos b/macros/generic/misc/tex.logos new file mode 100644 index 0000000000..19d8e3fb5d --- /dev/null +++ b/macros/generic/misc/tex.logos @@ -0,0 +1,9 @@ +\def\TeXMaG{T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX% TeX part + M\kern-.1667em\lower.5ex\hbox{A}\kern-.2267emG} +\def\LaTeX{{\rm L\kern-.36em\raise.3ex\hbox{\sc a}\kern-.15em + T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}} +\def\AmSTeX{$\cal A\kern-.1667em\lower.5ex\hbox{$\cal M$}\kern-.075em + S$-\TeX} +\def\SliTeX{Sli\TeX} +\def\PiC{P\kern-.12em\lower.5ex\hbox{I}\kern-.075emC} +\def\PiCTeX{\PiC\kern-.11em\TeX} diff --git a/macros/generic/misc/time.sty b/macros/generic/misc/time.sty new file mode 100644 index 0000000000..e1b86ce46d --- /dev/null +++ b/macros/generic/misc/time.sty @@ -0,0 +1,30 @@ +%%% Save file as: TIME.STY (TIME.TEX) Source: FILESERV@SHSU.BITNET +%%% Author: Sunando Sen <sens@nyuacf.bitnet> <sens@acfcluster.nyu.edu> +%%% Source: INFO-TeX@SHSU.edu, Mon, 6 Jan 1992 23:14 EST +%%% Purpose: The command \now produces the current time in hh:mm A.M./P.M. +%%% format; similar to \today +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%% Macro to write the current time %%%%%%%%%%%%%%%%%%% +% \now produces the current time, e.g., 11:15 A.M. % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\newcount\hour \newcount\minute +\hour=\time \divide \hour by 60 +\minute=\time + +\count99=\hour \multiply \count99 by -60 \advance \minute by \count99 + +\def\now{% +\ifnum \hour<13 + \ifnum \hour=0 \advance \hour by 12 \number\hour:\else \number\hour:\fi% + \ifnum \minute<10 0\fi% + \number\minute% +\ A.M.% +\else \advance \hour by -12 \number\hour:% + \ifnum \minute<10 0\fi% + \number\minute% + \ P.M.% +\fi% +} + +\endinput diff --git a/macros/generic/misc/underlin.tex b/macros/generic/misc/underlin.tex new file mode 100644 index 0000000000..eec6aaa129 --- /dev/null +++ b/macros/generic/misc/underlin.tex @@ -0,0 +1,18 @@ +% underlin.tex - real multi-word underlining +% By Stephen Gildea <gildea@x.org> January 1995. + +% Usage: \textul{text to underline} + +\def\textul#1{\leavevmode\let\textulnext=\textuli\textuli#1 & } +\def\textuli#1 {\ifx\unskip\let\textulnext=\relax\else + \textulword{#1}\textulspace\fi \textulnext} +\newskip\textulspskip %saved size of a space +\def\textulword#1{% + \setbox0\hbox{#1\space\global\textulspskip=\the\lastskip\unskip}% + \dimen0=\dp0\dp0=1.2pt + \setbox0\vtop{\box0\hrule}\ifdim\dp0<\dimen0\dp0=\dimen0\fi \box0} +\def\textulspace{\leaders\hrule height -1.2pt depth 1.6pt + \hskip\textulspskip} + +% For a much fancier version with many options (e.g., strikeout), +% see ulem.sty in the CTAN archive. diff --git a/macros/generic/misc/undertilde.tex b/macros/generic/misc/undertilde.tex new file mode 100644 index 0000000000..a586f5554b --- /dev/null +++ b/macros/generic/misc/undertilde.tex @@ -0,0 +1,3 @@ +\def\undertilde#1{\mathord{\vtop{\ialign{##\crcr + $\hfil\displaystyle{#1}\hfil$\crcr\noalign{\kern1.5pt\nointerlineskip} + $\hfil\tilde{}\hfil$\crcr\noalign{\kern1.5pt}}}}} diff --git a/macros/generic/misc/verbatim.tex b/macros/generic/misc/verbatim.tex new file mode 100644 index 0000000000..11d684db6f --- /dev/null +++ b/macros/generic/misc/verbatim.tex @@ -0,0 +1,258 @@ +\catcode `\@ = 11 %%% we use commercial-at as a letter throughout; +\chardef \l@tter = 11 %%% and introduce synonyms for the \catcodes for +\chardef \@ther = 12 %%% <letter> and <other>; +\newcount \c@unt %%% a loop-counter; +\newcount \ch@rcode %%% this will hold the character-code of the + %%% escape character; +\newif \ifd@bugging %%% set <true> if you want to watch the + %%% finite-state automaton at work; +\newif \ifshewleadingspaces %%% set <true> if you want to see leading spaces + %%% shewn as inverted square cup (explicit); +\newif \ifshewembeddedspaces %%% set <false> if you want to see embedded +\shewembeddedspacestrue %%% spaces shewn as white space (implicit); +\ifd@bugging %%% if <debugging>, + \let \m@ssage = \message %%% \m@ssage is synonymous with \message +\else %%% otherwise + \def \m@ssage #1{}% %%% it simply throws its parameter away; +\fi +% +\def \verbatim %%% the \verbatim macro takes no parameter + {\begingroup %%% and immediately starts a nested group + \tracingonline = 0 + \def \n@sted %%% within which \n@sted is defined + {\begingroup %%% to start a further group within which + \let \n@sted %%% \n@sted becomes a synonym for \endgroup + = \endgroup + \@nvironment %%% and the environment is restored to that + %%% which obtained two levels of nesting out; + \ignorespaces %%% for tidyness, we ignore any <lwsp> + }% %%% which follows the escape character; + \edef \@nvironment %%% we initialise \@nvironment + {\the \font %%% who forgot this ????? + \parindent = %%% to prepare to restore \parindent + \the \parindent + \parskip = %%% and \parskip; + \the \parskip + \space %%% and ensure that the value to be assigned to + }% %%% \parskip is properly terminated; + \displayverbatimfont %%% we assume Knuth's font-selectors and + %%% select the `typewriter' font; + \parskip = 0 pt %%% we then set \parindent and + \parindent = 0 pt %%% \parskip to 0 pt; + \c@unt = 0 %%% and initialise \count to 0; + \loop %%% this loop checks the \catcode of each + %%% character code in the range 0 .. 127 + %%% (or 0 .. 255 for TeX V3) and if it + %%% is other than <letter> or <other>, as + %%% appropriate, saves the current value in + %%% \@nvironment for subsequent restoration + %%% within an inner group; it then sets the + %%% \catcode to either <letter> or <other>; + \ifnum \c@unt < `\A + \s@ve \catcode \c@unt = \@ther + \else \ifnum \c@unt > `\z + \s@ve \catcode \c@unt = \@ther + \else \ifnum \c@unt > `\Z + \ifnum \c@unt < `\a + \s@ve \catcode \c@unt = \@ther + \else \s@ve \catcode \c@unt = \l@tter + \fi + \else \s@ve \catcode \c@unt = \l@tter + \fi + \fi + \fi + \advance \c@unt by 1 + \ifnum \c@unt < 256 % or 128 for the V2 sites ... + \repeat + \v@rbatim + } +% +\def \v@rbatim #1% %%% + {\if #1 %%% + \let \n@xt = \v@rb@tim %%% + \else %%% + \def \n@xt %%% + {\v@rb@tim #1}% %%% + \fi %%% + \n@xt %%% + } %%% +% +\def \v@rb@tim #1% + {\ch@rcode = `#1 %%% + \edef \@nvironment %%% and append code to \@nvironment + {\@nvironment %%% to make the escape character active; + \catcode \the \ch@rcode + = \active + \space %%% <space> separates list items in \@nvironment + }% + \catcode \ch@rcode %%% the escape character is made active; + = \active + \uccode `\^^M = \ch@rcode %%% and the upper-case code of <return> is made + %%% equal to the character-code of the escape + %%% character; this is necessary because only + %%% <return> can be guaranteed to be active at + %%% this point, and we need an active character + %%% to form the primary operand of \def; + %%% the \@x's below are \expandafter's, + %%% and the effect is to upper-case <return> + %%% (yielding the escape character), then \def + %%% (an active instance of) this character as + %%% \n@sted, which has been defined above; +% + \@x \uppercase \@x {\@x \def \r@turn {\n@sted}}% +% + \uccode `\^^M = 0 %%% the upper-case code of <return> is then re- + %%% instated (not strictly true; it is set to 0, + %%% which is assumed to be its previous value + %%% --- could be improved here); + \@ctivecr %%% <return> is made active; + \@ctivespace %%% and so is <space> (to avoid space-elision); + %%% finally, the finite-state automaton which + }% %%% processes <space>s is set to <????>; + %%% this ends the definition of \verbatim. +% +\def \s@ve #1#2=#3% %%% \s@ve minimises the \catcode restoration + {\ifnum #1#2 = #3% %%% work of \@nvironment by saving only the + %%% \catcode of characters whose \catcode + %%% is to be changed; it then changes the + %%% \catcode of those characters. + \else \edef \@nvironment + {\@nvironment #1\the #2=\the #1#2 }% + #1#2 = #3% + \fi + }% + %%% the code which follows implements the finite + %%% state automaton which determines whether + %%% <space>s are ignored, shewn explicitly or + %%% implied, and which ensures that blank + %%% lines are reproduced correctly. +% +\def \v@id {\futurelet \n@xt \v@idifspace}% +\def \l@ad {\l@adingspace \futurelet \n@xt \l@adifspace}% +\def \sk@p {\vskip \baselineskip \futurelet \n@xt \l@adifspace}% +\def \emb@d {\emb@ddedspace}% +\def \sh@wspace {\char 32\relax}% +\def \h@despace {\leavevmode \kern \fontdimen 2 \font}% +\def \l@adingspace {\ifshewleadingspaces \sh@wspace \else \h@despace \fi}% +\def \emb@ddedspace {\ifshewembeddedspaces \sh@wspace \else \h@despace \fi}% +\def \v@idifspace {\testn@xt {\afterassignment \v@id}}% +\def \l@adifspace {\testn@xt {\afterassignment \sk@p}}% +% + %%% \testn@xt provides a common look-ahead for + %%% \v@idifspace and \l@adifspace, and also +\def \testn@xt #1% %%% implements some essential debugging hooks. + {\ifx \n@xt \sp@c@ + \m@ssage {Next character is a space}% + \let \n@xt = \relax + \else \ifx \n@xt \r@t@rn + \m@ssage {Next character is a return}% + \def \n@xt {#1\let \n@xt = }% + \else \m@ssage {Next character is \meaning \n@xt}% + \let \n@xt = \relax + \@x \let \sp@ce = \emb@d + \fi + \fi + \n@xt + }% +% + %%% We next tamper with the \catcode of <space> + %%% and <return>, while defining macros and + %%% synonyms which require them to be active; + %%% the \catcode is then restored to its default + %%% (not necessarily the previous value --- + %%% could be improved). \@ctivespace makes + %%% <space> active, then defines <space> as +\catcode `\ = \active% %%% \v@id with a synonym \sp@c@. This code is +\def\sp@ce{ }% %%% used by the finite-state automaton. +\def\@ctivespace% +{\catcode`\ =\active\def {\v@id}\let\sp@c@= }\catcode`\ =10\relax% +\catcode`\ =10\relax% +% +\catcode `\^^M = \active % %%% <return> is made active; +\def \r@turn {^^M}% %%% \r@turn defined as an active <return>; +\let \r@t@rn = ^^M% %%% \r@t@rn is made a synonym; +\def \@ctivecr % %%% and \@ctivecr is defined to + {\catcode `\^^M = \active % %%% make <return> active, then + \def ^^M% %%% define <return> to manipulate the + %%% finite-state automaton and ... + {\@x \def \sp@ce {\l@ad}% + \@x \let \@x \sp@c@ \@x =\sp@ce % +% + \endgraf % %%% insert a \par primitive (for blank lines). +% + \futurelet \n@xt \l@adifspace % + }% + \let \r@t@rn = ^^M% %%% \r@t@rn is synonymous with active <return> + }% +\catcode `\^^M = 5 % %%% finally, the \catcode of <return> is + %%% restored to its normal value; +% + %%% the \AfterGroup macro is intended for + %%% use within a nested normal environment, + %%% and causes (a concealed macro defined as) + %%% its parameter text to be inserted into + %%% TeX's input stream when the nested normal + %%% group terminates. +% +\def \AfterGroup #1{\global \def \@ftergroup {#1}\aftergroup \@ftergroup}% +% +\let \@x = \expandafter %%% \@x is a brief synonym for \expandafter; +% +% +\def \mitabrev %%% and \mitabrev defined as the closure for + {\endgroup \endgroup}% %%% \verbatim; any other name could be used, + %%% as the code performs no look-ahead for + %%% any particular string. +% + %%% Finally we announce to the world that we + %%% have been loaded, and gives some clues as + %%% to the usage. +% + +\catcode `\Ý = \active +\catcode `\| = \active + +\def Ý{\begingroup + \def \s@lidus ##1Ý{\inlineverbatimfont ##1\endgroup}% + \p@ssivate \activesp@ces \s@lidus + } + +\def |{\begingroup + + \def \s@lidus ##1|{\inlineverbatimfont ##1\endgroup}% + \p@ssivate \activesp@ces \s@lidus + } + +\def \p@ssivate + {\tracingonline = 0 + \c@unt = 0 + \loop + \ifnum \catcode \c@unt = 11 {}% + \else \ifnum \catcode \c@unt = 12 {}% + \else \catcode \c@unt = 12 + \fi + \fi + \ifnum + \c@unt < 255 + \advance \c@unt by 1 + \repeat + \catcode `\Ý = \active + \catcode `\| = \active + } + +\begingroup +\catcode `\ = \active\gdef\activesp@ce{\def {\phantom{\char`\ }}}% +\endgroup + +\def \activesp@ces {\catcode `\ = \active \activesp@ce} + +\catcode `\@ = \@ther %%% commercial-at is restored to its normal + %%% <other> catcode (not necessarily the + %%% previous value --- could be improved); + +\message {Verbatim environment loaded;}% +\message {usage: ``\noexpand \verbatim <char> ... <char> \noexpand \mitabrev''}% +\message {less functional short forms: \string Ý...\string Ý & + \string |...\string |}% + +%%% ======================================================================== %%% diff --git a/macros/generic/misc/weekday.sty b/macros/generic/misc/weekday.sty new file mode 100644 index 0000000000..cda185ad31 --- /dev/null +++ b/macros/generic/misc/weekday.sty @@ -0,0 +1,74 @@ +% Save file as: WEEKDAY.STY Source: FILESERV@SHSU.BITNET +%% WEEKDAY.STY -- original source: Dimitri Vulis <DLV@CUNYVMS1.BITNET> with +%% modifications by George D. Greenwade <BED_GDG@SHSU.BITNET>, and gracious +%% assistance from Bernhard Schroeder <UPK002@DBNRHRZ1.BITNET>, Hunter +%% Goatley <GOATHUNTER@WKUVX1.BITNET>, and others via INFO-TeX/comp.text.tex. +%% 21-FEB-1991 17:42:37 +%% +%% Usage: \weekday{yyyy}{mm}{dd} (where "yyyy" is a year, "mm" is the numeric +%% equilavent of the month, and "dd" is the specific calendar date +%% which may be one or two numbers) yields the weekday associated with +%% the date provided (i.e., Sunday, Monday, ...). May pass \year, +%% \month, and \day to generate today's weekday. +%% +%% -- \weekdaydate{yyyy}{mm}{dd} yields result of \weekday, as well as the +%% calendar date (i.e., \weekdaydate{1991}{02}{21} yields Thursday, +%% February 21, 1991). (NOTE: syntax is changed from \weekdaydisplay +%% to \weekdaydate to make it a little more rememberable) +%% +%% May be used as a TeX macro or as a LaTeX style, from what I can tell. +%% Please report any enhancements or bugs you come across so they can be +%% posted in FILESERV's STYle archives. George <BED_GDG@SHSU.BITNET> +%% +\newcount\wwwy +\newcount\wwwm +\newcount\wwwd +\newcount\wwwc +\newcount\wwwt +\newcount\wwws + +\def\weekday@{% +\wwwc=\wwwy +\divide\wwwc100\relax +\wwwt=-\wwwc +\multiply\wwwt100\relax +\advance\wwwy\wwwt +\wwws=\wwwy +\multiply\wwws1461\relax +\divide\wwws4\relax +\wwwt=\wwwm +\multiply\wwwt764\relax +\divide\wwwt25\relax +\advance\wwws\wwwt +\advance\wwws\wwwd +\ifnum\wwwm>\tw@\advance\wwws\thr@@\else\weekday@@\fi +\wwwt=-\wwws +\divide\wwwt7\relax +\multiply\wwwt7\relax +\advance\wwws\wwwt +} + +% By the year 2000 we ought to examine \wwwc as well + +\def\weekday@@{% +\wwwt=\wwwy +\divide\wwwt4\relax +\multiply\wwwt4\relax +\advance\wwwt-\wwwy +\ifnum\wwwt=\z@\advance\wwws4\else\advance\wwws5\fi +} + +\def\weekday#1#2#3{% year, month 1--12, day 1--31 +\wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax \weekday@ +\ifcase\wwws Sunday\or + Monday\or Tuesday\or Wednesday\or Thursday\or Friday\or Saturday\fi} + +\def\weekdaydate#1#2#3{% year, month 1--12, day 1--31 +\wwwy=#1\relax\wwwm=#2\relax\wwwd=#3\relax\weekday@ +\ifcase\wwws Sunday,\or +Monday,\or Tuesday,\or Wednesday,\or Thursday,\or Friday,\or Saturday,\fi +\space +\ifcase #2\or + January\or February\or March\or April\or May\or June\or + July\or August\or September\or October\or November\or December\fi +\space\number#3, \space\number#1} % Here I (Bernhard) inserted \number diff --git a/macros/generic/misc/wiggly.tex b/macros/generic/misc/wiggly.tex new file mode 100644 index 0000000000..7f04760f34 --- /dev/null +++ b/macros/generic/misc/wiggly.tex @@ -0,0 +1,30 @@ +% A macro \underwiggle for drawing variable length wiggly lines horizontally +% under its argument in the same way as \underbar. +% Written by Dr. John S. Garavelli on 4 December 1987 and adapted from a routine +% by A. G. W. Cameron at Harvard University which appeared in TUGBOAT November +% 1985, vol. 6, no. 3, p. 155. +% WARNING: the computations performed by this macro can be very time consuming, +% so use it sparingly. + +\newcount\vone \newcount\vtwo \newcount\vthree \newcount\vfour \newcount\vfive +\newcount\vsix \newcount\vseven \newcount\veight \newcount\vnine \newcount\vten +\newbox\wbox \newdimen\wbsize +\def\underwiggle#1{\ifmmode\setbox\wbox=\hbox{$#1$} + \else\setbox\wbox=\hbox{#1}\fi +\dp\wbox=0pt\wbsize=\wd\wbox\lower2pt\hbox to0pt +{\hss$\vone=0\vtwo=0\vthree=7000\vfive=\vtwo +\loop +\vseven=\vone \divide\vseven by 2 +\vsix=\vfive \divide\vsix by 2 \multiply\vsix by -1 +\veight=16384 \advance\veight by \vsix +\vnine=16384 \advance\vnine by -\vsix +\vten=\vseven \advance\vten by 32768 +\hskip\vseven sp +\vrule height\veight sp width 32768 sp depth\vnine sp +\hskip-\vten sp +\ifdim\vseven sp<\wbsize \advance\vone by 20000 +\advance\vtwo by \vthree +\vfour=-\vtwo \divide\vfour by 10 +\advance\vthree by \vfour +\advance\vfive by \vtwo +\repeat$}\box\wbox} diff --git a/macros/generic/misc/zip.tex b/macros/generic/misc/zip.tex new file mode 100644 index 0000000000..c1139b3cc4 --- /dev/null +++ b/macros/generic/misc/zip.tex @@ -0,0 +1,88 @@ +% zip.tex +% +% J. Daniel Smith +% 24 May 1990 +% +% Modified from a STY file snarfed from someplace else. But I don't +% remember where the original code came from... OOPS!!! +% +% Make a barcode for a ZIP code! +% +% Example usage is below. +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\catcode`@=11 % letter +% +% Dimensions of bars to be used in the barcode +\newdimen\b@rwidth \newdimen\b@rlong \newdimen\b@rshort \newdimen\b@rsep +\b@rwidth=0.02true in \b@rlong=0.125true in \b@rshort=0.05true in +\b@rsep=0.0275true in +\def\sb@r{\vrule height\b@rshort width\b@rwidth depth0pt \kern\b@rsep} +\def\lb@r{\vrule height\b@rlong width\b@rwidth depth0pt \kern\b@rsep} + +% The barcodes for each digit +\def\zerob@r{\lb@r\lb@r\sb@r\sb@r\sb@r} +\def\oneb@r{\sb@r\sb@r\sb@r\lb@r\lb@r} +\def\twob@r{\sb@r\sb@r\lb@r\sb@r\lb@r} +\def\threeb@r{\sb@r\sb@r\lb@r\lb@r\sb@r} +\def\fourb@r{\sb@r\lb@r\sb@r\sb@r\lb@r} +\def\fiveb@r{\sb@r\lb@r\sb@r\lb@r\sb@r} +\def\sixb@r{\sb@r\lb@r\lb@r\sb@r\sb@r} +\def\sevenb@r{\lb@r\sb@r\sb@r\sb@r\lb@r} +\def\eightb@r{\lb@r\sb@r\sb@r\lb@r\sb@r} +\def\nineb@r{\lb@r\sb@r\lb@r\sb@r\sb@r} + +\newcount\zipb@rm +\newcount\zipb@rn +\chardef\ten=10 + +%Almost like using \ifcase... except `-' is ignored. +\def\zipb@r@@@#1#2{\expandafter\def\csname zipb@r@@#1\endcsname% + {#2\advance\zipb@rn#1\relax}} + +\newbox\zipbarcode +\zipb@r@@@0{\global\setbox\zipbarcode\hbox{\box\zipbarcode\zerob@r}} +\zipb@r@@@1{\global\setbox\zipbarcode\hbox{\box\zipbarcode\oneb@r}} +\zipb@r@@@2{\global\setbox\zipbarcode\hbox{\box\zipbarcode\twob@r}} +\zipb@r@@@3{\global\setbox\zipbarcode\hbox{\box\zipbarcode\threeb@r}} +\zipb@r@@@4{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fourb@r}} +\zipb@r@@@5{\global\setbox\zipbarcode\hbox{\box\zipbarcode\fiveb@r}} +\zipb@r@@@6{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sixb@r}} +\zipb@r@@@7{\global\setbox\zipbarcode\hbox{\box\zipbarcode\sevenb@r}} +\zipb@r@@@8{\global\setbox\zipbarcode\hbox{\box\zipbarcode\eightb@r}} +\zipb@r@@@9{\global\setbox\zipbarcode\hbox{\box\zipbarcode\nineb@r}} + +\def\zipb@r@@#1{\csname zipb@r@@#1\endcsname} + +\def\zipb@r@#1{\ifx#1\null + \let\next\relax + \else + \zipb@r@@{#1}#1% + \let\next\zipb@r@ + \fi + \next} + +\def\zipbar#1{\setbox\zipbarcode=\null + \hbox{ % put numbers in an \hbox + \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r} % start with long bar + \zipb@rn\z@\zipb@r@#1\null + \zipb@rm\zipb@rn \divide\zipb@rm\ten \multiply\zipb@rm\ten + \advance\zipb@rm-\zipb@rn + \ifnum\zipb@rm<0 + \advance\zipb@rm\ten + \fi + \zipb@r@@{\the\zipb@rm} % last digit, so that the sum is divisible by ten + \global\setbox\zipbarcode\hbox{\box\zipbarcode\lb@r}% end with a long bar + } % end of \hbox +} + +\catcode`@=12 % disable private sequences +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +%\zipbar{1234567890} +% +%\zipbar{48837} +% +%\zipbar{78653--0102} +%\bye +\endinput |