diff options
Diffstat (limited to 'tex/context/base/supp-ali.tex')
-rw-r--r-- | tex/context/base/supp-ali.tex | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/tex/context/base/supp-ali.tex b/tex/context/base/supp-ali.tex new file mode 100644 index 000000000..363c239bc --- /dev/null +++ b/tex/context/base/supp-ali.tex @@ -0,0 +1,140 @@ +%D \module +%D [ file=supp-ali, +%D version=2000.4.17, +%D title=\CONTEXT\ Support Macros, +%D subtitle=Alignment, +%D author=Hans Hagen, +%D date=\currentdate, +%D copyright={PRAGMA / Hans Hagen \& Ton Otten}] +%C +%C This module is part of the \CONTEXT\ macro||package and is +%C therefore copyrighted by \PRAGMA. See mreadme.pdf for +%C details. + +%D Yet undocumented. + +% 0 = centered +% 1 = left in before +% 2 = right in before +% 3 = left in after +% 4 = right in after + +\unprotect + +\chardef\characteralignmentmode=4 + +\let\afterassignwidth \!!zeropoint +\let\beforeassignwidth\!!zeropoint + +\def\alignmentcharacter{.} + +\let\alignmentclass\s!default % can be used to handle multiple mixed ones + +\def\setfirstpasscharacteralign% + {\popcharacteralign + \expanded{\dosetfirstpasscharacteralign{\alignmentcharacter}}} + +\def\dosetfirstpasscharacteralign#1% + {\def\checkalignment##1% + {\popcharacteralign + \setbox\scratchbox=\hbox{#1}% + \edef\characterassignwidth{\the\wd\scratchbox}% + \setbox\scratchbox=\hbox{}% + \docheckalignment#1##1#1\relax\relax + \scratchdimen=-\wd\scratchbox + \setbox\scratchbox=\hbox{##1}% + \advance\scratchdimen by \wd\scratchbox + \ifdim\scratchdimen>\beforeassignwidth\relax + \edef\beforeassignwidth{\the\scratchdimen}% + \fi + \ifdim\scratchdimen=\!!zeropoint + \setbox\scratchbox=\hbox{##1}% + \scratchdimen=\wd\scratchbox + \ifnum\characteralignmentmode=0 + % do nothing + \else\ifnum\characteralignmentmode<3 + \advance\scratchdimen by \characterassignwidth + \ifdim\scratchdimen>\beforeassignwidth\relax + \edef\beforeassignwidth{\the\scratchdimen}% + \fi + \else + \ifdim\scratchdimen>\afterassignwidth\relax + \edef\afterassignwidth{\the\scratchdimen}% + \fi + \fi\fi + \fi + \pushcharacteralign}% + \def\docheckalignment##1#1##2##3\relax% + {\ifx##2\relax + \setbox\scratchbox=\hbox{##1}% + \ifdim\wd\scratchbox>\afterassignwidth + \edef\afterassignwidth{\the\wd\scratchbox}% + \fi + \else + \docheckalignment##2##3\relax + \fi}} + +\def\setsecondpasscharacteralign% + {\popcharacteralign + \expanded{\dosetsecondpasscharacteralign{\alignmentcharacter}}} + +\def\dosetsecondpasscharacteralign#1% + {\def\checkalignment##1% + {\popcharacteralign + \setbox\scratchbox=\hbox{#1}% + \edef\characterassignwidth{\the\wd\scratchbox}% + \setbox\scratchbox=\hbox{}% + \docheckalignment#1##1#1\relax\relax + \scratchdimen=\wd\scratchbox + \setbox\scratchbox=\hbox{##1}% + \ifdim\scratchdimen=\wd\scratchbox + \ifcase\characteralignmentmode + \noindent\box\scratchbox + \else + \noindent\hbox + {\dontcomplain + \hbox to \beforeassignwidth + {\ifcase\characteralignmentmode\or + \box\scratchbox\hss + \or + \hss\box\scratchbox\hskip\characterassignwidth + \or + \hss\rlap{\box\scratchbox}% + \or + \hss\rlap{\hbox to \afterassignwidth{\hss\box\scratchbox}}% + \fi}% + \hskip\afterassignwidth}% + \fi + \else + \noindent\hbox + {\hbox to \beforeassignwidth + {\hss\box\scratchbox\hskip-\scratchdimen}% + \hskip\afterassignwidth}% + \fi}% + \def\docheckalignment##1#1##2##3\relax% + {\ifx##2\relax + \setbox\scratchbox=\hbox{##1}% + \else + \docheckalignment##2##3\relax + \fi}} + +% provide a means to use multiple alignments mixed + +\def\pushcharacteralign% + {\setxvalue{@cac@\alignmentclass}{\noexpand\do + {\afterassignwidth}{\beforeassignwidth}{\alignmentcharacter}}} + +\def\popcharacteralign% + {\def\do##1##2##3% + {\def\afterassignwidth {##1}% + \def\beforeassignwidth {##2}% + \def\alignmentcharacter{##3}}% + \getvalue{@cac@\alignmentclass}} + +\long\def\startcharacteralign#1\stopcharacteralign% + {\bgroup + \setfirstpasscharacteralign #1% + \setsecondpasscharacteralign#1% + \egroup} + +\protect \endinput |