diff options
author | Karl Berry <karl@freefriends.org> | 2006-01-11 23:49:19 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2006-01-11 23:49:19 +0000 |
commit | b3e91602f5c5c87db7d26bc4e2422697cbfefdb8 (patch) | |
tree | 727056e7ca8a3fc6e395eae3296e66f4b081eecc /Master/texmf-dist/source/latex3/xor | |
parent | 23d7c0b36aca6e9b3a074d0382ad9bb24d351bc6 (diff) |
trunk/Master/texmf-dist/source/latex3
git-svn-id: svn://tug.org/texlive/trunk@113 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex3/xor')
18 files changed, 12985 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex3/xor/xmarks.dtx b/Master/texmf-dist/source/latex3/xor/xmarks.dtx new file mode 100644 index 00000000000..c8286827ec0 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xmarks.dtx @@ -0,0 +1,956 @@ +% \iffalse +%% +%% (C) Copyright 1999 Frank Mittelbach +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \begin{macrocode} +\def\next#1: #2.dtx,v #3 #4 #5 #6 #7$#8{ +%<*dtx> + \ProvidesFile{#2.dtx} +%</dtx> +%<package>\ProvidesPackage{#2} +%<driver>\ProvidesFile{#2.drv} + [#4 #3 #8 (#6)]} +\next$Id: xmarks.dtx,v 1.6 2000/06/13 20:47:23 latex3 Exp $ + {multiple marks} +% \end{macrocode} +% +%<*driver> + \documentclass{ltxdoc} +% + \begin{document} + \DocInput{xmarks.dtx} + \end{document} +%</driver> +% +% \fi +% +% +% \GetFileInfo{xmarks.dtx} +% +% \title{The \textsf{xmarks} package\thanks{This file +% has version number \fileversion, last +% revised \filedate.}} +% \author{FMi} +% \date{\filedate} +% +% \maketitle +% +% \tableofcontents +% +% +% +% \section{Mark algorithm} +% +% To allow for completely independent marks we use the following +% procedure: +% \begin{itemize} +% \item +% For every mark of type \meta{type} we have a queue that holds every mark +% info found in memory. Every info is associated with a unique number, +% i.e., we simply count them. The queue always holds at least one item +% which is the previous mark info, i.e., the last mark for that type on +% the previous page. +% +% \item +% We use \TeX's internal mark mechanism only to record the associated +% numbers for marks for every type on the current page. +% +% \item +% For every \meta{type} we record the info-number that belongs to the last +% mark of the previous page. +% +% \item +% By looking at \TeX's internal |\botmark| we can determine the +% info-number of the last mark for every \meta{type} that is on the current +% page. +% +% \item +% The difference between this number and the info-number from the last +% page gives us the number of marks for every \meta{type} on the current page. +% +% \item +% That way we are able to decide how to extract items from the queue so +% that first, last, and previous mark for every type can be accessed. +% \begin{itemize} +% \item +% If the difference is zero, no new marks have been added on the +% current page, therefore the only item on the corresponding mark type +% queue holds the info that should be previous, first, and last mark of +% this type for the current page. +% \item +% If the difference is one, then the first item in the queue represents +% the info that should become the previous mark (it will be popped off) +% and the second item (which will be kept, since it will become the +% previous mark for the next page) should become first and last mark for +% the current page. +% \item +% Otherwise we had at least two marks for this type on the current page. +% Therefore, the first item in the queue will become previous mark (popped +% off), the second will become first mark (popped off), then we pop off +% all but the last item in the queue, which will become last mark, by only +% looking at it. +% \end{itemize} +% In other words every queue should hold only one item after this part of +% the algorithm has acted. +% After this is done we save the info-numbers given by |\botmark| +% as the info-numbers of the last page, so that they are available next time. +% +% \item +% Putting a mark into the galley therefore means to put its info to the +% right of the corresponding queue, increment the current info-number for +% \meta{type} by one and putting a \TeX{} mark into the galley holding the +% current info-numbers for all \meta{types}. +% +% \end{itemize} +% +% +% \subsection{Restrictions} +% +% One restriction in using this algorithm without further refinements +% is that for every \meta{type} there will be an upper limit of marks allowed +% within one document. This upper limit is given by |\maxdimen| which is +% probably high enough to ignore it, but it could be improved by resetting +% the info numbers whenever all marks have found their way onto the +% current page. +% +% Another restriction is that one better not changes from linearily +% processing the data for the main galley, or, if one modifies that +% processing one needs to carefully adjust the data structures for the +% marks as well. The problem being that the individual marks within a +% preprocessed galley will stay there forever (and thus can be parsed +% several times), the external data structures, e.g., the plists and +% the sequences however need manual corrections in that case. +% +% \subsection{Implementation} +% +% The original implementation was done on a portable PC in a train +% sometime in 1992/93 and is just a straight implementation of the +% above algorithm using plists to hold the current and the last +% info-numbers. The whole stuff could be done much better by analysing +% the algorithm combining common parts (a lot of thing have be done +% twice, etc.) and recoding the rest in a better way. +% +% The implementation below is more or less a straight adaption +% of that code, so it still needs a rewrite one day. It is based on +% modules implementing ``queues'', ``property lists'', and ``quarks'' +% most of which have been published as experimental code with a +% slightly different surface syntax, i.e., as \texttt{l3seq.sty}, +% \texttt{l3prop.sty}, and \texttt{l3quark.sty}. +% +% New stuff: +% \begin{macrocode} +\RequirePackage{ldcsetup} +\IgnoreWhiteSpace +% \end{macrocode} +% +% \begin{macrocode} +\long\def\@firstofthree#1#2#3{#1} +\long\def\@secondofthree#1#2#3{#2} +\long\def\@thirdofthree#1#2#3{#3} +% \end{macrocode} +% +% \begin{macrocode} +\def \tlp@to@str@N {\expandafter \tlp@to@str@aux \meaning} +\def \tlp@to@str@aux #1>{} +\def \tlp@to@str@c #1 {\expandafter \tlp@to@str@N \csname#1\endcsname} +% \end{macrocode} +% +% +% +% +% +% \subsection{Commands for manipulating queues} +% +% \begin{macro}{\trace@queue} +% \begin{macro}{\trace@queue@internal} +% \begin{macro}{\tracingqueues} +% \begin{macrocode} +%<*trace> +\def\trace@queue#1{\ifnum \tracingqueues > \z@ + \typeout{Queues:~ #1~ \on@line}\fi} +\def\trace@queue@internal#1{\ifnum\tracingqueues>\@ne + \typeout{Queues:~ #1~ \on@line}\fi} +\newcount\tracingqueues +%</trace> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\queue@new@c} +% \begin{macrocode} +\def\queue@new@c#1{\@namedef{#1}{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\queue@gadd@Nn} +% \begin{macrocode} +\def\queue@gadd@Nn#1#2{\expandafter\gdef\expandafter#1\expandafter + {#1\queue@elt#2\queue@eelt} +%<*trace> + \trace@queue@internal{add~ `#2'~ to~ queue~ \string#1} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\queue@gadd@cn} +% \begin{macrocode} +\def\queue@gadd@cn#1{\expandafter\queue@gadd@Nn\csname#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\queue@top@NN} +% \begin{macrocode} +\def\queue@top@NN#1#2{ + \queue@empty@err@N#1 + \expandafter\queue@top@split@w#1\q@stop{\def#2} +%<*trace> + \trace@queue@internal{top~ of~ queue~\string#1:~`\tlp@to@str@N#2'} +%</trace> +} +% \end{macro} +% +% \begin{macro}{\queue@top@split@w} +\def\queue@top@split@w\queue@elt#1\queue@eelt#2\q@stop#3{#3{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\queue@top@cN} +% \begin{macrocode} +\def\queue@top@cN#1{\expandafter\queue@top@NN\csname#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\queue@pop@aux@nnNN} +% \begin{macro}{\queue@pop@aux@w} +% \begin{macrocode} +\def \queue@pop@aux@nnNN #1#2#3{ + \queue@empty@err@N #3 + \expandafter\queue@pop@aux@w #3\q@stop #1#2#3} +\def \queue@pop@aux@w \queue@elt#1\queue@eelt + #2\q@stop #3#4#5#6{#3#5{#2}#4#6{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\queue@gpop@NN} +% \begin{macrocode} +\def \queue@gpop@NN #1#2{\queue@pop@aux@nnNN \gdef \def #1 #2 +%<*trace> + \trace@queue@internal{pop~ of~ queue~\string#1:~`\tlp@to@str@N #2'} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\queue@gpop@cN} +% \begin{macrocode} +\def \queue@gpop@cN #1{\expandafter\queue@gpop@NN\csname#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\queue@empty@err@N} +% \begin{macrocode} +\def\queue@empty@err@N #1{\ifx#1\@empty \ERROR \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% +% \subsection {Quarks} +% +% A quark is a control sequence that expands into itself@ |\def| +% |\foo{\foo}|. Quarks provide a cheap way of generating distinct +% constants. Also, they permit the following ingenious trick: when +% you pick up a token in a temporary, and you want to know whether you +% have picked up a particular quark, all you have to do is compare the +% temporary to the quark using |\ifx|. +% +% \begin{macro}{\quark@new@N} +% Allocate a new quark. +% \begin{macrocode} +\def \quark@new@N #1{\def #1{#1}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\q@stop} +% \begin{macro}{\q@no@value} +% \begin{macro}{\q@nil} +% |\q@stop| is often used as a marker in parameter text, +% |\q@no@value| is the canonical missing value, and |\q@nil| +% represents a nil pointer in some data structures. +% \begin{macrocode} +\quark@new@N \q@stop +\quark@new@N \q@no@value +\quark@new@N \q@nil +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\q@error} +% \begin{macro}{\q@mark} +% We need two additional quarks. |\q@error| delimits the end of +% the computation for purposes of error recovery. |\q@mark| is +% used in parameter text when we need a scanning boundary that is +% distinct from |\q@stop|. +% \begin{macrocode} +\quark@new@N\q@error +\quark@new@N\q@mark +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\quark@if@no@value@NTF} +% \begin{macro}{\quark@if@no@value@NF} +% \begin{macro}{\quark@if@no@value@nTF} +% \begin{macro}{\quark@if@no@value@nT} +% \begin{macro}{\quark@if@no@value@nF} +% Here we test if we found a special quark as the first argument. +% The argument might contain an arbitrary list of tokens, therefore +% we have to wrap it up in a token list pointer. +% \begin{macrocode} +\def \quark@if@no@value@NTF #1{ +% \end{macrocode} +% We better start with |\q@no@value| as the first argument since +% the whole thing may otherwise loop if |#1| is wrongly given +% a string like |aabc| instead of a single token.\footnote{It may +% still loop in special circumstances however!} +% \begin{macrocode} + \ifx\q@no@value#1 + \expandafter\@firstoftwo + \else \expandafter\@secondoftwo \fi} +% \end{macrocode} +% It would be possible to speed up the following commands by +% providing individual implementations similar to the one above. +% Should perhaps be done if they are used often! +% \begin{macrocode} +\def \quark@if@no@value@NF #1{\quark@if@no@value@NTF {#1}\@empty} +\def \quark@if@no@value@nTF #1{\gdef \@gtempa {#1} + \quark@if@no@value@NTF\@gtempa} +\def \quark@if@no@value@nF #1{\quark@if@no@value@nTF {#1}\@empty} +\def \quark@if@no@value@nT #1#2{\quark@if@no@value@nTF {#1} + {#2}\@empty} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\quark@if@nil@NTF} +% A function to check for the presence of |\q@nil|. +% \begin{macrocode} +\def\quark@if@nil@NTF#1{ + \ifx#1\q@nil + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo\fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{Commands for manipulating property lists} +% +% +% \begin{macro}{\prop@new@N} +% \begin{macrocode} +\def \prop@new@N #1{\def #1{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\prop@put@NNn} +% \begin{macro}{\prop@gput@NNn} +% \begin{macro}{\prop@gput@NNo} +% \begin{macro}{\prop@gput@cco} +% \begin{macro}{\prop@gput@ccn} +% \begin{macrocode} +\long\def \prop@put@NNn #1#2{\prop@split@aux@NNn + #1#2{\prop@put@aux@w {\def #1}#2}} +\long\def \prop@gput@NNn #1#2{\prop@split@aux@NNn + #1#2{\prop@put@aux@w {\gdef #1}#2}} +% missing commands for galley stuff... +\def \prop@gput@NNo #1#2#3{ + \expandafter\prop@gput@NNn \expandafter #1 \expandafter + #2 \expandafter { #3 } } +\def \prop@gput@cco #1#2#3{ + \expandafter\prop@gput@NNn \csname #1\expandafter\endcsname + \csname #2\expandafter\endcsname + \expandafter { #3 } } +\def \prop@gput@ccn #1#2{ + \expandafter\prop@gput@NNn \csname #1\expandafter\endcsname + \csname #2\endcsname + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\prop@put@aux@w} +% \begin{macrocode} +\long\def \prop@put@aux@w #1#2#3#4#5#6{ + \quark@if@no@value@nTF {#4} + {#1{#2{#6}#3}} + {\def\tmp@w ##1#2\q@no@value {#1{#3#2{#6}##1}} + \tmp@w #5}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\prop@split@aux@NNn} +% \begin{macrocode} +\long\def \prop@split@aux@NNn #1#2#3{ + \def\tmp@w ##1#2##2##3\q@stop {#3{##1}{##2}{##3}} +% ^ ^ needed! + \expandafter\tmp@w #1#2\q@no@value \q@stop} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prop@get@NNN} +% \begin{macrocode} +\long\def \prop@get@NNN #1#2{\prop@split@aux@NNn + #1#2\prop@get@aux@w} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prop@get@aux@w} +% \begin{macrocode} +\long\def \prop@get@aux@w #1#2#3#4{\def#4{#2}} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prop@map@funct@Nn} +% \begin{macrocode} +\let \prop@map@funct@Nn \@gobbletwo +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prop@map@NN} +% \begin{macrocode} +\def \prop@map@NN #1#2{ + \let \prop@map@funct@Nn #2 + \expandafter\prop@map@aux@w #1\q@stop \q@stop} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\prop@map@aux@w} +% \begin{macrocode} +\def \prop@map@aux@w #1#2{ + \ifx #1\q@stop \else + \prop@map@funct@Nn #1{#2} + \expandafter\prop@map@aux@w + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\prop@map@cN} +% \begin{macrocode} +\def \prop@map@cN #1{ + \expandafter \prop@map@NN \csname #1\endcsname } +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% \subsection{Commands for manipulating marks} +% +% +% +% \begin{macro}{\trace@mark} +% \begin{macro}{\trace@mark@internal} +% \begin{macro}{\tracingmarks} +% Tracing is done when |\tracingmarks| is positive. +% \begin{macrocode} +%<*trace> +\def\trace@mark#1{\ifnum \tracingmarks > \z@ + \typeout{Marks:~ #1~ \on@line}\fi} +\def\trace@mark@internal#1{\ifnum\tracingmarks>\@ne + \typeout{Marks:~ #1}\fi} +\newcount\tracingmarks +%</trace> +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\mark@new} +% Defines a new mark label and retrieval token list pointer. +% \begin{macrocode} +\def\mark@new#1{ +%<*trace> + \trace@mark + {new~mark:~\string#1} +%</trace> +% \end{macrocode} +% We make sure that the argument is still free and allocate the +% corresponding queue. To avoid problems with the use of such tlp's +% when they are used before the first |\mark@update@structure| we initialize +% them in a way that |\mark@previous| and the like will accept them even +% then. +% \begin{macrocode} + \newcommand* #1 {{}{}{}} + \queue@new@c{\string#1@seq} +% \end{macrocode} +% The last info-number for this type will be set to |1| This value +% is actually arbitrary and we could use |-\maxdimen+1| to get the +% range doubled. +% \begin{macrocode} + \prop@gput@NNn\mark@last@plist#1{1} +% \end{macrocode} +% More important is that the starting value for the current +% info-number is one less then the one used above. +% \begin{macrocode} + \prop@gput@NNn\mark@curr@plist#1{0} +% \end{macrocode} +% We now put the very first mark of this type in. This mark will be +% empty. This will initialize the queue (now holding the empty previous +% mark) increment the current info number, so that last and current are +% now equal and also puts a \TeX{} mark into the galley will the +% additional type present. +% \begin{macrocode} + \mark@put@Nn#1{}% +% \end{macrocode} +% \begin{macrocode} + \expandafter\g@addto@macro\expandafter\mark@save@state\expandafter{% + \expandafter\global\expandafter\let + \csname saved\string#1@seq\expandafter\endcsname + \csname\string#1@seq\endcsname} + \expandafter\g@addto@macro\expandafter\mark@restore@state@internal\expandafter{% + \expandafter\global\expandafter\let + \csname\string#1@seq\expandafter\endcsname + \csname saved\string#1@seq\endcsname} +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\mark@save@state} +% \begin{macro}{\mark@restore@state@internal} +% Save and restore the current state of the mark data +% structure. The commands will be extended by |\mark@new|. They are +% needed if part of the main galley is being reused or several +% times parsed. +% \begin{macrocode} +\def\mark@save@state{% + \global\let\saved@mark@curr@plist\mark@curr@plist + \global\let\saved@mark@last@plist\mark@last@plist} +\def\mark@restore@state@internal{% + \global\let\mark@curr@plist\saved@mark@curr@plist + \global\let\mark@last@plist\saved@mark@last@plist} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\mark@restore@state} +% |\mark@restore@state| will restore the state of the mark +% mechanism to the one saved by |\mark@save@state|. It has to be +% called inside an output routine and as it needs an output routine +% of its own to restore the |\mark| status of the bottom mark (so +% that \TeX{} correctly updates the mark registers in case it +% doesn't find a mark in box 255) it has an argument which is +% executed inside that output routine to regain control. +% +% The code in the argument has to set |\output| to a new output +% routine! If not you are in trouble. +% +% \begin{macrocode} +\def\mark@restore@state#1{% +%<*trace> + \@tracepush{mark@restore@state} +%</trace> +% \end{macrocode} +% We first restore the external data structures by calling +% |\mark@restore@sate@internal|. Then we have to ensure that \TeX's +% idea of what the current |\botmark| is, corresponds to what it +% was when we saved the state. Back then it was the contents of +% |\mark@last@plist| so we are now adding an empty box and then +% mark with is contents +% onto the MVL followed by a penalty that ensures we trigger the +% output routine and then specify a tiny little output routine +% whose sole purpose is to get that mark processed. +% \begin{macrocode} + \mark@restore@state@internal + \hbox{}% +% \end{macrocode} +% We have to protect |\mark@last@plist| from expanding too far +% inside the |\mark| so we first put it into a token register +% before applying |\mark|. +% \begin{macrocode} + \@temptokena\expandafter{\mark@last@plist}% +%<*trace> + \trace@mark@internal{restoring~ botmark~ \the\@temptokena}% +%</trace> + \mark + {\the\@temptokena} + \penalty-20203\relax +% \end{macrocode} +% We are not setting |\vsize| assuming its positive. So the moment +% we return from the current output routine (we are hopefully in +% right now) we should very very soon find the above penalty and +% then trigger the output routine we are about to define now. +% +% In that output routine we have a quick test for the +% |\outputpenalty| just to ensure that we really grabbed what we +% are supposed to grab. Then we throw away the contents of box 255 +% since all we wanted todo is to get |\botmark| set back to the +% value of our mark above. Finally we execute whatever got passed +% along as argument one to regain control. Since current |\output| +% has a rather funny definition the code in that argument better +% change that back to something that does a little bit more +% typesetting. +% \begin{macrocode} + \global\output{% +%<*trace> + \@tracepush{mark@restore@state@or} +%</trace> + \ifnum-20203=\outputpenalty\else \ERROR \fi + \global\setbox\@cclv\box\voidb@x + #1% +%<*trace> + \@tracepop{mark@restore@state@or} +%</trace> + }% +%<*trace> + \@tracepop{mark@restore@state} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\mark@put@Nn} +% To put a mark into the current horizontal or vertical \TeX{} list +% we first update |\mark@curr@plist| and then put its value into the +% mark without any further expansion. (The code could be +% optimized!) +% \begin{macrocode} +%<-trace>\def\mark@put@Nn#1{% % wtest hack } +%<*trace> +\def\mark@put@Nn#1#2{ + \def\l@tmpa@tlp{#2} + \trace@mark + {set~\string#1~<-~\tlp@to@str@N\l@tmpa@tlp} +%</trace> +% \end{macrocode} +% First we have to update the current info number for this type. The +% code is a bit complicated because we have to get the number from the +% the plist update it and then put it back. If we would keep the numbers +% differently this could be improved, probably at the cost of more macro +% names. +% \begin{macrocode} + \@temptokena\expandafter{\mark@curr@plist} + \prop@get@NNN\mark@curr@plist#1\@tempa +%<*debug> + \ifx\q@no@value\@tempa + \ERROR + \fi +%</debug> + \@tempcnta\@tempa + \advance\@tempcnta\@ne + \expandafter + \prop@gput@NNn\expandafter\mark@curr@plist\expandafter#1\expandafter + {\the\@tempcnta} +% \end{macrocode} +% Now we want to put this plist into a \TeX{} mark. We need a +% one-level expansion, otherwise our pkeys would expand which would +% produce chaos. So we save it in a toks register. +% \begin{macrocode} + \@temptokena\expandafter{\mark@curr@plist} + \mark + {\the\@temptokena} +% \end{macrocode} +% Finally we shouldn't forget to put the info at the right of the +% corresponding queue. +% Without tracing we can omit the second argument to +% this function. +% \begin{macrocode} +%<*trace> + \queue@gadd@cn{\string#1@seq}{#2} +%</trace> +%<-trace> \queue@gadd@cn{\string#1@seq}% +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\mark@put@Nnn} +% \begin{macrocode} +\def\mark@put@Nnn#1#2#3{ + \mark@put@Nn#1{#2#3}} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\mark@update@structure} +% This function is for use in output routines to initialize the marks +% at the beginning. It is only useful after \TeX{} internally has +% updated |\botmark|. +% \begin{macrocode} +\def\mark@update@structure{ +% \end{macrocode} +% We map a function over all keys in |\mark@last@plist|, in other +% words over all types of marks. This routine will set the marks for +% all types. Finally we set the plist |\mark@last@plist| to the +% plist that was stored in |\botmark|, i.e., to the +% info-numbers from this page. +% \begin{macrocode} + \prop@map@NN\mark@last@plist\mark@retrieve@single@Nn + \expandafter\gdef\expandafter\mark@last@plist\expandafter{\botmark} +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\mark@retrieve@single@Nn} +% This function will be mapped over the plist containing the info-numbers +% from the last page. This means that |#1| will be the key (which is +% simply our type token list pointer and |#2| is the value, i.e. the +% info-number from the last page for this type. +% \begin{macrocode} +\def\mark@retrieve@single@Nn#1#2{ +%<*trace> + \trace@mark@internal + {queue~for~\string#1~ before:~`\tlp@to@str@c{\string#1@seq}'} +%</trace> +% \end{macrocode} +% We retrieve the info number for this type from |\botmark| +% and store the difference in |\@tempcnta|. +% \begin{macrocode} + \@temptokena\expandafter{\botmark}% +%<*trace> + \trace@mark@internal{picking~ up~ from~ output~ \the\@temptokena}% +%</trace> + \prop@get@NNN\botmark#1\@tempa +%<*debug> + \ifx\q@no@value\@tempa + \ERROR + \fi +%</debug> + \@tempcnta\@tempa + \advance\@tempcnta-#2\relax +%<*trace> + \trace@mark@internal + {found~\the\@tempcnta\space entries~ for~ \string#1~ + (new~\@tempa;~old~#2)} +%</trace> +% \end{macrocode} +% Then we decide what to do depending on its value. +% We use |\@tempa|, |\@tempb|, and |\@tempc| to +% temporarily hold the previous, first and last mark for this type. +% \begin{macrocode} + \ifcase\@tempcnta +% \end{macrocode} +% If there haven't been any new marks we leave the queue alone, +% peeking only at its top element and using it for all three marks. +% \begin{macrocode} + \queue@top@cN{\string#1@seq}\@tempa + \let\@tempb\@tempa + \let\@tempc\@tempa + \or +% \end{macrocode} +% When there was one mark of this type, we pop one item for the +% previous mark of this type, and use the remaining item for first +% and last mark. +% \begin{macrocode} + \queue@gpop@cN{\string#1@seq}\@tempa + \queue@top@cN{\string#1@seq}\@tempb + \let\@tempc\@tempb + \else +% \end{macrocode} +% If we had more than one mark for this type we pop one mark for the +% previous mark of this type, then pop another mark for the first +% mark of this type, then pop all but the last item and use the last +% item as the last mark of this type, keeping it as before on the +% queue. +% \begin{macrocode} + \queue@gpop@cN{\string#1@seq}\@tempa + \queue@top@cN{\string#1@seq}\@tempb + \@whilenum \@tempcnta>\@ne\do + {\advance\@tempcnta\m@ne + \queue@gpop@cN{\string#1@seq} + \@tempc + } + \queue@top@cN{\string#1@seq}\@tempc + \fi +% \end{macrocode} +% After this process all values for previous, first and last mark for +% this type are found so that we can store them in the tlp +% representing this type for further processing. +% \begin{macrocode} + \@temptokena\expandafter{\@tempa} + \@temptokenb\expandafter{\@tempb} + \@temptokenc\expandafter{\@tempc} + \edef#1{{\the\@temptokena}{\the\@temptokenb}{\the\@temptokenc}} +%<*trace> + \trace@mark + {in~output:~\string#1~->~\tlp@to@str@N#1} +% \end{macrocode} +% At this point the queue should show only one item. +% \begin{macrocode} + \trace@mark@internal + {queue~ for~\string#1~after:~`\tlp@to@str@c{\string#1@seq}'} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@temptokenb} +% \begin{macro}{\@temptokenc} +% \begin{macrocode} +\newtoks\@temptokenb +\newtoks\@temptokenc +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\mark@curr@plist} +% \begin{macro}{\mark@last@plist} +% Here are the allocations for the two plists used. +% \begin{macrocode} +\prop@new@N\mark@curr@plist +\prop@new@N\mark@last@plist +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% +% +% \begin{macro}{\mark@get@first@N} +% \begin{macro}{\mark@get@last@N} +% \begin{macro}{\mark@get@previous@N} +% To retrieve the first, last or previous page mark, we +% grap the appropriate value stored in the tlp. The marks are stored +% in the tlp in the order previous, first, last mark. These functions +% should be used only in output routines after |\mark@retrieve| has +% acted, otherwise their value will be wrong. They are all fully +% expandable. +% +% Actually, they may bomb when tracing is included and we have +% material that doesn't work corretly within a write. +% \begin{macrocode} +%<*trace> +\def\mark@get@first@N#1{ + \expandafter\@secondofthree#1 + \trace@mark@internal{use~first~\string#1~=~ + `\expandafter\@secondofthree#1'} +} +\def\mark@get@last@N#1{ + \expandafter\@thirdofthree#1 + \trace@mark@internal{use~ last~ \string#1~ =~ + `\expandafter\@thirdofthree#1'} +} +\def\mark@get@previous@N#1{ + \expandafter\@firstofthree#1 + \trace@mark@internal{use~prev~\string#1~ =~ + `\expandafter\@firstofthree#1'} +} +%</trace> +%<-trace>\def\mark@get@first@N{% +%<-trace> \expandafter\@secondofthree} +%<-trace>\def\mark@get@last@N{% +%<-trace> \expandafter\@thirdofthree} +%<-trace>\def\mark@get@previous@N{% +%<-trace> \expandafter\@firstofthree} +% \end{macrocode} +% above version in trace case doesn't work alway! +% \begin{macrocode} +\def\mark@get@first@N{% + \expandafter\@secondofthree} +\def\mark@get@last@N{% + \expandafter\@thirdofthree} +\def\mark@get@previous@N{% + \expandafter\@firstofthree} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\DeclareMarkType} +% \begin{macrocode} +\def\DeclareMarkType#1{ + \expandafter\mark@new\csname mark@#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PutMark} +% \begin{macrocode} +\def\PutMark#1{ + \@ifundefined{mark@#1}{\ERROR}{} + \expandafter\mark@put@Nn\csname mark@#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\PreviousMark} +% \begin{macrocode} +\def\PreviousMark#1{ + \expandafter\mark@get@previous@N\csname mark@#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\FirstMark} +% \begin{macrocode} +\def\FirstMark#1{ + \expandafter\mark@get@first@N\csname mark@#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\LastMark} +% \begin{macrocode} +\def\LastMark#1{ + \expandafter\mark@get@last@N\csname mark@#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \Finale +% +\endinput +% +% $Log: xmarks.dtx,v $ +% Revision 1.6 2000/06/13 20:47:23 latex3 +% docu update +% inlined quarks code +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-alloc.dtx b/Master/texmf-dist/source/latex3/xor/xo-alloc.dtx new file mode 100644 index 00000000000..05250715ccb --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-alloc.dtx @@ -0,0 +1,125 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-alloc.dtx,v 1.4 2000/08/11 07:13:34 latex3 Exp $ +% \end{macrocode} +% +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% |\footins| is FD, should probably move to FE +% +% |\@footins| is FE, should probably go and be replaced by a box and skip allocation +% they don't need to be same number, except for compatibility reasons. +% +% |\@kludgeins| was EA maybe can go, depending on how enlargethispage to be implemented. +% for now, move to FC (which was bx@A +% \begin{macrocode} +\chardef\@kludgeins="FC\relax +\global\dimen\@kludgeins \maxdimen +\global\count\@kludgeins 1000 +\global\dimen\@kludgeins\z@ +\global\skip\@kludgeins\z@ +\global\setbox\@kludgeins\box\voidb@x +% \end{macrocode} +% +% \begin{macrocode} +\insc@unt"FC\relax +% \end{macrocode} +% +% count dimen skip no longer bounded by insertion allocation. +% toks now bounded by insertions. +% \begin{macrocode} +\def\newcount{\alloc@0\count\countdef\@kludgeins} +\def\newdimen{\alloc@1\dimen\dimendef\@kludgeins} +\def\newskip{\alloc@2\skip\skipdef\@kludgeins} +\def\newtoks{\alloc@5\toks\toksdef\insc@unt} +% \end{macrocode} +% +% \begin{macrocode} +\def\newinsert#1{\global\advance\insc@unt \m@ne + \ch@ck4\insc@unt\box + \ch@ck5\insc@unt\toks + \allocationnumber\insc@unt + \global\chardef#1\allocationnumber + \wlog{\string#1=\string\insert\the\allocationnumber}} +% \end{macrocode} +% +% \begin{macrocode} +\newinsert\bx@A +\newinsert\bx@B +\newinsert\bx@C +\newinsert\bx@D +\newinsert\bx@E +\newinsert\bx@F +\newinsert\bx@G +\newinsert\bx@H +\newinsert\bx@I +\newinsert\bx@J +\newinsert\bx@K +\newinsert\bx@L +\newinsert\bx@M +\newinsert\bx@N +\newinsert\bx@O +\newinsert\bx@P +\newinsert\bx@Q +\newinsert\bx@R +% \end{macrocode} +% +% like |\@next| but allocates to list if empty (so doesn't have the +% 4th argument) There is a hidden 3rd argument, picked up by |\@xnext|. +% \begin{macrocode} +\def\@allocating@next#1#2{ + \ifx#2\@empty + \xdef#2{\noexpand\@elt\csname bx@\the\insc@unt\endcsname} + \expandafter\newinsert\csname bx@\the\insc@unt\endcsname + \fi + \expandafter\@xnext #2\@@#1#2} +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} + +% +% \endinput +\endinput +% +% $Log: xo-alloc.dtx,v $ +% Revision 1.4 2000/08/11 07:13:34 latex3 +% added header +% +% Revision 1.3 2000/06/13 20:54:46 latex3 +% made this a dtx file +% +% Revision 1.2 2000/02/22 01:03:55 david +% *** empty log message *** +% +% Revision 1.1 2000/02/22 00:52:52 david +% Initial revision +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-capt.dtx b/Master/texmf-dist/source/latex3/xor/xo-capt.dtx new file mode 100644 index 00000000000..618e22f94d7 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-capt.dtx @@ -0,0 +1,306 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-capt.dtx,v 1.13 2000/08/11 07:14:03 latex3 Exp $ +% \end{macrocode} +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% \subsection{Modifying the caption command} +% +% \begin{macro}{\@caption} +% |\caption| just saves its main argument in a token register. It also +% has |\unskip| and |\ignorespaces| to cope with hmode. +% The format of the token register is:\\ +% \marg{type}\marg{number}\marg{caption text}\marg{extra info}\\ +% The \meta{type} is something like `figure', used to generate the +% relevant command names. \meta{number} is the fully expanded version of +% |\the|\ldots. The last group is unused by the current definition +% but extended packages may use it to pass extra information to the +% float handler, as required. +% \begin{macrocode} +\def\caption{\@dblarg{\@caption\float@type}} + +\long\def\@caption#1[#2]#3{% + \unskip +% \end{macrocode} +% We use the old \LaTeX{} interface with |\addcontentsline| for the +% moment.\footnote{FIX!!} +% \begin{macrocode} + \addcontentsline{\csname toc@extension@#1\endcsname}{#1} +% \end{macrocode} +% The counter used is not |#1| but given by (|\foat@counter|) which +% should perhaps be passed along but isn't: +% \begin{macrocode} + {\protect\numberline{\csname the\float@counter\endcsname} + {\ignorespaces #2}} + \global\toks\@currbox{#3} + \ignorespaces + } +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Adding captions to float boxes} +% +% This should really be a template instance. +% Must \emph{copy} the float body in |\this@float@box| +% into |\this@captioned@float| adding the caption text. +% May use |\this@area|, |\this@area@col@number| and other information, to be +% determined \ldots +% +% \begin{macro}{\append@caption@to@float} +% Combine float body and caption of the current float (``this +% float'') and store it in |\this@captioned@float|. +% \begin{macrocode} +\def\append@caption@to@float{ + \typeset@some@floatbox + \this@type\this@area + \this@float@box{\csname caption@\this@type\endcsname} + \this@usercnt\this@caption\this@span@number +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\append@here@caption@to@float} +% Combine float body and caption of the current here float and +% store it in |\this@captioned@float|. +% \begin{macrocode} +\def\append@here@caption@to@float{ + \typeset@some@floatbox + \here@type{h\the\curr@col@count 1} + \here@float@box{\csname caption@\here@type\endcsname} + \here@usercnt\here@caption\here@span@number +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\typeset@this@float@and@caption} +% Combine float body and caption of the current float (``this +% float'') and output it into the current list. +% \begin{macrocode} +\def\typeset@this@float@and@caption{ + \append@caption@to@float + \box\this@captioned@float +} +% \end{macrocode} +% \end{macro} +% +% +% +% \section{Some primitive templates for testing} +% +% prove of concept only --- not even prototype +% +% +% \begin{macro}{\typeset@some@floatbox} +% The macro |\typeset@some@floatbox| take 7 arguments as follows: +% \begin{description} +% \item[type] type of the float to be typeset +% \item[area] area in which to format the float +% \item[floatbody box] box register in which the body of the float +% is stored +% \item[caption heading] fixed text like ``Figure'' +% \item[caption number] caption number of the float +% \item[caption text] caption text of the float +% \item[span count] span count (normally deducable from the area +% but\ldots +% \end{description} +% The first two arguments are used to decide which formatting +% instance to call, the remaining arguments are passed to that +% instance. +% +% The logic is (at the moment) as follows: if a template instance +% (type \texttt{buildfloat}) with the name +% \meta{type}|-|\meta{area}\footnote{The ``here'' areas are +% denoted as \texttt{h}\meta{col}\texttt{1}.} +% is defined then this instance is used, +% otherwise we look if there is an instance with just the name of +% the \meta{area}, otherwise we try an instance with the name +% \meta{type} and if this isn't defined either we try the instance +% named |default|. +% \begin{macrocode} +\def\typeset@some@floatbox#1#2{ % type area + + \IfExistsInstanceTF{buildfloat} + { #1 - #2 } + {\def\use@instance@named{#1 - #2}} + { + \IfExistsInstanceTF{buildfloat} + { #2 } + {\def\use@instance@named{#2}} + { + \IfExistsInstanceTF{buildfloat} + { #1 } + {\let\use@instance@named#1 } % we know this is a token + {\def\use@instance@named{default}} + } + } + \UseInstance{buildfloat}\use@instance@named +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macrocode} +% #1 body box +% #2 fixed text +% #3 counter value +% #4 caption +% #5 span number +\DeclareTemplateType{buildfloat}{5} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{buildfloat}{centeredabove}{5} + { + body-caption-sep =l [10pt] \belowcaptionskip, + } + { + \DoParameterAssignments + + \@parboxrestore + + \hsize=#5\columnwidth + + \global\setbox\this@captioned@float\vbox{ + \sbox\@tempboxb{#2~ #3:~ #4} + \ifdim \wd\@tempboxb >\hsize + #2~ #3:~ #4\par + \else + \hb@xt@\hsize{\hfil\box\@tempboxb\hfil}% + \fi + \vskip\belowcaptionskip + \centerline{ + \copy#1 + } + \kern\z@ + } + } +% \end{macrocode} +% +% \begin{macrocode} +\newbox\@tempboxb +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{buildfloat}{centeredbelow}{5} + { + body-caption-sep =l [10pt] \abovecaptionskip, + } + { + \DoParameterAssignments + + \@parboxrestore + + \hsize=#5\columnwidth + + \global\setbox\this@captioned@float\vbox{ + \centerline{\copy#1} + \vskip\abovecaptionskip + \sbox\@tempboxb{#2~ #3:~ #4} + \ifdim \wd\@tempboxb >\hsize + #2~ #3:~ #4\par + \else + \hb@xt@\hsize{\hfil\box\@tempboxb\hfil}% + \fi + } + } +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{buildfloat}{bottomright}{5} + { + body-caption-sep =l [10pt] \abovecaptionskip, + } + { + \DoParameterAssignments + + \@parboxrestore + + \hsize=#5\columnwidth + + \global\setbox\this@captioned@float\vbox{ + \@@line{\hss\vbox{\copy#1\kern0pt} + \rlap{ + \hskip\abovecaptionskip +% \end{macrocode} +% rubbish as far as it goes: this should be turned into a real +% template probably using coffins +% \begin{macrocode} + \parbox[b]{\marginparwidth + +(#5\columnwidth-\wd#1)/2}{ + \raggedright + #2~ #3:~ #4 + } + }\hss + } + \kern0pt + } + } +% \end{macrocode} +% +% +% +% \subsection{Some test instances} +% +% \begin{macrocode} +\DeclareInstance{buildfloat}{default}{centeredabove}{} + +\DeclareInstance{buildfloat}{figure}{centeredbelow}{} + +\DeclareInstance{buildfloat}{t31}{bottomright}{} +\DeclareInstance{buildfloat}{t22}{bottomright}{} +\DeclareInstance{buildfloat}{t13}{bottomright}{} +% \end{macrocode} +% +% \endinput +\endinput +% +% $Log: xo-capt.dtx,v $ +% Revision 1.13 2000/08/11 07:14:03 latex3 +% added header +% +% Revision 1.12 2000/08/11 06:47:53 latex3 +% untabify +% +% Revision 1.11 2000/07/19 15:55:53 latex3 +% used \float@type rather than \@captype +% extended buildfloat template to 5 arguments +% +% Revision 1.10 2000/07/10 18:45:23 latex3 +% some normalisation of caption attachment code -- needs more work +% +% Revision 1.9 2000/06/13 20:53:55 latex3 +% docu update +% renamed template type builtfloat to buildfloat +% +% Revision 1.8 2000/05/03 20:16:59 latex3 +% added more arguments to the caption template +% +% Revision 1.7 2000/05/03 20:03:59 latex3 +% fixed typo in macro name +% +% Revision 1.6 2000/05/03 18:52:44 latex3 +% enabling write of toc entries +% adding a prove of concept for caption templates +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-final.dtx b/Master/texmf-dist/source/latex3/xor/xo-final.dtx new file mode 100644 index 00000000000..ad4216ea7a3 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-final.dtx @@ -0,0 +1,1094 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% +% +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-final.dtx,v 1.20 2000/08/11 07:14:09 latex3 Exp $ +% \end{macrocode} +% +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% Update: as of April 3 this now does something reasonable with +% top and bottom floats. The text in between still needs lots of +% attention. No headers/footers/margins/overlays etc etc yet. +% +% There is still a lot of inefficient indirection; this shows where we +% may be able to support more general page-makeup systems. +% +% And not much tracing yet. +% +% \subsection{Text columns} +% +% \begin{macro}{\produce@final@column} +% \begin{macro}{\final@column@with@floats} +% \begin{macro}{\final@column} +% +% This version puts column floats in columns; see below for +% an alternative. It simulates current \LaTeX{} so should not be +% taken as a model for anything useful. +% +% When we remove or modernise this a lot more code from below can go +% too. +% +% \begin{macrocode} +\def\final@column@with@floats { +%<*trace> + \@tracepush{produce@final@column} +%</trace> + \setbox\@outputbox \box\@cclv + + \expandafter + \add@floats@top + \csname area@t1\the\curr@col@count\endcsname + + \ifvoid\footins + \else + \setbox\@outputbox \vbox { + \boxmaxdepth \@maxdepth + \dimen@\dp\@outputbox + \unvbox \@outputbox + \vskip-\dimen@ + \vskip \skip\footins + \color@begingroup + \normalcolor + \footnoterule + \unvbox \footins + \color@endgroup + } + \fi + + \expandafter + \add@floats@bottom + \csname area@b1\the\curr@col@count\endcsname + + \global\setbox\csname col@box@\the\curr@col@count\endcsname + % \vbox { % this should one day become \@colht + \vbox { % this should one day become \@colht + % or else + \@texttop + \dimen@ \dp\@outputbox + \unvbox \@outputbox + \vskip -\dimen@ + \@textbottom + }% + \global \maxdepth \@maxdepth +%<*trace> + \@tracepop{produce@final@column} +%</trace> +} +% \end{macrocode} +% This version does not give special treatment to column floats; it +% simply attachs footnotes and tops/tails. +% +% Probably this should just stuff the main text and footnotes into +% boxes (or a box?) with no extra formatting; all aesthetic handling would +% be done later, when the page is being made-up. +% +% The formatting details are clearly temporary. +% +% \begin{macrocode} +\def\final@column { +%<*trace> + \@tracepush{produce@final@column} +%</trace> + \setbox\@outputbox \box\@cclv + + \ifvoid\footins + \else + \setbox\@outputbox \vbox { + \boxmaxdepth \@maxdepth + \dimen@\dp\@outputbox + \unvbox \@outputbox + \vskip-\dimen@ + \vskip \skip\footins + \color@begingroup + \normalcolor + \footnoterule + \unvbox \footins + \color@endgroup + } + \fi + +% \end{macrocode} +% +% I am not sure if texttop/bottom should survive for long: something +% more spohisictaed is needed these days. This may mean that +% footnotes need better handling too: what makes a complex column +% look good? +% +% \begin{macrocode} + \global\setbox\csname col@box@\the\curr@col@count\endcsname + \vbox { % this should one day become \@colht + % or else + \@texttop + \dimen@ \dp\@outputbox + \unvbox \@outputbox + \vskip -\dimen@ + \@textbottom + }% + \global \maxdepth \@maxdepth +%<*trace> + \@tracepop{produce@final@column} +%</trace> +} +\let \produce@final@column \final@column +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\add@floats@top} +% \begin{macro}{\add@floats@bottom} +% These are now used (if at all) +% only within columns (maybe not best even there). +% +% \begin{macrocode} +\def\add@floats@top #1{ + \ifx#1\@empty + \else + \setbox\@tempboxa \vbox{} + \let \@elt \@comflelt #1 + \setbox\@outputbox \vbox{ + \boxmaxdepth \maxdepth + \unvbox\@tempboxa + \vskip -\pagesetup@float@float@sep + \topfigrule + \vskip \pagesetup@float@text@sep + \unvbox\@outputbox + } + \let\@elt\relax + \release@floats#1 + \fi +} +% \end{macrocode} +% +% \begin{macrocode} +\def\add@floats@bottom#1{ + \ifx#1\@empty + \else + \setbox\@tempboxa \vbox{} + \let\@elt\@comflelt + #1 + \setbox\@outputbox \vbox{ + \unvbox\@outputbox + \vskip \pagesetup@float@text@sep + \botfigrule + \unvbox\@tempboxa + \vskip -\pagesetup@float@float@sep + } + \let\@elt\relax + \release@floats#1 + \fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% \subsection{Shipout and housekeeping} +% +% +% \begin{macro}{\absolute@page@number} +% \begin{macrocode} +\mathchardef\absolute@page@number\c@page +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} + +% \end{macrocode} +% +% \begin{macro}{\produce@final@page} +% +% This puts everything to be shipped out into the hbox +% |\page@box| and then ships this out (not quite, see below!). +% +% Probably these two processes should be separated. +% +% At present it does the page-makeup within the shipped out box; +% this should proably be done earlier. +% +% Should the box (or the box-name) be a global +% fixed object (bad;-) or a local parameter (good;-)? +% +% The shipping out is surrounded by considerable housekeeping: +% this version sets up to do the writes and fixes the +% numbering. +% +% \begin{macrocode} +\def\produce@final@page{ +%<*trace> + \@tracepush{produce@final@page} + \tr@ce{final~ page~ output:~ Chris'~ version} +%</trace> + \begingroup % the \endgroup is put in by \aftergroup +% \end{macrocode} +% +% \begin{macrocode} + \@resetactivechars + \@parboxrestore + \let \protect \noexpand +% \end{macrocode}% +% Temp: just puts stuff into lists (which could have been built up +% as floats are placed?). +% \begin{macrocode} + \do@floats + \shipout \hbox { % NOTE: an hbox now! +% \end{macrocode} +% +% \begin{macrocode} + \set@typeset@protect + \aftergroup \endgroup + \aftergroup \set@typeset@protect +% \end{macrocode} +% Making the box can be done outside the shipout. +% \begin{macrocode} + \make@page@box + \box \page@box + } +% \endgroup %% This is _implicitly_ here. +% \end{macrocode} +% +% \begin{macrocode} + \count@\absolute@page@number +%<*trace> + \tr@ce{absolute~page:~\the\absolute@page@number} +%</trace> + \advance\count@\@ne + \global\advance\c@page\@ne + \global\mathchardef\absolute@page@number\count@ +%<*trace> + \@tracepop{produce@final@page} +%</trace> +} + +% \end{macrocode} +% \end{macro} +% +% \subsection{The page box} +% +% \begin{macro}{\mbox@addtopage} +% \begin{macro}{\box@addtopage} +% \begin{macro}{\page@box} +% This should be generalised to add a box to any box (without overcrowding). +% \begin{macrocode} +\newbox \page@box +\def\mbox@addtopage (#1,#2)#3{% +%<*trace> + \tr@ce{box~being~added~to~page:~at~(#1,~#2) + } +%</trace> + \global \setbox\page@box + \hbox { + \unhbox \page@box + \mbox@put (#1,#2) {#3} + } +} +\def\box@addtopage (#1,#2)#3{% + \mbox@addtopage (#1,#2){\box #3} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\make@page@box} +% +% This adds stuff to a globallly named box; maybe it should be more +% generic. +% +% This is some kind of default example. +% It should be templated. +% +% \begin{macrocode} +\def \make@page@box { +%<*trace> + \@tracepush{make@page@box} + \tr@ce{new style page nake-up} +%</trace> +% \end{macrocode} +% Temp for current header: +% \begin{macrocode} + \mbox@addtopage (\pagebodylefthpos, \headheight) + {page:~\thepage} +% \end{macrocode} +% Then add the float areas, using a list of boxes and positions. +% Probably, the whole thing should be done this way but this may +% not be sensible for simple cases. +% +% Also, some alignments (eg text) may be better handled by the +% use of coffins (which are a very similar, but more complex, +% technology). +% +% First set-up starting point for main text body. +% \begin{macrocode} + \forall@columns { + \expandafter \xdef + \csname stack@level@\the\curr@col@count \endcsname + {\pagebodytopvpos} + } + \stack@top@areas + \add@columns + \stack@bot@areas +%<*trace> + \@tracepop{make@page@box} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{The page box: text columns} +% +% This needs to be a lot more sophisticated in order to make these +% look anything but dreadful. +% +% \begin{macro}{\add@columns} +% \begin{macro}{\add@columns@topstacked} +% \begin{macro}{\add@columns@botaligned} +% +% Several possibilities here: choose one. +% +% One way to do bottom-aligned columns (probably will not +% generalise well): +% \begin{macrocode} +\def \add@columns@botaligned { +%<*trace> + \@tracepush{add@columns@botaligned} +%</trace> + \setlength \@tempdima {\pagebodylefthpos} + \forall@columns { +%<*trace> + \tr@ce{bot~aligned~column~\the\curr@col@count :~% + ht=\expandafter\the\expandafter\ht + \csname col@box@\the\curr@col@count \endcsname,~ + dp=\expandafter\the\expandafter\dp + \csname col@box@\the\curr@col@count \endcsname} +%</trace> +% \end{macrocode} +% Rules will need to be handled separately: where do they go in +% general with spanning floats? +% \begin{macrocode} +% \vrule + \box@addtopage ( \@tempdima, \pagebodybotvpos ) + {\csname col@box@\the\curr@col@count \endcsname} + \setlength \@tempdima {\@tempdima + \columnwidth + \columnsep} +% \vrule + } +%<*trace> + \@tracepop{add@columns@botaligned} +%</trace> +} +% \end{macrocode} +% +% Stacking them at the top: this must be dome immediately after +% stacking the top areas. They are aligned, if possible, at the +% top (the actual top, not necessarily the top text line). +% +% \begin{macrocode} +\def \add@columns@topstacked { +%<*trace> + \@tracepush{add@columns@topstacked} +%</trace> + \gsetmlength \cuur@col@pos {\pagebodylefthpos} + \forall@columns { +%<*trace> + \tr@ce{top~stacked~column~\the\curr@col@count :~% + ht=\expandafter\the\expandafter\ht + \csname col@box@\the\curr@col@count \endcsname,~ + dp=\expandafter\the\expandafter\dp + \csname col@box@\the\curr@col@count \endcsname} + \tr@ce{vsize~for~column~\the\curr@col@count~was:~% + \csname col@ht@ \the\curr@col@count\endcsname} + \tr@ce{lowered~column~\the\curr@col@count~:~% + \csname stack@level@\the\curr@col@count \endcsname + } +%</trace> + \gsetmlength@c {stack@level@\the\curr@col@count} + { \csname stack@level@\the\curr@col@count \endcsname + + \expandafter + \ht \csname col@box@\the\curr@col@count \endcsname + } +% \end{macrocode} +% Vertical rules will need to be handled differentlyy: +% where do they go in general with spanning floats? +% \begin{macrocode} +% \vrule + \box@addtopage ( \cuur@col@pos, + \csname stack@level@\the\curr@col@count \endcsname ) + {\csname col@box@\the\curr@col@count \endcsname} + \gsetmlength \cuur@col@pos { \cuur@col@pos + \columnwidth + \columnsep} +% \vrule + } +%<*trace> + \@tracepop{add@columns@topstacked} +%</trace> +} +\let \add@columns \add@columns@topstacked +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{The page box: float areas} +% +% \begin{macro}{\t@stack@area} +% \begin{macro}{\b@stack@area} +% +% The 4th argument must be a procedure that fills a box whose number +% is its last argument. This rather bizarre code merely avoids +% a box-register-per-area. +% +% \begin{macrocode} +\def\t@stack@area #1#2#3#4{ +%<*trace> + \@tracepush{t@stack@area} +%</trace> + #4 \@tempboxa +% \end{macrocode} +% First update stacking position for these columns. +% \begin{macrocode} + \@tempcnta #2 + \@tempcntb #3 \relax + \setlength \@tempdimb {\ht\@tempboxa + \dp\@tempboxa} + \loop + \@tempdima \csname stack@level@\the\@tempcntb \endcsname + \advance \@tempdima \@tempdimb + \expandafter + \xdef \csname stack@level@\the\@tempcntb \endcsname + { \the\@tempdima } + \advance \@tempcntb \@ne + \advance \@tempcnta \m@ne + \ifnum \@tempcnta > \z@ + \repeat +% \end{macrocode} +% Calculate horizontal displacement. +% \begin{macrocode} + \setlength \@tempdima + {\pagebodylefthpos - \columndisplacement + \columndisplacement * #3} +% \end{macrocode} +% Add box. +% \begin{macrocode} +%<*trace> + \tr@ce{float~area~box~#1#2#3~~lowered~:~% + \csname stack@level@#3 \endcsname + } +%</trace> + \box@addtopage (\@tempdima,\csname stack@level@#3\endcsname) + \@tempboxa +%<*trace> + \@tracepop{t@stack@area} +%</trace> +} +% \end{macrocode} +% Different order for co-stacking. +% \begin{macrocode} +\def\b@stack@area #1#2#3#4{ +%<*trace> + \@tracepush{b@stack@area} +%</trace> + #4 \@tempboxa +% \end{macrocode} +% Calculate horizontal displacement. +% \begin{macrocode} + \setlength \@tempdima + {\pagebodylefthpos - \columndisplacement + \columndisplacement * #3} +% \end{macrocode} +% Add box. +% \begin{macrocode} + \box@addtopage (\@tempdima,\csname stack@level@#3\endcsname) + \@tempboxa +% \end{macrocode} +% Then update stacking position for these columns. +% \begin{macrocode} + \@tempcnta #2 + \@tempcntb #3 \relax + \setlength \@tempdimb {\ht\@tempboxa + \dp\@tempboxa} + \loop + \@tempdima \csname stack@level@\the\@tempcntb \endcsname + \advance \@tempdima -\@tempdimb + \expandafter + \xdef \csname stack@level@\the\@tempcntb \endcsname + { \the\@tempdima } + \advance \@tempcntb \@ne + \advance \@tempcnta \m@ne + \ifnum \@tempcnta > \@ne + \repeat +%<*trace> + \@tracepop{b@stack@area} +%</trace> +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\stack@top@areas} +% \begin{macro}{\stack@bot@areas} +% +% Use of these is all a bit ad hoc for a particular stacking system. +% +% \begin{macrocode} +\def \stack@bot@areas { + \stack@areas@list b \pagebodybotvpos \pagebox@list@b +} +\def \stack@top@areas { + \stack@areas@list t \pagebodytopvpos \pagebox@list@t +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\stack@areas@list} +% +% |#1| : stacking type (t, b or c at present)\\ +% |#2| : starting position\\ +% |#3| : list name +% +% \begin{macrocode} +\def \stack@areas@list #1#2#3 { +%<*trace> + \@tracepush{stack@areas@list} +%</trace> + \ifx #3 \@empty + \else + \forall@columns { +% \end{macrocode} +% Starting point: +% \begin{macrocode} +% \vrule + \expandafter \xdef + \csname stack@level@\the\curr@col@count \endcsname + {#2} + } +% \end{macrocode} +% Stacking or co-stacking: bottom-up or top-down. +% \begin{macrocode} + \expandafter + \let \expandafter + \p@elt \csname #1@stack@area \endcsname + #3 + \fi +%<*trace> + \@tracepop{stack@areas@list} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\make@area@floats@box} +% +% Format all the floats in a list and store the result in a box register. +% This should be templated. +% +% This could do the file-writing too. +% +% |#1| : area-name\\ +% |#2| : box to be filled +% +% \begin{macrocode} +\def\make@area@floats@box #1#2 { +%<*trace> + \@tracepush{make@area@floats@box} +%</trace> + \setbox #2 \vbox{} +% \let \@elt \@comflelt % Big aaah! + \def \@elt { \typeset@float@in@box {#2} } + \csname area@#1\endcsname +% \end{macrocode} +% Not very pretty yet! But better when decoration +% stuff is used. +% \begin{macrocode} + \let \@elt \relax + \expandafter + \release@floats + \csname area@#1\endcsname +%<*trace> + \@tracepop{make@area@floats@box} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{DECORATIONS} +% Not used at present but something like this is probably needed. +% +% \begin{macrocode} + +\def \box@decorate@bot #1 { + \setbox #1 \vbox{ + \vskip \pagesetup@float@text@sep + \botfigrule + \unvbox #1 + \vskip -\pagesetup@float@float@sep + } +} +\def \box@decorate@top #1 { + \setbox #1 \vbox{ + \unvbox #1 + \vskip -\pagesetup@float@float@sep + \topfigrule + \vskip \pagesetup@float@text@sep + } +} + + +% \end{macrocode} +% \end{macro} +% +% +% \subsection{The page box: margins} +% +% Needed? +% +% \subsection{The page box: headers and footers} +% +% Nothing worth puting here yet. +% +% \subsection{The page box: other} +% +% Maybe should be many subsections: eg overlays. +% +% \subsection{Typesetting captions and float boxes} +% +% All more or less temporary. +% +% \begin{macro}{\@comflelt} +% \begin{macro}{\typeset@float@in@box} +% +% Maybe a bad name but this is probably as generic as it can be at +% present (and one would hate to see the name's demise). +% +% \begin{macrocode} +\def\@comflelt #1 { + \global \let \this@float@box #1 + \expandafter + \extract@this@float@actual@structure \the\toks #1 + \setbox\@tempboxa \vbox { + \unvbox\@tempboxa + \typeset@this@float@and@caption + } + } +% \end{macrocode} +% +% Thus sadly we maybe should move to this, avoiding the use of a +% global variable for parameter passing. +% +% \begin{macrocode} +\def\typeset@float@in@box #1 #2 { + \global \let \this@float@box #2 + \expandafter + \extract@this@float@actual@structure \the\toks #2 + \setbox #1 \vbox { + \unvbox #1 + \typeset@this@float@and@caption + } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\typeset@this@float@and@caption} +% +% This should really be a template instance. +% +% It must be integrated with the generic version of +% |\append@caption@to@float| since they must both do the same thing. +% +% May use |\this@area|, |\this@area@col@number| and other information, +% to be determined \ldots even |\this@caption@action|. +% +% First we disable premature captioning (fascist or what?). +% +% \begin{macrocode} +%<*obsolete> +\let\add@caption@to@float@box \relax +%</obsolete> + +%<*obsolete> +\def \typeset@this@float@and@caption { + \box\this@float@box + \nobreak + \smallskip + \hsize\columnwidth + \this@caption \par + \bigskip + \hrule + \vskip\pagesetup@float@float@sep + } +% Reminder ABOVE ONLY WORKS WITH THIS: +% \def\append@caption@to@float{ +% \global\setbox\this@captioned@float\vbox{ +% \copy\this@float@box +% \smallskip +% \hsize\columnwidth +% \this@caption +% \par\bigskip\hrule} +% } +%</obsolete> +% \end{macrocode} +% \end{macro} +% +% \subsection{Page box lists} +% +% \begin{macro}{\pagebox@area} +% \begin{macro}{\@addto@pagebox@list} +% +% Bad names? +% +% Add the float areas to a page-box list, and specify how to +% process them. This should be templated. The columns could be added +% to this list. +% +% The 2nd argument must at present be a procedure that has two +% arguments and it is expected to fill a box whose number +% is its last argument. This rather bizarre code merely avoids +% a box-register-per-area. +% +% |#1| : area-name +% |#2| : action for each float in area +% |#3| : area-position +% +% \begin{macrocode} +\def\pagebox@area #1#2#3 { +%<*trace> + \@tracepush {pagebox@area} +%</trace> + \expandafter + \let \expandafter + \this@list \csname area@#1\endcsname +%<*trace> + \tr@ce{adding~ floats~ (if any)~ #1~ ==~ `\this@list'~ + to~page~list:~#3 } +%</trace> + \ifx \this@list \@empty + \else + \let \p@elt \relax + \@addto@pagebox@list {#3} + { \p@elt #1 { #2 {#1}} } + \fi +%<*trace> + \@tracepop {pagebox@area} +%</trace> +} +% \end{macrocode} +% Ugh!! Improve? +% \begin{macrocode} +\def \@addto@pagebox@list #1#2 { + \@temptokena \expandafter\expandafter\expandafter + { \csname pagebox@list@#1 \endcsname + #2 + } + \expandafter + \xdef + \csname pagebox@list@#1 \endcsname + { \the\@temptokena } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \subsection{Magic boxes} +% +% \begin{macro}{\mbox@put} +% \begin{macro}{\box@put} +% \begin{macro}{\copy@put} +% +% Probably move sometime.\footnote{Move?} +% +% These add boxes with the specified visual relative position +% but all-zero dimensions (unlike picture mode where the inner +% boxes have non-zero vertical size). A highly generalised lap-box! +% +% At present these use Don Knuth's left-handed DVI co-ordinate +% system. They could (should?) be changed to a saner system as used +% by \LaTeX{}, Postscript and the rest of the known civilised world +% since Descartes. +% +% \begin{macrocode} +\def\mbox@put (#1,#2)#3{% + \setbox\@tempboxa \hbox { +% \raise #2 % Ugh! Zany y-direction--- + \lower #2 % thanks Don! + \hbox {\kern#1 #3\hss} + } +% \end{macrocode} +% For this application we must zero everything. +% \begin{macrocode} + \wd \@tempboxa \z@ + \ht \@tempboxa \z@ + \dp \@tempboxa \z@ + \box\@tempboxa + } +% \end{macrocode} +% +% \begin{macrocode} +\def\box@put (#1,#2)#3{% + \mbox@put (#1,#2) {\box #3} +} +% \end{macrocode} +% +% \begin{macrocode} +\def\copy@put (#1,#2)#3{ + \mbox@put (#1,#2) {\copy #3} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Move me!} +% +% Stuff for elsewhere; maybe to xo-new right now? +% +% \begin{macro}{\forall@areas} +% \begin{macro}{\def \make@useful@list@aux} +% \begin{macro}{\def \make@useful@list} +% Area list stuff\footnote{Probably move.}. +% +% These should be more generally used/available whatever area lists, +% however impemnted, we end up with. +% +% This list manipulation stuff works only for lists whose elements are +% unexpandable; this could be extended. +% \begin{macrocode} +\def \forall@areas #1 { + \def \area@elt ##1##2##3 { + \def \curr@area {##1##2##3} + \def \curr@pos {##1} + \def \curr@col {##3} + \def \curr@span {##2} + #1 + } + \used@areas@exec +} + +\def \make@useful@list@aux #1#2#3 { + \ifx #1 \relax + \else + \expandafter + \xdef \csname \temp@list@name @exec \endcsname + {\csname \temp@list@name @exec \endcsname \temp@list@elt #1#2#3 } + \expandafter + \make@useful@list@aux + \fi +} +\def \make@useful@list #1 #2 { + \edef \temp@list@name + {\expandafter \@gobble \string #1} + \def \temp@list@elt {#2} + \let #2 \relax + \expandafter + \let \csname \temp@list@name @exec \endcsname \@empty + \expandafter + \make@useful@list@aux #1\relax\relax\relax +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\release@floats} +% +% \begin{macrocode} +\def\release@floats#1{ +% \show #1 + \xdef \@freelist {\@freelist#1} + \global\let#1\@empty +} +% \end{macrocode} +% \end{macro} +% +% More helper functions (some not yet used)\footnote{To be moved}. +% +% Lettings. +% +% \begin{macro}{\let@nc} +% \begin{macro}{\let@cn} +% \begin{macro}{\let@cc} +% \begin{macrocode} +\def \let@nc #1 #2 { + \expandafter + \let \expandafter + #1 \csname #2\endcsname +} +\def \let@cn #1 { + \expandafter + \let \csname #1\endcsname +} +\def \let@cc #1 { + \expandafter + \let@nc \csname #1\endcsname +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% Macrised lengths etc. +% +% \begin{macro}{\setmlength} +% \begin{macro}{\gsetmlength} +% \begin{macrocode} +\def \gsetmlength #1#2 { + \setlength \@tempdima {#2} + \xdef #1 {\the\@tempdima} +} +\def \gsetmlength@c #1#2 { + \setlength \@tempdima {#2} + \expandafter + \xdef \csname #1\endcsname + {\the\@tempdima} +} +\def \setmlength #1#2 { + \setlength \@tempdima {#2} + \edef #1 {\the\@tempdima} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Really temp stuff} +% +% \begin{macro}{TEMP@KLUDGES} +% Some very temporary (very bad) examples and kludges: +% \begin{macrocode} +\def \do@floats { +%<*trace> + \@tracepush{do@floats} +%</trace> + \make@useful@list \used@areas \area@elt + \let \pagebox@list@t \@empty + \let \pagebox@list@b \@empty + \forall@areas { + \expandafter + \pagebox@area + \expandafter + {\curr@area} \make@area@floats@box {\curr@pos} + } +%<*trace> + \tr@ce{ + pagebox~list:~t~ is~\meaning \pagebox@list@t} + \tr@ce{ + pagebox~list:~b~ is~\meaning \pagebox@list@t} + \@tracepop{do@floats} +%</trace> +} + +% \end{macrocode} +% +% Temp place for these calcs. They should be part of the page layout +% set-up.\footnote{Move?} +% Temp positioning stuff: +% \begin{macrocode} +\AtBeginDocument { +%% vert + \setlength \@tempdima {\headheight + \headsep} + \xdef \pagebodytopvpos {\the\@tempdima} + + \setlength \@tempdima {\@tempdima + \textheight} + \xdef \pagebodybotvpos {\the\@tempdima} + +%% horiz + \setlength \@tempdima {\columnwidth + \columnsep} + \xdef \columndisplacement {\the\@tempdima} + + \def \pagebodylefthpos {\z@} % or whatever?) + +% \show \pagebodytopvpos +% \show \pagebodybotvpos +% +% \showthe \headheight +% \showthe \headsep +% \showthe \textheight +% \showthe \textwidth +% \showthe \columnwidth +} + +% \end{macrocode} +% \end{macro} +% +% \endinput +\endinput +% +% $Log: xo-final.dtx,v $ +% Revision 1.20 2000/08/11 07:14:09 latex3 +% added header +% +% Revision 1.19 2000/07/19 15:56:46 latex3 +% removed \extract@this@float@actual@structure (is now in xo-or awaiting +% normalisation with similar commands) +% +% Revision 1.18 2000/07/10 18:46:11 latex3 +% mainly macro renamings +% +% Revision 1.17 2000/06/16 11:20:40 latex3 +% rename \construct@and@test@col@height to \construct@and@test@col@ht +% rename \construct@and@test@col@heights to \construct@and@test@col@hts +% rename \cl@height1 to \@col@ht@1 (etc) +% +% Revision 1.16 2000/06/13 21:17:32 latex3 +% move setting of \protect so that it works +% +% Revision 1.15 2000/04/12 20:52:39 car2 +% Much tidyng: farewell comflelt! +% +% Revision 1.14 2000/04/06 22:14:00 car2 +% added caption setting +% +% Revision 1.13 2000/04/03 12:09:28 car2 +% alpha version +% +% Revision 1.12 2000/04/03 10:59:31 car2 +% Untidy alpha +% +% Revision 1.11 2000/03/30 21:06:28 car2 +% Chris' alpha-minus version +% +% Revision 1.10 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.9 2000/03/22 15:29:42 latex3 +% some normalisations of names +% +% Revision 1.8 2000/03/09 14:44:31 latex3 +% *** empty log message *** +% +% Revision 1.7 2000/03/05 19:38:12 latex3 +% support multiple columns (6 max right now) +% +% Revision 1.6 2000/02/26 18:25:10 david +% release floats changes +% +% Revision 1.5 2000/02/16 17:34:31 latex3 +% bit of extra tracing to find why columns do not align (no good :-) +% +% Revision 1.4 2000/02/16 13:39:47 latex3 +% added 3col support +% +% Revision 1.3 2000/02/16 10:19:03 latex3 +% better code for adding floats to column (using \pagesetup@float@text@sep and friends) +% +% Revision 1.2 2000/02/13 22:28:10 latex3 +% moved some stuff from xo-or.sty to this file +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-float.dtx b/Master/texmf-dist/source/latex3/xor/xo-float.dtx new file mode 100644 index 00000000000..cc552fe25b0 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-float.dtx @@ -0,0 +1,950 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-float.dtx,v 1.32 2000/08/11 07:14:11 latex3 Exp $ +% \end{macrocode} +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% +% \begin{macro}{\@xfloat} +% The start of a float environment. +% Unlike \LaTeXe, now save the float as a horizontal list. +% \begin{macrocode} +\def\@xfloat #1[#2]{% +%<*trace> +\@tracepush{float~environment} +%</trace> + \@nodocument +% #2 is either user suplied or \fps@#1 (from 2e again) + \def \@fps {#2} + \def \float@type {#1} +% \end{macrocode} +% Next line could be inline since it is used only once +% now.\footnote{Change?} +% \begin{macrocode} + \expandafter \let \expandafter + \float@sequence@class \csname sequence@class@#1 \endcsname +% \end{macrocode} +% +% \begin{macrocode} + \expandafter \let \expandafter + \float@counter \csname counter@#1 \endcsname +% \end{macrocode} +% Floats (not caption) increment counter: +% \begin{macrocode} + \refstepcounter\float@counter + \ifhmode + \@bsphack + \fi + \ifinner + \@parmoderr\@floatpenalty\z@ + \else + \@allocating@next\@currbox\@freelist + { +% +% not used any longer: +% +% \global\expandafter\let\csname fps@\the\@currbox\endcsname +% \@fps +% \global\expandafter\let\csname ftype@\the\@currbox\endcsname +% \@captype +% + \global\advance\float@sequence@count\@ne + \expandafter\PutMark\expandafter\float@sequence@class\expandafter{ + \the\float@sequence@count} + \global\toks\@currbox{} + } + \fi +% \end{macrocode} +% +% Save |\@currbox| as an |\hbox|. +% \begin{macrocode} + \global\let\@saved@label\@empty + \global \setbox\@currbox +% \end{macrocode} +% The float body is typeset in a normalised environment, i.e.., we +% reset colour and font. This is followed by a call to +% |\body@|\meta{type} to allow the designer to set up special +% conventions for each float type, e.g., a special font or font +% size or a special colour, etc. +% \begin{macrocode} + \hbox \bgroup\color@begingroup + \normalcolor + \normalfont + \normalsize + \csname body@\float@type \endcsname + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@endfloatbox} +% The end of a float environment. +% First finish off the box assignment. Then make a copy in a second box. +% The current code makes use of the fact that the allocated boxes +% are in two continuous runs, |\sbx@offset| apart. +% \begin{macrocode} +\def \@endfloatbox{% + \unskip + \outer@nobreak + \color@endgroup + \egroup + \edef\@tempa{ + \global\toks\@currbox{ + {\the\toks\@currbox}{\SPANCNT} + {\@saved@label} + {\csname the\float@counter \endcsname} + {\@fps} + {\float@type} + {\the\float@sequence@count} + }} + \@tempa +%<*trace> +\tr@ce{\the\toks\@currbox} +%</trace> +% \end{macrocode} +% Simple temporary interface to get here floats for testing. Needs +% replacment!\footnote{FIX!!!} +% \begin{macrocode} + \def\@tempa{h} + \ifx\@fps\@tempa + \setup@here@float + \else + \@cons\@activelist\@currbox + \fi +%<*trace> +\@tracepop{float~environment} +%</trace> +} + +\def\SPANCNT{} %%% do properly one day: David + + +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\float@sequence@count} +% |\float@sequence@count| is the counter used to uniquely refer +% to the floats, it is incremented whenever we encounter a new float. +% \begin{macrocode} +\newcount\float@sequence@count +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\label} +% Modify to save the label string. +% \begin{macrocode} +\def\label#1{\@bsphack + \gdef\@saved@label{#1} + \protected@write\@auxout{}% + {\string\newlabel{#1}{{\@currentlabel}{\thepage}}}% + \@esphack} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \begin{macro}{\DeclareFloatType} +% A float type is an identifier like ``figure'' the defines a class +% (?) of floats of floats which have certain attributes in common, +% e.g., they have the same fixed caption text (e.g. \texttt{Fig}), +% they use the same counter to number the floats, etc. +% +% Setting up a float type is done by declaring an instance of type +% \texttt{floattypesetup} and then executing it. +% \begin{macrocode} +\def\DeclareFloatType#1#2{ + \DeclareInstance{floattypesetup}{#1}{std} + { type-id = #1, #2 } + \UseInstance{floattypesetup}{#1} +} +% \end{macrocode} +% +% For each float type \texttt{TYPE} the following utility macros +% hold important static data. +% +% \DescribeMacro\sequence@class@TYPE +% The |\sequence@class@TYPE| holds the name of the float sequence +% class the float type |TYPE| belongs to. A sequence class contains +% all types which should be placed in order of their call-outs, +% e.g., if type ``figure'' and ``table'' are in the same sequence +% class a table whose call-out is later than that of a figure will +% not be placed before it. If on the other hand these types are in +% different sequence classes such reordering will be undertaken by +% the placement algorithm if feasible. +% +% +% \DescribeMacro\toc@extension@TYPE +% The |\toc@extension@TYPE| holds the file extension to which +% caption information for this type is written, e.g., |lot| for +% tables, or |lof| for figures. If there is the desire to produce +% combined listing one can use the same extension for different +% float types.\footnote{This functionality can alternatively be +% provided by putting all captions into a single external file and +% then ignore certain entries when reading the data back, so it +% might vanish again.} +% +% +% \DescribeMacro\fps@TYPE +% The |\fps@TYPE| holds the default float areas in which this float +% type is allowed to go. By default this is the full list of all +% known areas. By restricting it to a subset of areas it is +% possible to provide special placement arrangements, e.g., tables +% always at the bottom only. +% +% +% \DescribeMacro\caption@TYPE +% The |\caption@TYPE| holds the fixed caption text which is +% displayed together with the caption number, e.g., |Figure|, +% etc. This is passed to the caption formatting instances. +% +% +% \DescribeMacro\counter@TYPE +% The |\counter@TYPE| holds the name of the counter to use for +% numbering the floats of type |TYPE|. It is possible that +% different types share the same counter, i.e., are numbered as a +% single sequence. However in that case one should probably ensure +% that the types belong to a single float sequence class since +% otherwise the numbers within the document might get out of +% sequence. On the other hand it is not required to have floats in +% the same sequence class share a counter; they can be numbered +% independently without problems. +% +% \DescribeMacro\body@TYPE +% The |\body@TYPE| holds the formatting instructions that should be +% applied to the body of each float of type |TYPE|. +% +% \begin{macrocode} +\DeclareTemplateType{floattypesetup}{0} + +\DeclareTemplate{floattypesetup}{std}{0}{ + type-id =n \floattypesetup@id, + sequence-class-id =n \floattypesetup@class@id, + toc-extension =n \floattypesetup@toc@ext, + default-area-list =n \floattypesetup@area@list, + caption-text =n \floattypesetup@caption@text, + numbered-boolean =b @test, + numbered-id =n \floattypesetup@numbered@id, + numbered-within-id =n \floattypesetup@numbered@within@id, + numbered-action =f0 \floattypesetup@numbered@action, + body-decls =f0 \floattypesetup@body@decls, + + } + { +% \end{macrocode} +% Setting up defaults is done (at least in parts) in two steps: +% first we set certain key commands to |\relax| then we run +% |\DoParameterAssignments| and then check if they are still +% |\relax|. If so we set the commands that we really want to +% set. This is necessary because several of them have names that +% contain the float type as part of the name and this type name is +% one of the keys. +% \begin{macrocode} + \let\floattypesetup@class@id\relax + \let\floattypesetup@numbered@id\relax + \let\floattypesetup@numbered@action\relax + \let\floattypesetup@body@decls\relax +% \end{macrocode} +% Now for the defaults we can set directly: +% the |@test| switch is locally used to denote that we want to +% number the floats. +% \begin{macrocode} + \@testtrue % number by default +% \end{macrocode} +% The areas which should be tried for the current type are by +% default all areas, i.e., |\known@areas|; we use |\def| not |\let| +% to allow this list to grow afterwards. +% \begin{macrocode} + \def\floattypesetup@area@list{\known@areas} +% \end{macrocode} +% Default for the fixed caption text is |\@empty|. +% \begin{macrocode} + \let\floattypesetup@caption@text\@empty +% \end{macrocode} +% By default we don't run the float counter within another +% counter. We use |\@empty| to denote this since this is also what +% would be returned from |numbered-within-id=,| which might be +% specified by a user. +% \begin{macrocode} + \let\floattypesetup@numbered@within@id\@empty +% \end{macrocode} +% Everything goes by default to the |.toc| file (which isn't too +% bad if the extended \texttt{xcontents} package is used. +% \begin{macrocode} + \def\floattypesetup@toc@ext{toc} % everything in here by default +% \end{macrocode} +% Now we are ready to look at the designer specifications: +% \begin{macrocode} + \DoParameterAssignments +% \end{macrocode} +% Now for the second step: evaluate what we have: If the +% |sequence-class-id| is not set up, we try to default it to the +% |type-id|: +% \begin{macrocode} + \ifx\floattypesetup@class@id\relax + \let\floattypesetup@class@id\floattypesetup@id + \fi +% \end{macrocode} +% Float numbers are only set up if requested (which is the default). +% \begin{macrocode} + \if@test +% \end{macrocode} +% If the |numbered-id| is not set up, we try to default it to +% the |type-id|:\footnote{This needs fixing since part of the float +% handling assumes there is some counter to step etc. FIX!} +% \begin{macrocode} + \ifx\floattypesetup@numbered@id\relax + \let\floattypesetup@numbered@id\floattypesetup@id + \fi +% \end{macrocode} +% Set up the new counter, if it already exists skip this part: +% \begin{macrocode} + \expandafter\ifx\csname c@\floattypesetup@numbered@id \endcsname + \relax + \ifx\floattypesetup@numbered@within@id\@empty + \newcounter\floattypesetup@numbered@id + \else + \newcounter\floattypesetup@numbered@id + [\floattypesetup@numbered@within@id] + \fi +% \end{macrocode} +% The default display for the float number is ``arabic'', we +% overwrite this only if requested: +% \begin{macrocode} + \ifx\floattypesetup@numbered@action\relax + \else + \global\expandafter\let + \csname the\floattypesetup@numbered@id \endcsname + \floattypesetup@numbered@action + \fi + \fi + \fi +% \end{macrocode} +% +% Low-level environment declaration (allows overwriting since +% figure etc already exists)\footnote{Handle better?} +% \begin{macrocode} + \expandafter + \xdef\csname \floattypesetup@id \endcsname + {\noexpand\@float{\floattypesetup@id}} + \global\expandafter \let \csname end\floattypesetup@id \endcsname + \end@float +% \end{macrocode} +% The remaining bits of the code set up the data structures that +% belong to each float type by linking the macro name containing +% the type in its name (i.e., |\floattypesetup@id|) to the +% corresponding key macro. Theay are otherwise straight forward +% |\let|s. +% +% First for |\sequence@class@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname sequence@class@\floattypesetup@id \endcsname + \floattypesetup@class@id +% \end{macrocode} +% Then |\toc@extension@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname toc@extension@\floattypesetup@id \endcsname + \floattypesetup@toc@ext +% \end{macrocode} +% Then |\fps@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname fps@\floattypesetup@id \endcsname + \floattypesetup@area@list +% \end{macrocode} +% Then |\caption@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname caption@\floattypesetup@id \endcsname + \floattypesetup@caption@text +% \end{macrocode} +% Then |\counter@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname counter@\floattypesetup@id \endcsname + \floattypesetup@numbered@id +% \end{macrocode} +% Then |\body@|\meta{type}: +% \begin{macrocode} + \global\expandafter\let + \csname body@\floattypesetup@id \endcsname + \floattypesetup@body@decls + } +% +% +% +% +% \begin{macro}{\DeclareFloatSequenceClass} +% A float sequence class is a list of float types for which the +% placement algorithm should preserve call-out order even between +% objects with different float type. +% +% For each class we need a corresponding ``mark'' (needed by the +% algorithm) and we need to record the class name in an |\@elt| +% list. +% +% Perhaps this declaration should be implicitly handled by +% |\DeclareFloatType|. It would mean a bit more work for the latter +% but less declarations in the document design!\footnote{Change one +% day!} +% \begin{macrocode} +\def\DeclareFloatSequenceClass#1{ +% \end{macrocode} +% We probably have to check if that class is already +% declared since in that case we have to leave out a couple of +% actions. We assume that this is the case if a mark class is +% already defined for it.\footnote{Do it properly!} +% \begin{macrocode} + \@ifundefined{mark@#1} + { + \DeclareMarkType{#1} +% \end{macrocode} +% Add this to the list of known classes. +% \begin{macrocode} + \@cons\float@classes@list{{#1}} + } + \ErrorAlreadyDefined +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\float@classes@list} +% The list of float classes known in the system. +% \begin{macrocode} +\let\float@classes@list\@empty +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\c@figure} +% \begin{macro}{\c@table} +% Throw away good registers\ldots this is only for testing to allow +% us using the OR together with classes like article that sets up +% figure and table already\footnote{Clean up!} +% \begin{macrocode} +\expandafter\ifx\csname c@figure \endcsname \relax +\else + \let\c@figure\relax % thus new counter will be defined + \let\c@table \relax +\fi +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% +% +% +% +% +% \subsection{Float Placement Control Files} +% +% \begin{macro}{\perhaps@write@placements@to@fpl@file} +% |\perhaps@write@placements@to@fpl@file| writes all float +% placements (except for ``here'' floats) into the |fpl| in case we +% are writing to this file. +% +% By default, don't write fpl files. +% \begin{macrocode} +\let\perhaps@write@placements@to@fpl@file\relax +\let\perhaps@write@to@fpl@file\@gobble +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\perhaps@write@to@fpl@file} +% |\perhaps@write@to@fpl@file| writes its first argument to the +% |fpl| in case we are writing to it. +% +% By default, don't write fpl files. +% \begin{macrocode} +\let\perhaps@write@to@fpl@file\@gobble +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\perhaps@write@placements@to@fpl@file@aux} +% The format for a Float: line in an |fpl| file. Only the sequence +% number (|#7|) is currently used, the rest just helps a human +% reader identify the float. +% \begin{macrocode} +\def\perhaps@write@placements@to@fpl@file@aux#1#2#3#4#5#6#7{ + \@spaces\@spaces Float:~#7~(#6~#4)~[#3]^^J} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\savefloatplacements} +% Declaration to turn on writing of FPL files. +% \begin{macrocode} +\def\savefloatplacements{ + \newwrite\fpl@file + \immediate\openout\fpl@file\jobname.fpl + \def\perhaps@write@to@fpl@file{ + \immediate\write\fpl@file + } + \def\perhaps@write@placements@to@fpl@file{ + \def\@elt{\expandafter + \perhaps@write@placements@to@fpl@file@aux\the\toks} + \perhaps@write@to@fpl@file{ + ^^JPage:~\the\absolute@page@number\space (\the\c@page)^^J +% \end{macrocode} +% +% \begin{macrocode} + \expandafter\@write@areas\used@areas\relax\relax\relax + } + \let\@elt\relax}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@write@areas} +% |\@write@areas| loops through an area list (like |\used@areas|) +% and writes lines for every float, provided that |\@elt| is +% properly set up before. It is used inside a |\write| so needs to +% be expandable! +% \begin{macrocode} +\def\@write@areas#1#2#3{ + \ifx\relax#1 + \else + \expandafter\ifx\csname area@#1#2#3\endcsname\@empty + \else + \@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname + \fi + \expandafter\@write@areas + \fi} +% \end{macrocode} +% Alternate version that writes out all areas even if they don't +% contain any floats. +% \begin{macrocode} +\def\@write@areas#1#2#3{ + \ifx\relax#1 + \else + \@spaces Area:~#1#2#3^^J\csname area@#1#2#3\endcsname + \expandafter\@write@areas + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\readfloatplacements} +% Similar declaration to read FPC files. The file is read at this +% point up to th efirst Page: line. and the output routine command +% |\float@placement@loop| is redefined to read the FPC info for each page. +% \begin{macrocode} +\def\readfloatplacements{ + \newread\fpc@file + \openin\fpc@file\jobname.fpc\relax + \ifeof\fpc@file + \PackageWarningNoLine{xo} + {No~\jobname.fpc:~using~automatic~float~placement} + \else + \let\get@fpc@page@data\get@fpc@page@data@fpc + \get@fpc@page@data + \let\try@float@pages\relax +% \end{macrocode} +% Next line should go once we implement moving floats in and out of +% ``here'' as then we need to read the file at a different +% place!\footnote{Reimplement!} +% \begin{macrocode} + \let\float@placement@loop\fpc@float@placement@loop + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\fpc@float@placement@loop} +% Version of |\try@float@pages| to use with float placement control file. +% Should be moved to xo-or once it works. +% \begin{macrocode} +\def\fpc@float@placement@loop{ +%<*trace> + \@tracepush{fpc@float@placement@loop} +%</trace> +% \end{macrocode} +% Don't think the the next line has any meaning, so +% removed.\footnote{Old command only did set up best@trial, which +% is later on set to relax anyway. Correct to remove?} +% \begin{macrocode} +% \initialise@best@trial + \get@fpc@page@data + \global\let\best@trial\relax +% \end{macrocode} +% +% \footnote{Do we have to set run@with@floats? Check!} +% \begin{macrocode} + \mark@restore@state{ + \unvcopy\@holdpg + \setup@best@column@or + } +%<*trace> + \@tracepop{fpc@float@placement@loop} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\next@fpc@page} +% The next page for which there is FPC data. Initial value has to be +% a number to |\ifnum|. +% \begin{macrocode} +\let\next@fpc@page\m@ne +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\get@fpc@page@data} +% +% \begin{macrocode} +\let\get@fpc@page@data\relax +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\get@fpc@page@data@fpc} +% get one line of data from an FPC file, calls itself recursively +% so the effect of a call is to get all the lines for the current page +% up to and including the Page: line for the next page for which there +% is data. +% \begin{macrocode} +\def\get@fpc@page@data@fpc{ +%<*trace> +\@tracepush{get@fpc@page@data@fpc} +%</trace> + \let\@nextfpc\relax + \ifnum\next@fpc@page>\absolute@page@number +%<*trace> + \tr@ce{No~ float~ control~ on~ page:~ \the\absolute@page@number} +%</trace> + \else + \ifeof\fpc@file +%<*trace> + \tr@ce{fpc~ file~ended} +%</trace> + \global\let\next@fpc@page\maxdimen + \else + \begingroup + \endlinechar`\ % + \catcode`\ 10\relax + \global\read\fpc@file~to~\@gtempa + \endgroup + \let\@nextfpc\get@fpc@page@data + \ifx\@gtempa\@empty + \else + \expandafter\parse@fpc\@gtempa\relax + \fi + \fi + \fi +%<*trace> +\@tracepop{get@fpc@page@data@fpc} +%</trace> + \@nextfpc +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{parse@fpc} +% If float control files are being read, +% Read the section of the fpc file for this page +% and directly assign floats to the specified areas +% with no trials or checks. +% \begin{macrocode} +\def\parse@fpc#1#2~#3~#4\relax{ + \ifx P#1 +%<*trace> +\tr@ce{Next~page~control:~#3} +%</trace> + \global\mathchardef\next@fpc@page#3\relax + \let\@nextfpc\relax + \else\ifx A#1 +%<*trace> +\tr@ce{Area:~#3} +%</trace> + \setup@this@area{#3} + \let\@nextfpc\get@fpc@page@data + \else\ifx F#1 + \ifx\this@area\fpc@here +% \end{macrocode} +% Should allow moving floats into and out of here status means +% reading before the collecton OR, not after.\footnote{FIX, update, +% extend --- whatever you want to call it.} +% \begin{macrocode} +%<*trace> +\tr@ce{here~float} +%</trace> + \else +%<*trace> +\tr@ce{not~here~float} +%</trace> + \begingroup + \count@#3\relax + \global\let\this@float@box\relax + \let\@elt\extract@float@by@number + \@activelist + \endgroup +% \end{macrocode} +% If a float number is specified and there is not a float of that +% number in the active list, something has gone wrong, either we +% haven't reached the float yet (possible if the new arrangement +% results in the callout being on a later page than specified) or +% we have already assigned this float (which is a bug, either in +% this code, or in the fpc file.) Currently this condition is not +% handled other than by |\ERROR|. If the float is found, assign it +% to the current area (as set by an Area: line in the fpc file. +% \begin{macrocode} + \ifx\this@float@box\relax +%<*trace> + \tr@ce{Float:~#3~not~found} +%</trace> + \edef\fpc@list{\fpc@list#3,\this@area\relax} + \show\fpc@list + \else +%<*trace> + \tr@ce{Float:~#3~is~\this@float@box} +%</trace> +% \end{macrocode} +% Before we add the float, let's do some sanity checks. We allow to +% place a float into an area which is bigger than the float (spans +% more columns) but we complain if the area is smaller. +% \begin{macrocode} + \ifnum \this@area@span@number < + \if!\this@span@number! 1\else % big hack + \this@span@number \fi + \relax + \PackageError{xo} + {Float~ bigger~ than~ target~ area} + {Float~\this@sequence@number\space spans ~ + \this@span@number\space columns,~ + but~ target~ area~ \this@area\space + spans~ only~ \this@area@span@number\space + columns.\MessageBreak + Correct~ the~ data~ in~ file~ \jobname.fpc! + } + \fi +% \end{macrocode} +% We also check if the target area is allowed on the current page +% (it could be the case that the page setup for that page doesn't +% list it in its |area-list| key! +% \begin{macrocode} + \xin@\this@area + \used@areas + \ifin@\else + \PackageError{xo} + {Target~ area~ not~ available~ on~ current~ page} + {Float~ \this@sequence@number\space was~ requested~ to~ + be~ placed~ into~ area~ \this@area,\MessageBreak + but~ this~ + area~ is~ not~ available~ on~ page~ \thepage. + \MessageBreak + Correct~ the~ data~ in~ file~ \jobname.fpc! + } +% \end{macrocode} +% If we can't put it into the requested area we have to put it +% somewhere else. Otherwise a lot of code might break. So we simply +% chose the first area in |\used@area|\footnote{Need a solution if +% the page doesn't allow ``any'' floats! FIX!} +% \begin{macrocode} + \ifx\used@areas\@empty % we have a problem + \RESOLVE + \else + \setup@this@area{\expandafter\@carcube\used@areas\@nil} + \fi + \fi +% \end{macrocode} +% Typeset and attach the caption and adjust the text size for the +% current column. +% \begin{macrocode} + \append@caption@to@float + \construct@and@test@col@hts + \if@test + \ERRORFloatAreaToLarge + \fi +% \end{macrocode} +% We append the float to the area after the above column updates, +% otherwise |\construct@and@test@col@hts| would incorrectly think +% there is already a float present even if we add the first float +% to an area. +% \begin{macrocode} + \let\@elt\relax + \xdef\@freelist{\@freelist\@elt\this@float@box} + \expandafter\@cons\csname area@\this@area\expandafter\endcsname + \this@float@box + \fi + \fi +% \end{macrocode} +% +% Loop to next line. +% \begin{macrocode} + \let\@nextfpc\get@fpc@page@data +% \end{macrocode} +% end of case on type of fpc line. +% \begin{macrocode} + \fi\fi\fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\fpc@here} +% +% \begin{macrocode} +\def\fpc@here{hhh} +% \end{macrocode} +% \end{macro} + +% \begin{macro}{\fpc@list} +% +% \begin{macrocode} +\def\fpc@list{\relax} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\get@float@number} +% could be known as |\@seventhofseven|. +% \begin{macrocode} +\def\get@float@number#1#2#3#4#5#6#7{#7} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\extract@float@by@number} +% Find the float box that has the float with sequence number |\count@|. +% \begin{macrocode} +\def\extract@float@by@number#1{ + \ifnum\expandafter\get@float@number\the\toks#1=\count@ + \def\@currbox{#1} + \expandafter\update@this@float@structure\the\toks#1 + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \endinput +\endinput +% +% $Log: xo-float.dtx,v $ +% Revision 1.32 2000/08/11 07:14:11 latex3 +% added header +% +% Revision 1.31 2000/08/11 06:48:24 latex3 +% untabify +% +% Revision 1.30 2000/08/11 06:44:00 latex3 +% fix typo in initialization +% +% Revision 1.29 2000/08/04 10:17:28 latex3 +% separate out initialisation of here float +% +% Revision 1.28 2000/07/19 17:14:01 latex3 +% deduce \this@class from \this@type instead of storing it on a per +% float basis +% +% Revision 1.27 2000/07/19 15:53:46 latex3 +% introduced float sequence classes +% cleaned up parts of the code +% added further documentation +% +% Revision 1.26 2000/07/10 18:47:12 latex3 +% macro name renaming +% +% Revision 1.25 2000/06/29 17:16:30 latex3 +% introduced \setup@this@area +% +% Revision 1.24 2000/06/26 15:00:59 latex3 +% docu update +% +% Revision 1.23 2000/06/22 20:07:00 latex3 +% renamed some macros to get them more uniform +% +% Revision 1.22 2000/06/22 10:55:59 latex3 +% Includeed part of David's code (formerly in xo-dpc.sty) for writing +% and reading fpl/fpc files. Not done is moving floats in and out of hhh +% +% Revision 1.21 2000/06/16 11:20:50 latex3 +% rename \construct@and@test@col@height to \construct@and@test@col@ht +% rename \construct@and@test@col@heights to \construct@and@test@col@hts +% rename \cl@height1 to \@col@ht@1 (etc) +% +% Revision 1.20 2000/06/15 15:24:25 latex3 +% implemented new semantics for area names +% +% Revision 1.19 2000/06/13 21:18:02 latex3 +% add some trace guards +% +% Revision 1.18 2000/05/03 18:55:34 latex3 +% pass \theCNT instead of \value{CNT} in the float data structure (we +% might need both one day) +% +% Revision 1.17 2000/04/21 19:11:39 latex3 +% updated here float interface (needs fixing) +% +% Revision 1.16 2000/04/08 10:49:39 latex3 +% first draft support for here floats +% +% Revision 1.15 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.14 2000/03/22 15:30:28 latex3 +% some normalisations of names +% started on spans (tmp version) +% +% Revision 1.13 2000/03/16 10:28:29 latex3 +% partial and full flush working for the first time +% +% Revision 1.12 2000/03/05 19:40:07 latex3 +% support multiple columns (6 max right now) +% moved some float init code into page setup +% +% Revision 1.11 2000/02/26 18:22:59 david +% interface to x-alloc and make changes due to +% deferred float pre-allocation +% +% Revision 1.10 2000/02/21 01:45:23 david +% documentation improvements +% +% Revision 1.9 2000/02/20 00:05:08 david +% use galley, don't discard it (get more pages that way) +% +% Revision 1.8 2000/02/19 23:16:19 david +% Use \construct@and@test@col@height before destroying +% \this@captioned@float, not after... +% +% Revision 1.7 2000/02/19 18:55:44 david +% reading fpc files +% +% Revision 1.6 2000/02/17 22:47:07 david +% *** empty log message *** +% +% Revision 1.5.1.1 2000/02/16 10:39:42 latex3 +% 3cols support added +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-flow-chart.dtx b/Master/texmf-dist/source/latex3/xor/xo-flow-chart.dtx new file mode 100644 index 00000000000..5565a5aa6ad --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-flow-chart.dtx @@ -0,0 +1,153 @@ + +% \iffalse +% $Id: xo-flow-chart.dtx,v 1.5 2000/03/22 15:31:14 latex3 Exp $ +% \fi + +\begin{footnotesize} +\begin{verbatim} + (1) + | + V + \setup@collection@or + | + V + New OR: \collection@or + | + V + \setup@float@placement + + + + \setup@float@placement + | + V +(2)--> \float@placement@loop + | + V + \trial@inner@loop + | + V + <current float successfully placed in previous trial?> + | | + no yes + | | + | | + | V + | \try@next@float <--------------------- + | | | + | | | + | <\@activelist empty?> | + | | | | + | no yes | + | | | | + | | V | + | (get it) \@activelist@empty@action | + | | (= \setup@best@column@or) | + -------------v---------------- | + | | + | | + -----> \select@and@test@next@area | + | | | + | | | + | <still open areas for current float type?> | + | | | | + | yes no---------------(defer float)---------------- + | | | + | (do some tests and perhaps | + | close area this way) | + | | | + | <float allowed on this page/column (according to tests)?> | + | | | | + | yes no---------------(defer float)---------------- + | | + | <current area got closed by any test?> + | | | + | yes no + | | | + -------- V + \pretests@success@action (\setup@grabcolumn@or) + + + + + \setup@grabcolumn@or + | + V + \grabcolumn@loop <-------- + | | + V | + New OR: \grabcolumn@or | + | | + | | + <all cols produced?> | + | | | + yes no------------ + | + (store results of trial) + | + V + \setup@cleanup@or + | + V + New OR: \cleanup@or + | + V + <special outputpenalty reached?> --> (reenter 2) + + + + \setup@best@column@or + | + V + \best@column@loop <------- + | | + V | + New OR: \best@column@or | + | | + <all cols produced?> | + | | | + yes no---------- + | + (produce final page) + | + V + \initialise@next@page + | + V + (try to make float pages) + | + V + \setup@collection@or (reenter 1) + + + +\end{verbatim} +\end{footnotesize} + +\endinput + +% +% $Log: xo-flow-chart.dtx,v $ +% Revision 1.5 2000/03/22 15:31:14 latex3 +% some normalisations of names +% some corrections +% +% Revision 1.4 2000/03/05 19:38:51 latex3 +% more updates -- still wrong +% +% Revision 1.3 2000/02/26 18:27:52 david +% updates (not finished) +% +% Revision 1.4 2000/02/18 19:08:47 car2 +% oops, something else changed! +% +% Revision 1.3 2000/02/18 19:05:04 car2 +% correction: removed a defer +% +% Revision 1.2 2000/02/16 10:20:14 latex3 +% small updates +% +% Revision 1.1 2000/02/16 07:35:47 latex3 +% Initial revision +% + diff --git a/Master/texmf-dist/source/latex3/xor/xo-grid.dtx b/Master/texmf-dist/source/latex3/xor/xo-grid.dtx new file mode 100644 index 00000000000..b1d737358a7 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-grid.dtx @@ -0,0 +1,345 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-grid.dtx,v 1.3 2000/08/11 07:14:20 latex3 Exp $ +% \end{macrocode} +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% This package implements grid design on top of \LaTeXe{} by adding +% |\AlignToGrid| in various macros. Nothing else is really needed (or +% so I hope :-) +% +% So far this probably doesn't cover all structures that should, or +% could be handled automatically. +% +% \subsection{Headings} +% +% +% \begin{macro}{\headingsinkage} +% This is a temporary register used to specify the amount of +% sinkage a |\@startsection| heading is allowed if it falls at the +% a column break. In a proper reimplementation of |\@startsection| +% as a template, this should be individually specifiable rather +% than being the same for all headings! +% \begin{macrocode} +\newskip\headingsinkage +\headingsinkage=5pt plus 3pt minus 5pt +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@startsection} +% \begin{macrocode} +\def\@startsection#1#2#3#4#5#6{% + \if@noskipsec \leavevmode \fi + \par + \@tempskipa #4\relax + \@afterindenttrue + \ifdim \@tempskipa <\z@ + \@tempskipa -\@tempskipa \@afterindentfalse + \fi + \if@nobreak + \everypar{}% + \else + \addpenalty\@secpenalty + \addvspace\@tempskipa +% \end{macrocode} +% next lines are pretty horrible but we need something like this +% here (only it could be be done better) +% \begin{macrocode} + \vskip-\headingsinkage + \vskip\saved@topskip + \vskip-\prevdepth + \nointerlineskip + \null + \nobreak + \vskip-\saved@topskip + \vskip\headingsinkage + \fi + \@ifstar + {\@ssect{#3}{#4}{#5}{#6}}% + {\@dblarg{\@sect{#1}{#2}{#3}{#4}{#5}{#6}}}} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\@sect} +% Have to ensure that we don't get the heading itself aligned due +% to a dangling |\AlignToGrid| from a previous structure, so we +% issue a |\IgnoreAlignToGrid| early on. That's the only change for +% this command. +% \begin{macrocode} +\def\@sect#1#2#3#4#5#6[#7]#8{% + \ifnum #2>\c@secnumdepth + \let\@svsec\@empty + \else + \refstepcounter{#1}% + \protected@edef\@svsec{\@seccntformat{#1}\relax}% + \fi + \@tempskipa #5\relax + \IgnoreAlignToGrid + \ifdim \@tempskipa>\z@ + \begingroup + #6{% + \@hangfrom{\hskip #3\relax\@svsec}% + \interlinepenalty \@M #8\@@par}% + \endgroup + \csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth \else + \protect\numberline{\csname the#1\endcsname}% + \fi + #7}% + \else + \def\@svsechd{% + #6{\hskip #3\relax + \@svsec #8}% + \csname #1mark\endcsname{#7}% + \addcontentsline{toc}{#1}{% + \ifnum #2>\c@secnumdepth \else + \protect\numberline{\csname the#1\endcsname}% + \fi + #7}}% + \fi + \@xsect{#5}} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\@xsect} +% Now after having typeset the heading we need to issue +% |\ObeyAlignToGrid| and make sure that the first line of text gets +% aligned again. And in addition we issue a |\AlignToGrid| inside +% the |\everypar| to align the first text after the heading. Of +% course that mean that we will generate a break point after this +% line and thus might end up up with a heading and only a single +% line afterwards. +% +% This could be fixed by using a ``rspace'' structure as +% implemented in \texttt{xo-or.sty} but this is not added at the +% moment! +% \begin{macrocode} +\def\@xsect#1{% + \ObeyAlignToGrid + \@tempskipa #1\relax + \ifdim \@tempskipa>\z@ + \par \nobreak + \vskip \@tempskipa + \@afterheading + \else + \@nobreakfalse + \global\@noskipsectrue + \everypar{% + \if@noskipsec + \global\@noskipsecfalse + {\setbox\z@\lastbox}% + \clubpenalty\@M + \AlignToGrid + \begingroup \@svsechd \endgroup + \unskip + \@tempskipa #1\relax + \hskip -\@tempskipa + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}% + \fi + \ignorespaces} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\@afterheading} +% The other case where we have to add |\AlignToGrid| to the +% |\everypar|. +% \begin{macrocode} +\def\@afterheading{% + \@nobreaktrue + \everypar{% + \if@nobreak + \@nobreakfalse + \clubpenalty \@M + \if@afterindent \else + {\setbox\z@\lastbox}% + \fi + \AlignToGrid + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{List structures} +% +% \begin{macro}{\@doendpe} +% Handling of |\everypar| after a list strcture is already strange +% and complicated; here we complicate it even more by adding +% |\AlignToGrid| into its definition(s). +% \begin{macrocode} +\def\@doendpe{\@endpetrue + \def\par{\@restorepar + \everypar{\everypar{}\AlignToGrid}\par\@endpefalse}% + \everypar{{\setbox\z@\lastbox}\everypar{}\AlignToGrid\@endpefalse}% +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\endtrivlist} +% And there is one case in |\endtrivlist| in which |\@doendpe| +% is skipped so we have to set |\everypar| manually +% here.\footnote{Perhaps done in a wrong way, CHECK!} +% \begin{macrocode} +\def\endtrivlist{% + \if@inlabel + \leavevmode + \global \@inlabelfalse + \fi + \if@newlist + \@noitemerr + \global \@newlistfalse + \fi + \ifhmode\unskip \par\fi + \if@noparlist + \everypar{\everypar{}\AlignToGrid} + \else + \ifdim\lastskip >\z@ + \@tempskipa\lastskip \vskip -\lastskip + \advance\@tempskipa\parskip \advance\@tempskipa -\@outerparskip + \vskip\@tempskipa + \fi + \@endparenv + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Math} +% +% \begin{macro}{\displaymath} +% \begin{macro}{\enddisplaymath} +% \begin{macro}{\[} +% \begin{macro}{\]} +% Math is a bit more complicated as with the standard definitions +% we don't regain control after the display. So we change all the +% definitions to use the |\@doendpe| method. This means we have to +% redefine |\[| at al to be a ref to |\displaymath| not the other +% way around as it was done in \texttt{latex.ltx}. +% \begin{macrocode} +\def \displaymath { + \relax\ifmmode + \@badmath + \else + \ifvmode + \nointerlineskip + \makebox[.6\linewidth]% + \fi + $$%%$$ BRACE MATCH HACK + \fi +} +\def \enddisplaymath { + \relax\ifmmode + \ifinner + \@badmath + \else + $$%%$$ BRACE MATCH HACK + \fi + \else + \@badmath + \fi +% \end{macrocode} +% To gain control we end the paragraph and then invoke the |\end| +% mechanism for dealing with par. This gives in certain situations +% slightly different results compared working only with |$$|'s but +% that's life. +% \begin{macrocode} + \par + \@endpetrue % kill parindent if current paragraph continues + \@ignoretrue +} +\def\[{\begin{displaymath}} +\def\]{\end{displaymath}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% +% \begin{macro}{\endequation} +% Same change for the end of an equation. +% \begin{macrocode} +\def\endequation{\eqno \hbox{\@eqnnum}$$\par\@ignoretrue + \@endpetrue % kill parindent if current paragraph continues +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\endeqnarray} +% And again the same for the equation array structure. +% \begin{macrocode} +\def\endeqnarray{% + \@@eqncr + \egroup + \global\advance\c@equation\m@ne + $$\par\@ignoretrue + \@endpetrue % kill parindent if current paragraph continues +} +% \end{macrocode} +% \end{macro} +% +% \endinput +\endinput +% +% $Log: xo-grid.dtx,v $ +% Revision 1.3 2000/08/11 07:14:20 latex3 +% added header +% +% Revision 1.2 2000/08/06 19:01:12 latex3 +% fix \prevdepth situation before \@startsection +% +% Revision 1.1 2000/07/30 18:07:22 latex3 +% Initial revision +% +% +% +% +% +% +% +% \begin{macro}{} +% \begin{macrocode} +% \end{macrocode} +% \end{macro} diff --git a/Master/texmf-dist/source/latex3/xor/xo-here.dtx b/Master/texmf-dist/source/latex3/xor/xo-here.dtx new file mode 100644 index 00000000000..189aa2259ae --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-here.dtx @@ -0,0 +1,454 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-here.dtx,v 1.12 2000/08/11 07:14:21 latex3 Exp $ +% \end{macrocode} +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% Most of the code in this file is temporary in the sense that the +% interfaces are not fixed or the intended functionality is not fully +% implemented. It is sort of the proof of concept stuff. +% +% +% +% \begin{macro}{\requirespace} +% The |\requirespace| command is an interface function for other +% parts of a a class file. It issues a here point which ensures +% that there is at least |#1| amount of space still available in +% the current column. If not it results in carrying the here point, +% including the previous line(s), to the next column. This could, +% for example, be used by a heading to ensure that there is a +% certain amount of minimal space following it. +% +% The precise (?) definition of ``previous line(s)'' is as follows: +% the internal algorithm will split the so far collected column material +% trying reach the latest possible break point before the here +% point. It is theoretically possible to construct examples where +% \TeX{} decides to take an earlier split point but it is +% guaranteed the the here point is not losing contact with the +% material directly preceeding it (unless a legal breakpoint was +% added in front of it). +% If the here point was added via |\vadjust| in horizontal mode, +% this means that the line immediately before it will be after the +% split (since there will be no other legal break point inbetween). +% \begin{macrocode} +\def\requirespace #1 { + \ifhmode + \@bsphack + \fi + \@next\@currbox\@freelist{}{} +% \end{macrocode} +% We are only interested in the type really: +% \begin{macrocode} + \global\toks\@currbox{{}{} + {} + {} + {} + {rspace} + {} + } + \here@point\@currbox{#1} + \@ignorefalse + \@esphack +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\marginpar} +% The current implementation of the document command |\marginpar| +% is only a proof of concept draft. It doesn't cover the full +% flexibility of the \LaTeXe{} version yet (and perhaps one wants +% even an extension of that). +% \begin{macrocode} +\def\marginpar #1 { + \ifhmode + \@bsphack + \fi + \@next\@currbox\@freelist{}{} + \@savemarbox\@currbox{#1} +% \end{macrocode} +% We are only interested in the type really: +% \begin{macrocode} + \global\toks\@currbox{{}{} + {} + {} + {} + {mpar} + {} + } +% \end{macrocode} +% How far is a marginpar allowed to move past the bottom of the +% text area? Or say it differently: how much space does a marginpar +% need to reserve on the page? +% +% The code below works differently than the \LaTeXe{} one: it will +% move the marginpar including the line it was issued on to the +% next column if its text will otherwise fall more than a +% baselineskip below the page bottom. +% \begin{macrocode} + \@tempdima\ht\@currbox + \advance\@tempdima\dp\@currbox + \advance\@tempdima -\baselineskip % allow to run long + \ifdim\@tempdima< \z@ \@tempdima\z@ \fi + \here@point\@currbox{\the\@tempdima} + \@ignorefalse + \@esphack +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% \begin{macro}{\typeset@a@marginpar} +% The |\typeset@a@marginpar| code is called when a marginpar is +% finally added to the current page (either in a trial or in the +% final run). +% +% It should be templated! +% +% Current code is only working for two column setup (!) and lacks +% any modification possibilities depending on the final position +% for the marginpar. +% +% \begin{macrocode} +\def \typeset@a@marginpar{ + \kern-\pagedepth + \vtop to\pagedepth{\baselineskip\pagedepth + \lineskip\z@ + \vss + \dimen@\dp\@currbox + \ifnum \curr@col@count = \@ne +% \end{macrocode} +% Since this perhaps only a trial setting we have to |\copy| and +% not to |\box|!\footnote{FIX: Should clear those boxes somewhere +% else to save space!} +% \begin{macrocode} + \llap{\copy\@currbox\kern\marginparsep} + \else + \ifnum \curr@col@count = \col@count + \rlap{\kern\columnwidth\kern\marginparsep\copy\@currbox} + \else + \ERROR-NOT-SUPPORTED + \fi + \fi + \kern-\dimen@ + \null} +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\check@and@typeset@a@here@float} +% +% When we reach |\check@and@typeset@a@here@float| we are trying to +% place a float from the active list into some area and have +% encountered a here point while grabbing the column text for this +% trial placement. In |\check@and@typeset@a@here@float| we check if +% the type of the here point is the same as the current float and +% if so whether or not it would conflict with that trial +% placement. This is the case if +% \begin{itemize} +% \item +% the here float and the float under trial have the same type +% \item +% and their ordering gets out of sync. +% \end{itemize} +% \begin{macrocode} +\def\check@and@typeset@a@here@float{ +%<*trace> + \@tracepush{check@and@typeset@a@here@float} +%</trace> +% \end{macrocode} +% If we don't run with floats then no check are necessary (in fact, +% the checks would produce incorrect results), so we skip them and +% immediately typeset the here float. +% \begin{macrocode} + \ifrun@with@floats +% \end{macrocode} +% If the current float under trial has the same sequence class as the here +% object we have to look at the spatial relationship in more detail. +% \begin{macrocode} + \ifx\here@class\this@class +%<*trace> + \tr@ce{here:~ here@class~ =~ this@class~ =~ \this@class} +%</trace> +% \end{macrocode} +% If the float under trial has a larger sequence number than the +% here float we have to ensure that the area we place it in follows +% the here point, i.e., is either a later column or if it is in the +% same column comes at the bottom. +% \begin{macrocode} + \ifnum \this@sequence@number > \here@sequence@number \relax +%<*trace> + \tr@ce{here:~ target~ area~ should~ be~ after~ here~ point!} +%</trace> +% \end{macrocode} +% Like in the case of checking call-out relations we use the column +% number returned in |\count@| by |calculate@target@fl@column| +% rather than always using the start column of the area. +% \begin{macrocode} + \calculate@target@fl@column + \ifnum \count@ > \curr@col@count +%<*trace> + \tr@ce{OK:~ target~ area column~ later} +%</trace> + \else + \ifnum \count@ = \curr@col@count +%<*trace> + \tr@ce{??:~ target~ area~ target~ column~ identical} +%</trace> +% \end{macrocode} +% So in case we are in the same column at the top we fail the trial. +% \begin{macrocode} + \if t \this@area@type +%<*trace> + \tr@ce{Fail:~ target~ area~ is~ before~ here~ point} +%</trace> + \@failtrue +%<*trace> + \else + \tr@ce{OK:~ target~ area~ is~ after~ here~ point} +%</trace> + \fi + \else +% \end{macrocode} +% And we fail the trial if we tried to place the float into an +% earlier column. +% \begin{macrocode} +%<*trace> + \tr@ce{Fail:~ target~ area~ column~ earlier~ + (\the\count@ < \the\curr@col@count)} +%</trace> + \@failtrue + \fi + \fi +% \end{macrocode} +% If the float sequence number of the current float is smaller than +% the one of the here float then we should always handle it via +% flushing the float out. So the |\else| case is really only there +% for debugging +% \begin{macrocode} +%<*debug> + \else + \tr@ce{here:~ target~ area~ should~ be~ before~ here~ point!} + \ifnum \this@area@col@number > \curr@col@count + \tr@ce{Problem:~ target~ area~ column~ after~ here~ point + (\this@area@col@number > \the\curr@col@count)} + \else + \ifnum \this@area@col@number = \curr@col@count + \tr@ce{??:~ target~ area~ target~ column~ identical} + \if t \this@area@type + \tr@ce{OK:~ target~ area~ is~ before~ here~ point} + \else + \tr@ce{Problem:~ target~ area~ is~ after~ here~ point} + \fi + \else + \tr@ce{OK:~ target~ area~ is~ before~ here~ point} + \fi + \fi +%</debug> + \fi + \fi + \fi + \if@fail +% \end{macrocode} +% If the test above failed we report progress claiming that the +% reason is due to the current float being placed before the here +% float. As mentioned above this should be the only possibility why +% things fail. +% \begin{macrocode} +%<*progress> + \progress@failed{\this@area\space before~here~float~ + (\here@type\space \here@sequence@number)~ + in~ column~ \the\curr@col@count} +%</progress> + \global\curr@col@count\col@count +%<*trace> + \tr@ce{Failed:~ here~ float~ out~ of~ sync} +%</trace> + \else + \typeset@a@here@float + \fi +%<*trace> + \@tracepop{check@and@typeset@a@here@float} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\typeset@a@here@float} +% The |\typeset@a@here@float| is called when a here float is +% finally added to the current page (either in a trial or in the +% final run). +% +% The caption is attached by the usual method where the here +% area is denoted by |h|\meta{col}|1|. This allows to have +% different caption placements depending, for example, on the +% column being near the one of outer margins. +% +% The float is separated from preceeding and following text by the +% current value of |\pagesetup@float@inline@sep| as defined in the +% page setup template plus or minus a certain amount to allow +% grid-based typesetting if desired. +% \begin{macrocode} +\def \typeset@a@here@float{ +% \end{macrocode} +% Attach the caption to the float body and store the result in +% |\this@captioned@float|. +% \begin{macrocode} + \append@here@caption@to@float +% \end{macrocode} +% If we are not doing grid typesetting we simply put +% |\pagesetup@float@inline@sep| before and after the formatted +% float. +% \begin{macrocode} + \ifdim \pagesetup@grid@point@sep = \z@ + \@tempskipa\pagesetup@float@inline@sep + \else +% \end{macrocode} +% Otherwise we have to work a little harder since now we need to +% put exactly the right amount of space before and after the float +% to stay within the grid. So we measure the size of the formatted +% float and store the value in |\@tempdima|. +% \begin{macrocode} + \@tempdima\ht\this@captioned@float + \advance\@tempdima\dp\this@captioned@float +% \end{macrocode} +% To this we add twice |\pagesetup@float@inline@sep| which gives us +% the target size for whole object including surrounding space. +% \begin{macrocode} + \advance\@tempdima\tw@\pagesetup@float@inline@sep +% \end{macrocode} +% Calculate the difference to the nearest grid point\ldots +% \begin{macrocode} + \snap@to@grid \@tempdima \pagesetup@grid@point@sep +% \end{macrocode} +% \ldots and decide which grid point is closest. If the smaller one +% is closer use it if we are allowed to shrink the white space by +% the necessary amount. +% \begin{macrocode} + \ifdim \returned@lower@delta@size < \returned@delta@size \relax + \ifdim \returned@lower@delta@size < 2\pagesetup@float@inline@shrink +% \end{macrocode} +% Note that for the lower delta size we have to use the +% negation since we want to backup by this amount and delta sizes +% are always given in absolute values. +% \begin{macrocode} + \xdef \returned@delta@size {-\returned@lower@delta@size } + \fi + \fi +% \end{macrocode} +% Now set up the amount of white space we need around the float by +% starting with the |\returned@delta@size| divided by two (i.e., +% equal amount contributed to both sides of the float and then add +% |\pagesetup@float@inline@sep|. Notice, that we used a skip +% register for the calculation so that any minus or plus parts will +% survive. This is useful in case we are not doing grid typesetting +% and want to allow for some flexibility.\footnote{This needs perhaps +% rethinking it the light of extended grid implementation concept!} +% \begin{macrocode} + \@tempskipa \returned@delta@size \relax + \divide \@tempskipa \tw@ + \advance \@tempskipa \pagesetup@float@inline@sep +%<*trace> + \tr@ce{GRID:~ here~float:~ use~ \the\@tempskipa \space above~ and~ below} +%</trace> + \fi +% \end{macrocode} +% Finally typeset the float and its surrounding space which is by +% now stored in |\@tempskipa|.\footnote{Perhaps make the space +% above and below specifiable individually. One day, perhaps!} +% \begin{macrocode} + \vskip\@tempskipa + \box\this@captioned@float + \vskip\@tempskipa +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\setup@here@float} +% Absolutely temp!!!!!\footnote{FIX!!!!} +% \begin{macrocode} +\def \setup@here@float { + \@tempskipa 2\pagesetup@float@inline@sep %FMi arbitrary value TMP + \advance\@tempskipa\ht\@currbox %FMi arbitrary value TMP + \advance\@tempskipa\dp\@currbox %FMi arbitrary value TMP + \advance\@tempskipa5\baselineskip %FMi arbitrary value TMP + \here@point\@currbox{\the\@tempskipa} +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \endinput +\endinput +% +% $Log: xo-here.dtx,v $ +% Revision 1.12 2000/08/11 07:14:21 latex3 +% added header +% +% Revision 1.11 2000/08/04 10:19:09 latex3 +% added init of here floats (temp version) +% +% Revision 1.10 2000/07/19 16:05:41 latex3 +% introduced float sequence class concept +% +% Revision 1.9 2000/07/10 19:13:34 latex3 +% template here floats and support grid typesetting for them. +% +% Revision 1.8 2000/06/29 17:18:44 latex3 +% introduced \setup@this@area +% +% Revision 1.7 2000/06/18 14:58:32 latex3 +% use \calculate@target@fl@column to determine the target column ti +% check if here float and current float are in sync +% +% Revision 1.6 2000/06/15 15:23:05 latex3 +% untabify +% +% Revision 1.5 2000/06/13 20:45:47 latex3 +% docu updates +% +% Revision 1.4 2000/05/03 18:58:56 latex3 +% provide caption template support +% +% Revision 1.3 2000/04/27 19:51:45 latex3 +% bug fix: need to copy boxes in trials :-) +% moved \check@and@typeset@a@here@float to this file +% +% Revision 1.2 2000/04/21 19:01:13 latex3 +% added documentation +% +% Revision 1.1 2000/04/21 10:19:07 latex3 +% Initial revision +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-new.dtx b/Master/texmf-dist/source/latex3/xor/xo-new.dtx new file mode 100644 index 00000000000..acbeda1bf83 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-new.dtx @@ -0,0 +1,701 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-new.dtx,v 1.25 2000/08/11 07:14:23 latex3 Exp $ +% \end{macrocode} +% +% This package is available for test overwrites that need integration +% into the main packages at some point +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% + +% +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% STUFF THAT CHANGES CHRIS' xo-final +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% +% +% +% \begin{macrocode} + +\flushbottom + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%changes to xo-final +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\iftrue % using Frank's changes built on 1.15 + +%<*obsolete> +\def\typeset@this@float@and@caption{ + \append@caption@to@float + \box\this@captioned@float +} +%</obsolete> + + + +\def\final@column { +%<*trace> + \@tracepush{produce@final@column} +%</trace> + \setbox\@outputbox \box\@cclv + + \ifvoid\footins + \else + \setbox\@outputbox \vbox { + \boxmaxdepth \@maxdepth +% \end{macrocode} +% \TeX\ calculates page breaks expecting the depth of the main text +% to extend below the page baseline, not contributing to the page height, +% and it assumes the entire height plus depth of footnotes will contribute +% to the page height. When the page is assembled, the footnote depth +% is below the baseline and the main text depth appears mid-page. To +% make the contents fit the page precisely, we (locally) adjust the +% footnote spacing \cs{skip}\cs{footins} by the \emph{difference} in +% the two depths.\footnote{This part of the code was suggested by +% Donald Arseneau in bug report pr3189.} +% \begin{macrocode} + \advance\skip\footins -\dp\@outputbox % already limited to \@maxdepth + \unvbox \@outputbox + \advance\skip\footins + \ifdim\dp\footins>\@maxdepth \@maxdepth \else \dp\footins \fi + \vskip \skip\footins +% \end{macrocode} +% If we are doing grid typesetting we put all excess space between +% the text and the footnote(s). +% \begin{macrocode} + \ifdim \pagesetup@grid@point@sep > \z@ + \vfil + \fi + \color@begingroup + \normalcolor + \footnoterule + \unvbox \footins + \color@endgroup + } + \fi +% \end{macrocode} +% +% I am not sure if texttop/bottom should survive for long: something +% more spohisictaed is needed these days. This may mean that +% footnotes need better handling too: what makes a complex column +% look good? +% +% \begin{macrocode} + \global\setbox\csname col@box@\the\curr@col@count\endcsname + \vbox to \csname col@ht@ \the\curr@col@count\endcsname %<----- + { % this should one day become \@colht + % or else + \@texttop + \dimen@ \dp\@outputbox + \unvbox \@outputbox + \vskip -\dimen@ + \@textbottom + }% + \global \maxdepth \@maxdepth +%<*trace> + \@tracepop{produce@final@column} +%</trace> +} +\let \produce@final@column \final@column + + + +\def\make@area@floats@box #1#2 { +%<*trace> + \@tracepush{make@area@floats@box} + \tr@ce{Area:~ #1} +%</trace> + \@ifundefined{area@#1} % test only needed because of missing integration + { +%<*trace> + \tr@ce{Area:~ not~ set~ up} +%</trace> + } + { + \setup@this@area{#1} % needed below when typesetting floats + + \setbox #2 \box\voidb@x % <-------- FMi +% \let \@elt \@comflelt % Big aaah! + \def \@elt { \typeset@float@in@box {#2} } + \csname area@#1\endcsname +% \end{macrocode} +% Not very pretty yet! But better when decoration +% stuff is used. +% \begin{macrocode} + \let \@elt \relax + + \expandafter + \release@floats + \csname area@#1\endcsname + } +%<*trace> + \@tracepop{make@area@floats@box} +%</trace> +} + + +\def\typeset@float@in@box #1 #2 { +%<*trace> + \@tracepush{typeset@float@in@box} +%</trace> + \gdef\this@float@box {#2} % <------------- FMi + \expandafter + \extract@this@float@actual@structure \the\toks #2 + + \update@this@area@columns + { + \expandafter + \gdecrement@num + \csname col@ \this@area@type + @floats@ \the\count@ @number\endcsname +%<*trace> + \tr@ce{col@ \this@area@type + @floats@ \the\count@ @number~ <-~ + \csname col@ \this@area@type + @floats@ \the\count@ @number\endcsname} +%</trace> + } + + \setbox #1 \vbox { + \ifvoid #1 +%<*trace> +\tr@ce{add~to~#1:~float~ #2} +%</trace> + \else % experimental FMi +%<*trace> +\tr@ce{add~to~#1:~float~ #2~ plus~ \pagesetup@float@float@sep} +%</trace> + \unvbox #1 % experimental FMi + \vskip \pagesetup@float@float@sep % experimental FMi + \fi % experimental FMi + \typeset@this@float@and@caption + } +%<*trace> + \@tracepop{typeset@float@in@box} +%</trace> + } + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% my new xo-final stuff +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +\def \myfinalpage { + \mbox@addtopage (\pagebodylefthpos, -\headsep) + {page:~\thepage} +% \end{macrocode} +% +% \begin{macrocode} +% Init |\dimen|1,2,3,\ldots as vertical current point per column +% (don't forget in Chris's (sorry, Don's) universum zero is at the +% top). +% \end{macrocode} +% +% \begin{macrocode} + \forall@columns{ + \dimen \the\curr@col@count + \z@ + } +% \end{macrocode} +% Now mount all top areas looping through an ordered list of top +% areas. +% \begin{macrocode} + \expandafter\mount@top@areas@loop + \top@areas + \relax\relax\relax +% \end{macrocode} +% Next mount the text columns. +% \begin{macrocode} + \forall@columns{ + +%<*trace> + \tr@ce{GRID (delta):~ column~\the\curr@col@count t:~ + \csname col@t@delta@ \the\curr@col@count + \endcsname\space used} +%</trace> + \advance \dimen \the\curr@col@count + by %NEEDED!!!!! + \csname col@t@delta@ \the\curr@col@count \endcsname + + \advance \dimen \the\curr@col@count + \csname col@ht@ \the\curr@col@count \endcsname + + \setlength \@tempdima + {\pagebodylefthpos - \columndisplacement + + \columndisplacement * \curr@col@count } + + \mbox@addtopage ( \the\@tempdima ,\the\dimen\curr@col@count ) + { \box \csname col@box@ \the\curr@col@count \endcsname } + +%<*trace> + \tr@ce{GRID (delta):~ column~\the\curr@col@count b:~ + \csname col@b@delta@ \the\curr@col@count + \endcsname\space used} +%</trace> + \advance \dimen \the\curr@col@count + by %NEEDED!!!!! + \csname col@b@delta@ \the\curr@col@count \endcsname + } +% \end{macrocode} +% Then mount the bottom floats. +% \begin{macrocode} + \def\col@of@focus{0} % temp solution see below + \expandafter\mount@bot@areas@loop + \bot@areas + \relax\relax\relax +% \end{macrocode} +% +% Next thing is absolutely temp: mount a marginal area on the right +% (bottom) to allow footnotes there (this is just for testing). +% \begin{macrocode} + \setlength \@tempdima + {\pagebodylefthpos + \columndisplacement * \col@count } + \mbox@addtopage ( \the\@tempdima , \textheight ) + { \box \saved@footins } % TEMP FMi +% +% Next thing is absolutely temp: mount a marginal area on the right +% (bottom) to allow marginal floats there (this is just for testing). +% \begin{macrocode} + \expandafter + \ifx\csname area@m1\the\curr@col@count\endcsname\relax + \else + \curr@col@count\col@count + \advance\curr@col@count\@ne + \make@area@floats@box {m\the\curr@col@count1}\@tempboxa + \setlength \@tempdima + {\pagebodylefthpos + \columndisplacement * \col@count } + \mbox@addtopage ( \the\@tempdima , \textheight ) + { \vbox to\textheight{\vfil \unvbox \@tempboxa \vfil }} + \fi +% + \ifShowGrid + \ifdim \pagesetup@grid@point@sep > \z@ + \@tempcnta\textheight + \@tempcntb\topskip + \advance\@tempcnta -\@tempcntb + \@tempdimb\pagesetup@grid@point@sep + \@tempcntb\@tempdimb + \divide\@tempcnta\@tempcntb + \advance\@tempcnta\@ne + + \setlength \@tempdimb + {\pagebodylefthpos + \columndisplacement * \col@count + - \columnsep } + \count@\@tempdimb + + \sbox\grid@box{ + \setlength\unitlength{1sp} + \begin{picture}(0,0) + \multiput(0,0)(0,\@tempcntb){\@tempcnta} + {\line(1,0){\count@}} + \end{picture} + } + + \mbox@addtopage ( 0pt ,\textheight ) + { \box\grid@box } + + \fi + \fi +} + +\newbox\grid@box + +\newif\ifShowGrid +\ShowGridtrue + +% for tracing only (unchanged) + + +\def\mbox@addtopage (#1,#2)#3{% +% \tr@ce{box~being~added~to~page:~at~(#1,~#2) } + \global \setbox\page@box + \hbox { + \unhbox \page@box + \mbox@put (#1,#2) {#3} + } +} + + + + +\def\mount@top@areas@loop#1#2#3{ + \ifx#1\relax + \else + \mount@top@area#1#2#3 + \expandafter\mount@top@areas@loop + \fi} + + +\def\mount@top@area#1#2#3 { + \make@area@floats@box {#1#2#3}\@tempboxa + + \ifvoid \@tempboxa + \else + + \setlength \@tempdimb + { \dimen#2 + \ht\@tempboxa + \dp\@tempboxa } + + \setlength \@tempdima + {\pagebodylefthpos - \columndisplacement + \columndisplacement * #2 } + + \mbox@addtopage ( \the\@tempdima ,\the\@tempdimb ) + { \box \@tempboxa } + + \count@ #2\relax + \advance\count@ #3\relax + \loop + \advance\count@\m@ne + \dimen \count@ = \@tempdimb + \advance\dimen \count@ + \ifnum \csname col@t@floats@ \the\count@ @number\endcsname > \z@ + \pagesetup@float@area@sep + \else + \pagesetup@float@text@sep + \fi + \ifnum #2 < \count@ + \repeat + + \fi +} + +\def\mount@bot@areas@loop#1#2#3{ + \ifx#1\relax + \else + \mount@bot@area#1#2#3 + \expandafter\mount@bot@areas@loop + \fi} + +\def\mount@bot@area#1#2#3 { + \make@area@floats@box {#1#2#3}\@tempboxa + + \ifvoid \@tempboxa + \else + + \setlength \@tempdimb + { \dimen#2 + \ht\@tempboxa + \dp\@tempboxa } + +% \end{macrocode} +% There are probably much better ways to get the spacing right, the +% one below is really only a temporary fix: in |\col@of@focus| we +% remember the last column in which already applied +% |\pagesetup@float@text@sep|, any additional float area will +% contribute another |\pagesetup@float@area@sep| +% instead.\footnote{To make this work it is absolutely necessary +% that the floats in bot@areas are ordered by column!!! No-good. FIX!!} +% \begin{macrocode} + \ifnum \col@of@focus < #2 \relax + \def\col@of@focus{#2} + \advance\@tempdimb + \pagesetup@float@text@sep + \else + \advance\@tempdimb + \pagesetup@float@area@sep + \fi + + \setlength \@tempdima + {\pagebodylefthpos - \columndisplacement + \columndisplacement * #2 } + + \mbox@addtopage ( \the\@tempdima ,\the\@tempdimb ) + { \box \@tempboxa } + +% \end{macrocode} +% Next loop is actually not necessary as long we keep the +% restriction that we don't allow partial overlapping float areas, ie we +% will never mount another float area in the columns that are +% spanned by the current float area (other than potentially the +% first and we set this one explicitly). +% \begin{macrocode} + \dimen #2 = \@tempdimb +% \count@ #2\relax +% \advance\count@ #3\relax +% \loop +% \advance\count@\m@ne +% \dimen \count@ = \@tempdimb +% \ifnum #2 < \count@ +% \repeat + + \fi +} + + +% of course \top@areas and \bot@areas should be constructed +% automatically when preparing the \use@areas or from the \known@areas +% but for now i simply define them here: + +\def\top@areas{t13 t12 t22 t32 t11 t21 t31} + +\def\bot@areas{b11 b12 b13 b21 b22 b31 b32} + + +%%%%%%%%%%%%%%%%%%%%%%%%%%% +% next line activates my version (well some of it is activated already +% above) +%%%%%%%%%%%%%%%%%%%%%%%%%%% +\let\make@page@box\myfinalpage + +\fi % end of stuff modifying xo-final 1.15 + +% \end{macrocode} +% + +\endinput + + + +% \begin{macro}{\savecolumnsizes} +% Declaration to turn on writing of CSL (column size list) files. +% \begin{macrocode} +\def\savecolumnsizes{ + \newwrite\csl@file + \immediate\openout\csl@file\jobname.csl + \def\perhaps@write@to@csl@file{ + \immediate\write\csl@file + } + \def\perhaps@write@placements@to@csl@file{ + \def\@elt{\expandafter + \perhaps@write@placements@to@csl@file@aux\the\toks} + \perhaps@write@to@csl@file{ + ^^JPage:~\the\absolute@page@number\space (\the\c@page)^^J +% \end{macrocode} +% +% \begin{macrocode} + \expandafter\@write@areas\used@areas\relax\relax\relax + } + \let\@elt\relax}} +% \end{macrocode} +% \end{macro} +% + + + + + + +\endinput + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% an attempt to use column 0 and n+1 as marginal areas +% not active +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% \begin{macro}{\forall@columns@and@margins} +% \begin{macrocode} +\def\forall@columns@and@margins#1{ + \edef\saved@curr@col@count{\the\curr@col@count} + \global\curr@col@count\col@count + \global\advance\curr@col@count\@ne + \@whilenum \curr@col@count>\m@ne \do + { + #1 + \global\advance\curr@col@count\m@ne + } + \global\curr@col@count\saved@curr@col@count\relax +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macrocode} +% original macro no longer used +\def\initialise@best@trial{ +%<*trace> + \@tracepush{initialise@best@trial} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \global\let\best@trial\@empty + \forall@columns@and@margins{ + \expandafter + \g@addto@macro\expandafter\best@trial\expandafter + { + \expandafter + \global + \csname col@ht@ \the\curr@col@count\endcsname + \textheight + } + } +%<*trace> + \tr@ce{\meaning\best@trial} + \@tracepop{initialise@best@trial} +%</trace> +} +% \end{macrocode} +% + +% \begin{macrocode} +\expandafter\newdimen\csname col@ht@ 0\endcsname +% \end{macrocode} +% + + +% \begin{macro}{\initialise@next@page} +% Initialises the column heights to text height. Clear the float +% area lists, zero holdinginserts to allow footnote texts to arrive +% in the insertion box. +% \begin{macrocode} +\def\initialise@next@page{ +%<*trace> + \@tracepush{initialise@next@page} +%</trace> +% + \forall@columns@and@margins + {\global\csname col@ht@ \the\curr@col@count\endcsname\textheight} +% + \initialise@areas +% + \global\page@float@count\z@ +% + \initialise@best@trial +% \end{macrocode} +% +% \begin{macrocode} + \initialise@flush@data +% \end{macrocode} +% +% \begin{macrocode} + \initialise@here@data +% \end{macrocode} +% +% \begin{macrocode} + \initialise@footins@action +% \end{macrocode} +% +% Nothing is closed when we are at the start of a page. +% \begin{macrocode} + \global\let\this@page@closed\@empty +% \end{macrocode} +% +% \begin{macrocode} + \let\@elt\initialise@float@class + \float@classes@list + \let\@elt\relax +% +%\showfloatlists +%\show\area@ddd\show\@activelist +% for safety + \global\let\this@float@box\@undefined +%<*trace> + \@tracepop{initialise@next@page} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% + +% +% \endinput +\endinput +% +% $Log: xo-new.dtx,v $ +% Revision 1.25 2000/08/11 07:14:23 latex3 +% added header +% +% Revision 1.24 2000/08/11 06:49:09 latex3 +% untabify +% +% Revision 1.23 2000/08/05 10:01:26 latex3 +% ensure that \make@area@floats@box doesn't do any harm to areas not set +% up via \DeclareFloatArea +% +% Revision 1.22 2000/08/04 15:50:31 latex3 +% \flushbottom default again +% +% Revision 1.21 2000/08/04 13:58:58 latex3 +% \bot@areas need to be ordered by column at the moment!!!! +% +% Revision 1.20 2000/08/04 10:20:09 latex3 +% removed old experimental code for grid layout +% +% Revision 1.19 2000/07/22 06:30:50 latex3 +% fixed bug in positioning bottom floats +% +% Revision 1.18 2000/07/19 17:12:53 latex3 +% introduced float sequence list +% +% Revision 1.17 2000/07/10 19:22:12 latex3 +% more grid support +% +% Revision 1.16 2000/07/04 19:48:55 latex3 +% experimental stuff for GRIDs +% start writing out columnsizes (unused) +% use \update@this@area@columns +% +% Revision 1.15 2000/06/29 17:16:59 latex3 +% introduced \setup@this@area +% +% Revision 1.14 2000/06/26 15:17:26 latex3 +% prototype support for \pagesetup@float@area@sep +% +% Revision 1.13 2000/06/16 11:21:07 latex3 +% rename \construct@and@test@col@height to \construct@and@test@col@ht +% rename \construct@and@test@col@heights to \construct@and@test@col@hts +% rename \cl@height1 to \@col@ht@1 (etc) +% +% Revision 1.12 2000/06/15 15:22:36 latex3 +% implemented new semantics for area names +% +% Revision 1.11 2000/06/13 21:23:03 latex3 +% *** empty log message *** +% +% Revision 1.10 2000/05/04 09:21:27 latex3 +% urg: \this@area undefined inside the output routine, so captions got +% typeset with whatever was the last \this@area. +% +% Revision 1.9 2000/05/03 18:41:52 latex3 +% still overwriting code for xo-final 1.15 ! (not 1.16) +% enabling support for caption templates +% +% Revision 1.8 2000/04/21 19:16:32 latex3 +% activate my version of xo-final +% +% Revision 1.7 2000/04/21 19:05:21 latex3 +% my version of xo-final mainly +% +% Revision 1.6 2000/04/09 20:02:42 latex3 +% first draft of marginpar support +% +% Revision 1.5 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.4 2000/02/26 18:26:08 david +% code moved to xo-* +% +% Revision 1.3 2000/02/13 21:37:20 latex3 +% ooops, my ultrix rcs is too old to guess the comment char correctly +% so we better add explicit \endinput +% +% Revision 1.2 2000/02/13 21:35:25 latex3 +% wording +% +% Revision 1.1 2000/02/13 21:34:51 latex3 +% Initial revision +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-or.dtx b/Master/texmf-dist/source/latex3/xor/xo-or.dtx new file mode 100644 index 00000000000..6aef48254b1 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-or.dtx @@ -0,0 +1,5188 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-or.dtx,v 1.53 2000/08/11 07:14:25 latex3 Exp $ +% \end{macrocode} +% +% \subsection{A flowchart of the algorithm} +% +% Several output routines are employed. Output routines (that is, +% macros to be used as the sole content of the primitive |\output| +% register) are named xxx@or. Typically a companion macro named +% setup@xxx is called to initialise the state (typically setting +% vsize) and to assign |\output|. +% +% +% [The flow chart has be cut into pieces and individual pieces are +% shown below.] +% +% ^^A \input{xo-flow-chart.sty} ^^A .sty to ease updating +% +% +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% +% +% \subsection{General helper Routines} +% +% \begin{macro}{\@gobblethree} +% Get rid of three tokens or brace groups. +% \begin{macrocode} +\long\def\@gobblethree#1#2#3{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\xin@} +% Like |\in@| but with both args (which have to be single tokens!) +% expanded. Should be replaced by a proper interface. +% \begin{macrocode} +\def\xin@#1#2{% +% expanded once: + \expandafter\def\expandafter\in@@\expandafter##\expandafter1#1##2##3\in@@{% + \ifx\in@##2\in@false\else\in@true\fi}% + \expandafter\expandafter\expandafter\in@@\expandafter#2#1\in@\in@@} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\gincrement@num} +% Globally increment a ``number macro'' by one. +% \begin{macrocode} +\def\gincrement@num#1 { +% \end{macrocode} +% We don't want to modify |\count@| here as it might hold some +% important data so we do everything in a group. +% \begin{macrocode} + \begingroup + \count@#1 + \advance\count@\@ne + \xdef#1{\the\count@} + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\gdecrement@num} +% Globally decrement a ``number macro'' by one. +% \begin{macrocode} +\def\gdecrement@num#1 { + \begingroup + \count@#1 + \advance\count@\m@ne + \xdef#1{\the\count@} + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\split@skip} +% \begin{macro}{\check@for@fil} +% \begin{macro}{\get@plus@part} +% \begin{macro}{\get@minus@part} +% |\split@skip| takes four aguments: a template key name (for error +% recovery), a skip specification (e.g., either the value of a skip +% register via |\the|\meta{register}, or a macro holding the +% information, or the specification directly), and two dimen +% registers. The skip specification is taken apart and the first +% dimen register receives ``plus'' part and the second the +% ``minus'' part. If the specification contains any |fil| parts an +% error is generated since these values can't be assigned to a +% dimen register. +% \begin{macrocode} +\begingroup +% \end{macrocode} +% We employ the |\lowercase| trick to get certain letters with +% |\catcode| 12 since we have to scan for them (they are what +% |\the| outputs. So if we say |MINUS| below we get |minus| but all +% |\catcode|d 12. +% \begin{macrocode} +\catcode`\M=12 +\catcode`\I=12 +\catcode`\N=12 +\catcode`\U=12 +\catcode`\S=12 +% \end{macrocode} +% We need |p| with |\catcode| 12 to scan for |pt| but we also need +% |P| with |\catcode| 11 to be able to say |\PackageError|. So we +% claim lowecase of |Z| is |p| and then say |ZT| and |ZLUS| below. +% \begin{macrocode} +\catcode`\Z=12 +\lccode`\Z=`\p +\catcode`\T=12 +% \end{macrocode} +% And we need to scan for |FIL|: +% \begin{macrocode} +\catcode`\L=12 +\catcode`\F=12 +% \end{macrocode} +% And the error message contains uppercase |V| and |O| and we want +% to retain those. +% \begin{macrocode} +\lccode`\V=`\V +\lccode`\O=`\O +% \end{macrocode} +% With the above prelims we now apply |\lowercase| to all the +% definitions below, which will put the correctly |\catcode|d +% strings in the parsing part of the macros. +% \begin{macrocode} +\lowercase{ +\gdef\split@skip #1#2#3#4{ +% \end{macrocode} +% |#2| is the skip specification. To be sure that the strings +% ``plus'', ``minus'', ``pt'' are always having |\catcode| 12 we +% assign it to a register first. Otherwise a user supplied string +% like |1in plus .5in| wouldn't be parsable since we are only +% looking for |pt| and also because in this case the |\catcode|s of +% |plus| would be 11. +% \begin{macrocode} + \@tempskipa#2\relax +% \end{macrocode} +% Then we pass this on to |\check@for@fil| which will make sure +% that there isn't any |fil| present and if not does the rest of +% the processing. +% \begin{macrocode} + \expandafter\check@for@fil \the\@tempskipa FIL\relax\check@for@fil + {\the\@tempskipa}{#3}{#4}{#1} + } +% \end{macrocode} +% +% \begin{macrocode} +\gdef\check@for@fil #1FIL#2\check@for@fil#3#4#5#6{ + \ifx\relax#2 + \expandafter + \get@minus@part #3MINUS 0ZT \get@minus@part{#4}{#5} + \else + #4\z@ + #5\z@ + \PackageError{template}{Value~ for~ key~ #6~ contains~ `fil(ll)'} + {Only~ finite~ minus~ or~ plus~ parts~ are~ allowed~ for~ this~ key.} + \fi + } +% \end{macrocode} +% +% \begin{macrocode} +\gdef\get@plus@part #1ZLUS#2ZT#3\get@plus@part#4{ + #4=#2pt\relax + } +% \end{macrocode} +% +% \begin{macrocode} +\gdef\get@minus@part #1MINUS#2ZT#3\get@minus@part#4#5{ + \get@plus@part #1ZLUS 0ZT\get@plus@part{#4} + #5=#2pt\relax + } +} +\endgroup +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% +% +% +% +% +% \subsection{Special Output Routine Penalties} +% +% +% \begin{macro}{\output@collect@penalty} +% Special penalty marking the point at which the collection OR ended. +% \begin{macrocode} +\mathchardef\output@collect@penalty=20202 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\output@balance@penalty} +% Special penalty marking the point at which the collection OR +% should end collection because we want to balance the material. +% \begin{macrocode} +\mathchardef\output@balance@penalty=10010 +% \end{macrocode} +% \end{macro} +% +% +% Other special penalties are inbetween -10000 and -10010. Those will +% not stop the collection OR but are instead recorded along the way. +% +% \begin{macro}{\output@columnbreak@penalty} +% Special penalty marking the point a forced column break was +% requested by the user. +% \begin{macrocode} +\mathchardef\output@columnbreak@penalty=10005 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\output@flush@float@penalty} +% Special penalty to trigger float flushing for one or more types. +% \begin{macrocode} +\mathchardef\output@flush@float@penalty=10006 +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\output@here@float@penalty} +% Special penalty for floats that should stay with their callout. +% \begin{macrocode} +\mathchardef\output@here@float@penalty=10007 +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\output@grid@align@penalty} +% Special penalty for places that should fall on the page grid. +% \begin{macrocode} +\mathchardef\output@grid@align@penalty=10008 +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \subsubsection{Utilities for Special Output Routine Penalties} +% +% +% \begin{macro}{\add@badly@guarded@penalty} +% Put a special penalty into the output and guard it with a +% box. The reason this macro is called |\add@badly@guarded@penalty| +% is that such a box of size zero is still messing up spacing +% caluclations. Why? Because when the penalty is reached on the MVL +% the preceeding line has already be fully added (i.e., including +% its depth). This means that \TeX{} might not reach it at all in +% time! For example, if the preceeding line would be the last line +% of the page the depth would not be taken into account yet, but by +% the time we reach the special penalty it has been added to +% |\pagetotal| and that may result in not fitting anymore onto the +% page. +% +% A solution would be to use a box that has the same depth as its +% preceeding box and a negative height so that it effectively +% doesn't modify the galley length. Easy, right? The only problem +% is that in case of |\vadjust| (and that is unfortunately the more +% important case) we just don't know what the preceeding depth is, +% since |\prevdepth| will always give us a friendly |-1000pt| in +% that case (start of a vertical sub-list\ldots). +% +% So not so easy after all. The way out of this dilemma turned out +% to be complicated and involves a lot of strange corrective +% actions in the collection process, see there for a replacement of +% that box and what else can go wrong if one delves into messing +% around with that part of \TeX. +% \begin{macrocode} +\def\add@badly@guarded@penalty#1 { + \ifvmode + \nointerlineskip + \vbox to\z@{\vss\the#1}\penalty-#1\relax + \else + \@bsphack + \vadjust{\vbox to\z@{\vss\the#1}\penalty-#1\relax} + \@esphack + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\add@guarded@penalty} +% Put a special penalty into the output. To ensure that it doesn't +% get mistakenly removed during breaking preceed it with a ``guard +% box'' which is later removed again. --- Actually no longer used +% but replacement isn't yet finalised.\footnote{CLEANUP!} +% \begin{macrocode} +\def\add@guarded@penalty#1 + {\guard@box{BUG:~\string#1}\penalty-#1\relax} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\guard@box} +% Could be moved into the previous macro. +% +% The way it is written (using |\prevdepth|) this can only be used +% in vertical mode! We have to carry over the |\prevdepth| and +% append the box without adding any additional interline +% space. Without it one gets nasty extra glue blobs of height +% |\baselineskip| somewhere in the output. +% \begin{macrocode} +\def\guard@box#1{ + \dimen@\prevdepth + \nointerlineskip + \vbox to0pt{\vss \rlap{#1}\kern\z@} + \prevdepth\dimen@ +} +% \end{macrocode} +% Better implementation? The above is wrong!\footnote{FIX!} +% \begin{macrocode} +\def\guard@box#1{ + \dimen@\prevdepth + \nointerlineskip + \begingroup + \setbox\z@\vbox to\z@{\vss \rlap{#1}} + \dp\z@\dimen@ + \box\z@ + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\remove@guard@box@from@cclv} +% Remove a guard box again. This always happens in the OR and so we +% hard code the box number for speed. +% +% Chris thinks this needs a maxdepth setting. +% \begin{macrocode} +\def\remove@guard@box@from@cclv{ + \global\setbox\@cclv \vbox{\boxmaxdepth\@maxdepth \unvbox\@cclv + \global\setbox\removed@guard@box\lastbox} +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\readd@guarded@penalty} +% Readding a guared penalty including the box that was removed +% earlier. Probably not needed in the end either since the way it +% is used at the moment we have a |\topskip| problem this +% way.\footnote{FIX!!!!} +% \begin{macrocode} +\def\readd@guarded@penalty#1 { + \box\removed@guard@box +%FMi what about topskip? + \penalty-#1\relax} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\removed@guard@box} +% \begin{macrocode} +\newbox\removed@guard@box +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{Columns and their Data Structures} +% +% \begin{macro}{\col@count} +% We are collecting stuff for a given number of columns. This +% number of column is available in a count register. +% \begin{macrocode} +\let\col@count \col@number % reuse a register from LaTeX + % which is named differently there +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\curr@col@count} +% Register denoting the column number of the current column while +% we cut the galley etc. Should always be modified globally since +% it is used within output routines. +% \begin{macrocode} +\newcount\curr@col@count +% \end{macrocode} +% \end{macro} +% +% +% +% \DescribeMacro\col@box@FOO +% Per column number FOO we have one box register allocated in which +% the column text from the galley is stored during trials and page +% makeup. +% +% \DescribeMacro\col@ht@FOO +% Per column number FOO we have dimen register allocated which +% holds the vertical target size for the column during the trials. +% +% \DescribeMacro\col@t@floats@FOO@number +% Per column number FOO we have a macro number in which we count +% the number of top floats we have seen so far in this column. This +% is used to implement |\pagesetup@float@area@sep| handling. +% +% \DescribeMacro\col@b@floats@FOO@number +% Per column number FOO we have a macro number in which we count +% the number of bottom floats we have seen so far in this column. This +% is used to implement |\pagesetup@float@area@sep| handling. +% +% +% \DescribeMacro\col@t@delta@FOO +% Per column number foo we have a macro in which we record the +% difference between the real size of all top floats (including +% there separation spaces) and the nominal size which is used to +% determine the vertical size of the remaining text column. The two +% may differ if we do grid typesetting. +% +% \DescribeMacro\col@b@delta@FOO +% Same kind of delta is recorded per column for the bottom floats. +% +% \DescribeMacro\fl@FOO@BAR +% For each float type BAR (e.g., |figure|, |table|, etc.) and each +% column number FOO we have a macro which holds the highest float +% sequence number for floats of type BAR allocated to column FOO or +% zero if no float has been allocated so far. +% +% \DescribeMacro{\fl@0@BAR} +% For each float type BAR (e.g., |figure|, |table|, etc.) +% |\fl@0@BAR| holds the highest sequence number in columns of the +% previous page. +% +% \DescribeMacro\tfl@FOO@BAR +% |\tfl@FOO@BAR| is like |\fl@FOO@BAR| but only stores information +% about floats allocated to top areas. +% +% + +% \begin{macro}{\col@box@1} +% \begin{macro}{\col@box@2} +% \begin{macro}{\col@box@3} +% \begin{macro}{\col@box@4} +% \begin{macro}{\col@box@5} +% \begin{macro}{\col@box@6} +% Need a box per column (currently fixed at six) to hold material +% from the galley for this column. +% \begin{macrocode} +\expandafter\newbox\csname col@box@1\endcsname +\expandafter\newbox\csname col@box@2\endcsname +\expandafter\newbox\csname col@box@3\endcsname +\expandafter\newbox\csname col@box@4\endcsname +\expandafter\newbox\csname col@box@5\endcsname +\expandafter\newbox\csname col@box@6\endcsname +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\col@ht@ 1} +% \begin{macro}{\col@ht@ 2} +% \begin{macro}{\col@ht@ 3} +% \begin{macro}{\col@ht@ 4} +% \begin{macro}{\col@ht@ 5} +% \begin{macro}{\col@ht@ 6} +% Need a dimen\footnote{Could be a macro if we find ourselves to +% use up too many dimens.} per column to hold its current vertical +% target size. +% \begin{macrocode} +\expandafter\newdimen\csname col@ht@ 1\endcsname +\expandafter\newdimen\csname col@ht@ 2\endcsname +\expandafter\newdimen\csname col@ht@ 3\endcsname +\expandafter\newdimen\csname col@ht@ 4\endcsname +\expandafter\newdimen\csname col@ht@ 5\endcsname +\expandafter\newdimen\csname col@ht@ 6\endcsname +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% +% +% \subsubsection{Utilities for Columns and their Data Structures} +% +% \begin{macro}{\forall@columns} +% If we want to do something to data structures for all column we +% can use the macro |\forall@columns|. Within its argument the +% current column is available in the register +% |\curr@col@count|. The macro takes some pains to restore the +% original value of |\curr@col@count| afterwards. +% \begin{macrocode} +\def\forall@columns#1{ + \edef\saved@curr@col@count{\the\curr@col@count} + \global\curr@col@count\z@ + \@whilenum \curr@col@count<\col@count \do + {\global\advance\curr@col@count\@ne + #1 + } + \global\curr@col@count\saved@curr@col@count\relax +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\initialise@column@data} +% \begin{macrocode} +\def\initialise@column@data{ +%<*trace> + \@tracepush{initialise@column@data} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \global\let\best@trial\@empty + + \forall@columns + { + + \global\csname col@ht@ \the\curr@col@count\endcsname\textheight + +% \end{macrocode} +% +% \begin{macrocode} + \expandafter + \g@addto@macro\expandafter\best@trial\expandafter + { + \expandafter + \global + \csname col@ht@ \the\curr@col@count\endcsname + \textheight + } +% \end{macrocode} +% We haven't seen any top or bottom floats yet. +% \begin{macrocode} + \global\@namedef{col@t@floats@ \the\curr@col@count + @number}{0} + \global\@namedef{col@b@floats@ \the\curr@col@count + @number}{0} +% \end{macrocode} +% For the same reason the delta values for top and bottom areas are +% zeroed.\footnote{Using \texttt{\string\let} and +% \texttt{\string\z@} in places like this would be more faster and +% shorter, but it wouldn't work nicely in tracing as it would make +% unexpandable macros. Perhaps the tracing versions should be made +% specially.} +% \begin{macrocode} + \global\@namedef{col@t@delta@ \the\curr@col@count}{0pt} + \global\@namedef{col@b@delta@ \the\curr@col@count}{0pt} + } + +%<*trace> + \tr@ce{\meaning\best@trial} + \@tracepop{initialise@column@data} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \subsubsection{User Commands for Columns} +% +% +% \begin{macro}{\columnbreak} +% And here is the user command formaking a column +% break:\footnote{All this is stolen from \texttt{multicol.sty} and +% there is still code that doesn't belong here.} |\columnbreak| is +% modelled after |\pagebreak| except that we generate a penalty +% |-\output@columnbreak@penalty|. +% \begin{macrocode} +\def\columnbreak{ +% \end{macrocode} +% We have to ensure that it is only used within a multicolumn +% environment since if that penalty would be seen by the unmodified +% \LaTeX{} output routine strange things would happen. +% \begin{macrocode} + \ifnum\col@count<\tw@ + \PackageError{xoutput} + {\noexpand\columnbreak~ in~ one-column~ mode} + {???} + \else + \ifvmode + \penalty -\output@columnbreak@penalty + \else + \@bsphack + \vadjust{\penalty -\output@columnbreak@penalty} + \@esphack + \fi + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% +% +% +% +% \subsection{Float Areas and their Data Structures} +% +% Naming conventions for float areas is as follows: +% \begin{quote} +% \meta{identifier}\meta{start-column}\meta{span-count}. +% \end{quote} +% The \meta{identifier} is a single letter denoting the type of area, +% e.g., |t| for top, |b| for bottom. The \meta{span-count} is a single +% digit denoting the number of columns to span. The +% \meta{start-column} is a single digit\footnote{with a bit of care in +% the code this could be extended to allow more than one digit.} +% denoting the start column of the area. Thus |t32| is a top area +% starting at column three and spanning two columns ie three and four. +% A restriction due to the naming scheme is that currently no more than +% 9 columns are possible. +% +% Only a subset of the float areas is allowed to be popolated on a +% page. In essense the current algorithm does not support placements +% that result in splitting the text of a column due to a float (other +% than column `here' floats).\footnote{Perhaps this restriction is +% lifted one day.} This means that if $pcs$ ($p=\textrm{pos}$, +% $c=\textrm{column}$, $s=\textrm{span}$) is a float area that is +% being populated then it must prevent populating all float areas that +% satisfy either +% \[ +% pij \textrm{ with } i < c \leq i+j < c+s +% \] +% or +% \[ +% pij \textrm{ with } i \leq c+s < i+j \leq \verb=\col@count= +% \] +% The first formula describes the areas which partly overlap from the +% left, the second formula describes those that partly overlap from +% the right. Areas which are sub- or super-areas, e.g., \texttt{t13} +% and \texttt{t22} do not affect each other. The above restriction is +% necessary to prevent situations like +%\begin{verbatim} +%aaaaaaaaaaa 444 +%aaaaaaaaaaa 444 +%aaaaaaaaaaa 444 +%111 222 bbbbbbb +%111 222 bbbbbbb +%111 222 bbbbbbb +%111 222 333 444 +%111 222 333 444 +%\end{verbatim} +% +% +% For each area |FOO| (e.g., |t13|) we keep a number of global +% variables to store relevant data. These are the following +% variables\footnote{Not a consistent lot}: +% +% \DescribeMacro\area@FOO +% Floats allocated to the area |FOO| by the page building process +% are stored as an |\@elt| list in the macro |\area@FOO|. +% +% \DescribeMacro\pagesetup@FOO@float@num +% The maximum number of floats allowed in area |FOO| is stored in +% the macro |\pagesetup@FOO@float@num|. +% +% \DescribeMacro\FOO@@float@count +% +% The number of floats currently allocated to area |FOO| is stored +% in the count register |\FOO@@float@count|.\footnote{This is a +% waste of registers!} +% +% \DescribeMacro\pagesetup@FOO@class@close +% The areas that should be closed for floats of the same sequence class the +% moment a float is placed into area |FOO|. This is a comma +% separated list. +% +% \DescribeMacro\pagesetup@FOO@all@close +% The areas that should be closed for all float sequence classes the +% moment a float is placed into area |FOO|. This is a comma +% separated list. +% +% +% +% \begin{macro}{\known@areas} +% |\known@areas| are the areas known to the system.\footnote{or +% something else, the semantics are still changing} Initialisation +% is done when declaring individual areas. +% \begin{macrocode} +\def\known@areas{} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\used@areas} +% |\used@areas| are the areas used by the current page setup. +% Initialisation is done in the page setup template so the +% definition below is arbitrary. +% \begin{macrocode} +\def\used@areas{ t11 b11 } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\@activelist} +% \begin{macrocode} +\let\@activelist\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@mvllist} +% \begin{macrocode} +\let\@mvllist\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\area@ddd} +% The list of deferred floats (which we consider being an area in +% some respects). +% \begin{macrocode} +\let\area@ddd\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pagesetup@ddd@class@close} +% \begin{macro}{\pagesetup@ddd@all@close} +% \begin{macrocode} +\def\pagesetup@ddd@class@close{\pagesetup@area@list} +\let\pagesetup@ddd@all@close\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\this@open@areas} +% \begin{macro}{\saved@this@open@areas} +% In |\this@open@areas| we store the float areas which we will try +% to place a float onto the current page. These areas are tried one +% after another until the float is successfully placed or we run +% out of areas. The list does not have any separator (as we assume +% that all areas are denoted by a letter followed by two digits). +% +% |\saved@this@open@areas| is the seved version needed for +% backtracking if we encounter a flush point that can't be resolved. +% \begin{macrocode} +\let\this@open@areas\@empty +\let\saved@this@open@areas\@empty +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\this@closed@areas} +% In |\this@closed@areas| we store the float areas which have been +% closed for the current float while trying to place it. In this +% list each area name is followed by a comma (to avoid spurious +% matches). It is initialised with |closed@\this@class @areas| when +% we fetch a new float to try. Once the float is placed we write +% the then current value back. +% \begin{macrocode} +\let\this@closed@areas\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\this@page@closed} +% In |\this@page@closed| we store the float areas which have been +% closed for all float types. In this list each area name is +% followed by a comma (to avoid spurious matches). +% \begin{macrocode} +\let\this@page@closed\@empty +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\t11@float@count} +% \begin{macro}{\t21@float@count} +% \begin{macro}{\b11@float@count} +% \begin{macro}{\b21@float@count} +% The float counts are allocated dynamically when an area is +% declared if they are not defined, but we have a few registers +% left over from \LaTeX{}'s old OR so we might as well use them. +% \begin{macrocode} +%\expandafter\newcount\csname t11@float@count\endcsname +\expandafter\let\csname t11@float@count\endcsname \@topnum +%\expandafter\newcount\csname b11@float@count\endcsname +\expandafter\let\csname b11@float@count\endcsname \@botnum +%\expandafter\newcount\csname t12@float@count\endcsname +\expandafter\let\csname t12@float@count\endcsname \@dbltopnum +%\expandafter\newcount\csname b12@float@count\endcsname +\expandafter\let\csname b12@float@count\endcsname \@dblbotnum +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ddd@float@count} +% And we need to declare the one for the defer area is that isn't +% going through the normal initialisation process. +% \begin{macrocode} +\newcount\ddd@float@count +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\pagesetup@float@area@sep} +% |\pagesetup@float@area@sep| is the separation to use between two +% adjacent float areas. +% \begin{macrocode} +\newskip\pagesetup@float@area@sep +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\pagesetup@float@text@sep} +% |\pagesetup@float@text@sep| is the separation to use between +% column text and adjacent float areas. +% \begin{macrocode} +%\newskip\pagesetup@float@text@sep +\let\pagesetup@float@text@sep\textfloatsep % reuse register +\let\textfloatsep\@undefined +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\pagesetup@float@float@sep} +% |\pagesetup@float@float@sep| is the separation to use between +% two floats in the same float area. +% \begin{macrocode} +%\newskip\pagesetup@float@float@sep +\let\pagesetup@float@float@sep\floatsep % reuse register +\let\floatsep\@undefined +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\pagesetup@float@text@shrink} +% |\pagesetup@float@text@shrink| is the allowed shrinkability of +% |\pagesetup@float@text@sep|. This is used if we are doing grid +% typesetting and have to adjust the vertical size of the column. +% \begin{macrocode} +\newdimen\pagesetup@float@text@shrink +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\pagesetup@float@inline@sep} +% |\pagesetup@float@inline@sep| is the separation to use between +% two floats in the same float area. +% \begin{macrocode} +%\newskip\pagesetup@inline@float@sep +\let\pagesetup@float@inline@sep\intextsep % reuse register +\let\intextsep\@undefined +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\pagesetup@float@inline@shrink} +% |\pagesetup@float@inline@shrink| is the allowed shrinkability of +% |\pagesetup@float@inline@sep|. This is used if we are doing grid +% typesetting and have to adjust the vertical size of object to be +% added, e.g., an inline float with its caption. +% \begin{macrocode} +\newdimen\pagesetup@float@inline@shrink +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \subsubsection{Utilities for Float Areas and their Data Structures} +% +% +% \begin{macro}{\initialise@areas} +% Initialise all float areas used within the current page setup. +% \begin{macrocode} +\def\initialise@areas{ + \expandafter\initialise@areas@loop + \used@areas + \relax\relax\relax +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\initialise@areas@loop} +% The |\initialise@areas@loop| picks up the next three tokens and +% interprets them as the component of an area name. +% \begin{macrocode} +\def\initialise@areas@loop#1#2#3{ + \ifx#1\relax + \else + \global\csname #1#2#3@float@count\endcsname\z@ + \global\expandafter\let\csname area@#1#2#3\endcsname\@empty + \expandafter\initialise@areas@loop + \fi} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\first@of@type} +% The macro |\first@of@type| takes a \meta{type} name as its first +% argument and an \meta{area} area name as its second argument and +% will return in the macro |\returned@sequence@number| the sequence +% number of the first float of type \meta{type} currently in +% \meta{area}. If there is no float of type \meta{type} in this +% area it will return |-1| (impossible sequence number). +% \begin{macrocode} +\def\first@of@type#1#2{ + \begingroup + \def\@tempb{#1} + \gdef\returned@sequence@number{-1} + \def\@elt{\expandafter\first@of@type@aux\the\toks} + \csname area@#2\endcsname + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\first@of@type@aux} +% This macro picks up the type definition in the data structure of +% a float and compares it with the name started in |\@tempb|. If +% they agree |\returned@sequence@number| will get updated to +% contain the sequence number of the float. +% \begin{macrocode} +\def\first@of@type@aux#1#2#3#4#5#6#7{ + \def\@tempa{#6} + \ifx\@tempa\@tempb + \gdef\returned@sequence@number{#7} + \let\@elt\@gobble + \fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\last@of@type} +% The macro |\last@of@type| takes a \meta{type} name as its firat +% argument and an \meta{area} area name as its second argument and +% will return in the macro |\returned@sequence@number| the sequence +% number of the last float of type \meta{type} currently in +% \meta{area}. If there is no float of type \meta{type} in this +% area it will return |-1| (impossible sequence number). +% \begin{macrocode} +\def\last@of@type#1#2{ + \begingroup + \def\@tempb{#1} + \gdef\returned@sequence@number{-1} + \def\@elt{\expandafter\last@of@type@aux\the\toks} + \csname area@#2\endcsname + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\last@of@type@aux} +% \begin{macrocode} +\def\last@of@type@aux#1#2#3#4#5#6#7{ + \def\@tempa{#6} + \ifx\@tempa\@tempb + \gdef\returned@sequence@number{#7} + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\setup@this@area} +% +% Whenever the algorithm works with some area as the current +% candidate for putting a float into it uses the following commands +% to reference this area: +% +% \DescribeMacro\this@area +% The macro |\this@area| holds the name of the candidate area, e.g., +% it would expand to something like |t13|. +% +% \DescribeMacro\this@area@type +% The macro |\this@area@type| holds the ``type'' of the area, e.g., |t| +% in the above example. +% +% \DescribeMacro\this@area@col@number +% The macro |\this@area@col@number| holds the starting column of the +% area, e.g., |1| in the above example. +% +% +% \DescribeMacro\this@area@span@number +% The macro |\this@area@span@number| holds the number of columns +% spanned by the area, e.g., |3| in the above example. +% +% All the above macros are globally assigned when calling +% |\setup@this@area|. The argument is fully expanded (!) since one +% typical usage to pick up the first area from an area like +% |\this@open@areas| which can then be done within the argument. +% +% \begin{macrocode} +\def\setup@this@area #1 { + \xdef\this@area{#1} +% \end{macrocode} +% This really relies on |\this@area| containing exactly three +% tokens (no error recovery if not). +% \begin{macrocode} + \expandafter\gassign@area@type@col@and@span@aux\this@area +} +\def\gassign@area@type@col@and@span@aux #1#2#3{ + \gdef \this@area@type {#1} % type + \gdef \this@area@col@number {#2} % col + \gdef \this@area@span@number {#3} % span +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\update@this@area@columns} +% +% If we have to do updates for all columns that are spanned by the +% current target area we can call |\update@this@area@columns|. It +% loops through the columns with |\count@| referring to the current +% column. Data structure updates have to be global as everything +% happens within a group. +% \begin{macrocode} +\def\update@this@area@columns #1 { + \begingroup + \count@\this@area@col@number\relax + \advance\count@\this@area@span@number\relax + \loop + \ifnum \this@area@col@number < \count@ + \advance\count@\m@ne +%<*trace> + \tr@ce{looking~ at~ column:~ \the\count@} +%</trace> + #1 + \repeat + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \newpage +% \subsection{Collection Output Routine} +% +% \begin{description} +% \item[Entry:] |\setup@collection@or| +% \item[Exit:] |\setup@float@placement| +% \item[Prereq:] |\initialise@next@page| should have been called before. +% \item[Description:] Grab enough text (and float call-outs) to obtain +% a galley big enough to form the next text page. The page goal is +% set to a value high enough to ensure that in normal cases text +% for all columns of the page is collected, i.e, we have a safety +% margin of 5 extra lines per column.\footnote{This should be made +% customisable for unusual jobs!} +% +% If the output routine is triggered with a special penalty (in the +% range of $-10000>p>-10010=|\output@balance@penalty|$) the penalty +% is moved into the collection box |\partial@galley@box| without +% further processing; otherwise the collection is ended and all +% collected material is moved to |\@holdpg| for use in page +% production. +% +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \setup@collection@or +% | +% V +% New OR: \collection@or +% | +% |<----------------------------------------- +% | | +% (natural end of collection reached?) | +% | | | +% yes no | +% | | | +% | (record special penalty and carry on)---- +% | +% V +% \setup@float@placement +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% Chris noted that |\@holdpg| never gets emptied. This could be +% done when the Collection OR is started for a new page (in this +% next macro).\footnote{FIX} +% +% \begin{macro}{\setup@collection@or} +% \begin{macrocode} +\def\setup@collection@or{ +%<*trace> + \@tracepush{setup@collection@or} +%</trace> + \global\holdinginserts\@ne +% \end{macrocode} +% We set the |\vsize| for collection to the height of a single +% column (plus a safety margin of currently five lines to allow for +% vanishing space at margins) multiplied by the number of columns. +% \begin{macrocode} + \global\vsize\textheight + \global\advance\vsize 5\baselineskip + \global\multiply\vsize \col@count +%<*trace> + \tr@ce{collection~vsize:~\the\vsize } +%</trace> +% \end{macrocode} +% Initialising the flush point handling: +% \begin{macrocode} + \@flushseenfalse + \@flushfailfalse +% \end{macrocode} +% We may have to restart the collection (whenever we find a here or +% a flush point) and we don't want to get extra space added via +% |\topskip|. So we can either make |\topskip| zero during +% collection (current strategy) or back it out whenever we restart. +% +% We can't set topskip to zero now since a) we want a proper +% |\topskip| for the first column and b) due to a bloody fix for the +% old \LaTeX{} OR, a value of |0pt| is set to |1sp| in +% |\begin{document}| and this results in adding |1sp| at every +% special point\ldots no, we definitely do not want this! It took +% me ages to find out why the grid design macros didn't work. +% \begin{macrocode} + \xdef\saved@topskip{\the\topskip} +% \end{macrocode} +% +% \begin{macrocode} + \global\output{\collection@or} +%<*trace> + \@tracepop{setup@collection@or} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\if@collecting@new@material} +% There are actually two collecting modes: one when the recent +% contributions are empty and we are really collecting material +% that we haven't seen before and one where we collect material +% that has been collected on a previous collection pass and has been +% placed again on to the main vertical list. The reason why we need +% to differentiate between the two is that in the second case we +% have to handle the special penalties differently since by now +% they are already surrounded by the proper guard boxes before and +% after and we better do not disturb this fragile setup. +% \begin{macrocode} +\newif\if@collecting@new@material +\def\@collecting@new@materialfalse + {\global\let\if@collecting@new@material\iffalse} +\def\@collecting@new@materialtrue + {\global\let\if@collecting@new@material\iftrue} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\collection@or} +% The output routine during the collection phase assembles the +% material until enough has been gathered to be sure to fill a +% page. +% \begin{macrocode} +\def\collection@or{ +%<*trace> + \@tracepush{collection@or} + \tr@ce{output~pen:~ \the\outputpenalty} +%{\x\showoutput\showbox255} +%</trace> +% \end{macrocode} +% We first look if the call to the OR is due to a special penalty. +% \begin{macrocode} + \@testfalse + \ifnum\outputpenalty < -\@M + \ifnum\outputpenalty > -\output@balance@penalty + \@testtrue + \fi + \fi + \if@test +%<*trace> + \tr@ce{Forced~ break~(\the\outputpenalty)~ seen\on@line} +%</trace> +% \end{macrocode} +% Whenever a special penalty, i.e., one between $-10000 > p > +% -10010$ is encountered we need some magic: +% \begin{itemize} +% \item We want to keep the the penalty in the collected material but +% nevertheless carry on with the collection. Simply moving the +% collected material to a separate box is not enough since then +% we will restart the collection with an empty page and thus +% receive a |\topskip| glue as well as probably losing material +% if there is anything discardable after the special penalty. +% \item But putting a zero box back and doing something to fix the +% problem with the |\topskip| glue isn't good either in case we +% later actually want to break after the line with special +% penalty, since then we would start a page with our inserted +% box, and in this case we would like to get a proper |\topskip| +% and we would like to get rid of discardable stuff. +% \item And there is another problem, we need a guard box in front of +% that special penalty, but this guard box should not be simply a +% |\null| box (as it is right now added by +% |\add@badly@guarded@penalty|) since that will result in wrong +% page calculations because it will make \TeX{} add the depth of +% the precious line to the page total which it shouldn't. +% \end{itemize} +% So what to do? First of all we remove the guard box in front of +% the special penalty (which is now at the end of box 255) since we +% want to replace that with something better, then we +% store away the depth of box 255 since we need that in a minute. +% \begin{macrocode} + \remove@guard@box@from@cclv +% \end{macrocode} +% We really have to say |\dp\@cclv| not |\pagedepth|. The latter is +% always zero in the OR which looks suspiciously like a bug or at +% least an inconsistency when Don implemented the change from \TeX2 +% to \TeX3 (in \TeX2 |\page...| registers were useless in the OR, +% now only |\pagedepth| seems to be left). +% \begin{macrocode} + \dimen@\dp\@cclv +% \end{macrocode} +% Then we subtract the size of the collected material from +% |\vsize| since we will store it away in a separate box for a +% while. Note that we have to use |\ht\@cclv| here not |\pagetotal| +% since the latter might be to large because of that |\null| +% box. The height of 255 on the other hand is, after the removal of +% that box the natural height of the material. +% \begin{macrocode} + \global\advance\vsize-\ht\@cclv +% \end{macrocode} +% Now we append the material to |\partial@galley@box|, this is +% straight forward. +% \begin{macrocode} + \global\setbox\partial@galley@box + \vbox{\ifvoid\partial@galley@box + \else + \unvbox\partial@galley@box + \fi + \unvbox\@cclv +% \end{macrocode} +% But how to add the penalty and how to guard it? We need a box or +% something to ensure the penalty doesn't get lost at a column +% break but we also want to avoid that \TeX{} adds the depth of the +% preceding line to |\pagetotal|. Fortunately we know this depth by +% now (we have just stored it in |\dimen@|), something we didn't +% know at the time the we added the penalty with +% |\add@badly@guarded@penalty|. So we could back up and then add a +% box with zero height and that depth. This way a break directly +% after this line would have the same |\pagetotal| as a break at +% the special penalty. In fact, instead of backing up using a +% |\kern| or a |\vskip| we can simply make the height of the box +% negative. The advantage is that this way we don't generate a +% break point between the box and a preceding box and thus don't +% have to use special precautions to prevent \TeX{} from breaking in +% front of the guard box.\footnote{This statement is only true for +% special penalties added using \texttt{\string\vadjust}, i.e., in +% hmode. If the penalty was added between paragraphs then there +% might be vertical space in front of the box. This might need +% special handling too. CHECK!} +% \begin{macrocode} + \setbox\z@\vbox to-\dimen@{} + \dp\z@\dimen@ + \box\z@ + \penalty\outputpenalty + } +%{\showoutput\batchmode\showbox\partial@galley@box\errorstopmode} +% \end{macrocode} +% So now we have put everthing we need into the +% |\partial@galley@box|, but how do we restart our collection +% process without running into the problems outlined above? +% +% Well, right now on the recent contributions there will be a +% penalty node (from our special penalty) which gets set to 10000 +% by \TeX{} followed perhaps by another penalty from the line +% breaking followed probably by interline glue calculated to make +% the next line of text fit vertically with the preceding one --- +% and we don't want to loose that that glue if we are ending up in +% the middle of a column. But we want to make it vanish if we +% happen to finally break at the special penalty place. +% +% So the trick is that we a) disable |\topskip| by setting it to +% |-\maxdimen| (not zero this might be too large still) and b) we +% add another of those funny boxes followed by a penalty of zero to +% allow for a break after it. +% +% If later on all this is put together again into a single box (in +% |\@holdpg|) we will have the following sequence there: +% \begin{itemize} +% \item text line (box) preceding the special penalty with depth $d$ +% or some other vertical material in which case $d=0\texttt{pt}$ +% \item special box with height $-d$ and depth $d$ +% \item special penalty, e.g. $-10008$ +% \item |\topskip| glue of 0pt +% \item special box with height $-d$ and depth $d$ +% \item |\penalty| 0 +% \item |\penalty| 10000 +% \item perhaps a |\penalty| and/or interline glue +% \item perhaps the next text line (box) +% \end{itemize} +% Now if during later processing we hit the special penalty +% |\pagetotal| has the same value as if we would have broken the +% galley directly after the text line, in other words we do not see +% the penalty too late (assume this happens to be the last line of +% the column then if |\pagetotal| would also have the extra depth +% added to it it might have been overfull and the penalty not being +% considered at all for this column). +% +% After the OR's have dealt with the special penalty, e.g., by +% flushing some floats, etc. the penalty will be replaced by 10000 +% and thus the next time the galley is processed there is no +% breakpoint between the two special boxes any more. As a result +% the next potential breakpoint is the penalty 0 which again +% results in exactly the same |\pagetotal| as before, i.e., if the +% text line was the last line to fit in the column then this +% breakpoint will still fit there. Thus if we break the column +% there then the interline glue etc will vanish and \TeX{} will +% insert |\topskip| glue (which has be set back to a normal value +% by then). If on the other hand, this break point is not chosen +% the interline glue will stay and thus the two text lines, before +% and after the special penalty will sit one |\baselineskip| apart +% just as they should. +% +% Woah. What did Don said on page 125 of \textit{The \TeX{}book}? +% (Deep breath.) You got that?\footnote{There are probably still +% cases that aren't covered I fear and the need for an explicit +% penalty 0 at the end is kind of toublesome, so we have to see if +% this needs further refinements.} +% +% And here is already the first case where the above method is not +% appropriate: if we stumble across a |\output@columnbreak@penalty| +% we need to discard any following glue, so we don't want a box +% intervene here.\footnote{Once this is interfaced with the galley +% code problems like this should vanish since then we can ensure +% that all such penalties are added to the galley on at save +% places. REDO THEN!} +% \begin{macrocode} + \global\topskip-\maxdimen % okay here? + \if@collecting@new@material + \ifnum \outputpenalty = -\output@columnbreak@penalty + \else + \setbox\z@\vbox to-\dimen@{} + \dp\z@\dimen@ + \box\z@ + \penalty\z@ + \fi + \fi +% \end{macrocode} +% +% \begin{macrocode} + \ifnum\outputpenalty=-\output@flush@float@penalty +%<*trace> + \tr@ce{Forced~ break~ =~ flush~ float~ point} +%</trace> + \@flushseentrue + \fi +% \end{macrocode} +% Otherwise either the we reached the natural end of the +% collection, or the point where we have been before (in case we +% are recollecting previously seen material) or we reached an +% |\output@balance@penalty|. +% \begin{macrocode} + \else + \ifnum\outputpenalty = -\output@collect@penalty +% \end{macrocode} +% If we got an |-\output@collect@penalty| then we are at the point +% to which the previous collection pass got. So, away with the +% guard box, then everything back onto the MVL and as a penalty we +% try to put what we have found in the previous collection pass. +% \begin{macrocode} + \remove@guard@box@from@cclv + \unvbox\@cclv +%<*trace> + \tr@ce{reinsert~penalty:~ \saved@outputpenalty\space + (unless~ 10000~ or~ <~ -9999)} +%</trace> + \ifnum\saved@outputpenalty > -\@M + \penalty + \ifnum\saved@outputpenalty=\@M + \z@ + \else + \saved@outputpenalty\relax + \fi +% \end{macrocode} +% We have a special situation to account for here: if we have a +% |\pagebreak| that ended the collection last time then it might +% still be the case that we haven't got to this point due to +% floats. So we would need to put that penalty back. But only then, +% and therese the catch! The alternative is to not stop a +% collection as such a point so that this problem doesn't arise in +% the first place. Right now we lose the +% penalty.\footnote{Unresolved situation. FIX!} +% \begin{macrocode} + \else + \fi +% \end{macrocode} +% Finally we change the |@collecting@new@material| switch since we +% are from now on looking at really new material. +% \begin{macrocode} + \@collecting@new@materialtrue + \else +% \end{macrocode} +% Next case is not functional right now\ldots +% \begin{macrocode} + \ifnum\outputpenalty = -\output@balance@penalty + \@balancetrue +%<*trace> + \tr@ce{BALANCE:~ break~ seen\on@line} +%</trace> + \xdef\saved@outputpenalty{0} +% \end{macrocode} +% This is now the point where the collection ended naturally: we +% save the penalty that triggered it and combine the +% |\partial@galley@box| if it contains material with the stuff now +% in 255 and put everything into |\@holdpg|. +% \begin{macrocode} + \else + \xdef\saved@outputpenalty{\the\outputpenalty} + \fi + \ifvoid\partial@galley@box + \global \setbox\@holdpg\box\@cclv + \else +%<*trace> + \tr@ce{Re-adding~ forced~ break(s)~ for~ splitting} +%</trace> + \global\setbox\@holdpg\vbox{ + \unvbox\partial@galley@box + \unvbox\@cclv} + \fi + +%\showbox\@holdpg + + \if@balance + \global\setbox\@holdpg\vbox{ + \unvbox\@holdpg + \penalty\outputpenalty % short for "-\output@balance@penalty" + } + \fi + + \mark@save@state + \mark@update@structure +% + \global\holdinginserts\z@ + + \global\topskip\saved@topskip + + \setup@float@placement + + \@collecting@new@materialfalse + \fi + \fi +%<*trace> + \@tracepop{collection@or} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\partial@galley@box} +% Need a box to store the partially collected galley. +% \begin{macrocode} +\newbox\partial@galley@box +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\initialise@float@class} +% +% \begin{macrocode} +\def\initialise@float@class#1{ +%<*trace> + \@tracepush{initialise@float@class} +%</trace> + \count@0\LastMark{#1} +% +% next line no longer used +% \global\expandafter\mathchardef\csname count@#1\endcsname\count@ +% +%<*trace> + \tr@ce{count~ (#1) = \the\count@} +%</trace> +% \end{macrocode} +% +% At some point the set of open areas at page start (for a +% given type of floats) should be specifiable through some +% templates. Using |\used@areas| is not really the right thing +% to do.\footnote{Code should vanish one day}. +% \begin{macrocode} + \global\expandafter\let\csname open@#1@areas\endcsname\used@areas + \global\expandafter\let\csname closed@#1@areas\endcsname\@empty +% \end{macrocode} +% +% \begin{macrocode} +%<*trace> + \tr@ce{open~ (#1) = \csname open@#1@areas\endcsname} + \tr@ce{closed~ (#1) = \csname closed@#1@areas\endcsname} +%</trace> +% \end{macrocode} +% +% |\fl@1@figure| are macros that expands to the highest numbered +% figure callout in this column (or zero if there is none). +% |\fl@0@figure| is the highest value from previous pages (or zero +% if there was never any float of this type). +% \begin{macrocode} + \forall@columns { + \ifnum \csname fl@ \the\curr@col@count @#1\endcsname>\z@ + \global\expandafter\let\csname fl@0@#1\expandafter\endcsname + \csname fl@ \the\curr@col@count @#1\endcsname + \expandafter\xdef + \csname fl@ \the\curr@col@count @#1\endcsname{0} + \fi +% \end{macrocode} +% |\tfl@1@figure| is like |\fl@1@figure| but only stores +% information about floats allocated to top areas. +% \begin{macrocode} + \expandafter\xdef + \csname tfl@ \the\curr@col@count @#1\endcsname{0} + } +%<*trace> + \@tracepop{initialise@float@class} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% +% \newpage +% +% \subsection{Placing Floats} +% +% +% \begin{description} +% \item[Entry:] |\setup@float@placement| +% \item[Exit:] |\setup@grab@column@or| or |\setup@best@column@or| +% \item[Prereq:] +% \item[Description:] +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \setup@float@placement +% | +% V +%(2)--> \float@placement@loop +% | +% <run with floats?> +% | | +% yes no----------> \setup@grab@column@or +% | +% V +% \trial@inner@loop +% | +% V +% <current float successfully placed in previous trial?> +% | | +% no yes +% | | +% (means we now try V +% again using different \try@next@float <------------------- +% placement rules below ) | | +% | | | +% | <\@activelist empty?> | +% | | | | +% | no yes | +% | | | | +% | | V | +% | (get it) \@activelist@empty@action | +% | | (= \setup@best@column@or) | +% -------------v---------------- | +% | | +% -----> \try@this@area (= \std@try@this@area, or | +% | | \relaxed@try@this@area) | +% | | | +% | <still open areas for current float type?> | +% | | | | +% | yes no---------------(defer float)-------------- +% | | | +% | (do some tests and perhaps | +% | close area this way) | +% | | | +% | <float allowed on this page/column (according to tests)?> | +% | | | | +% | yes no---------------(defer float)-------------- +% | | +% | <current area got closed by any test?> +% | | | +% | yes no +% | | | +% | (select next area) | +% | | | +% -------- V +% \pretests@success@action (\setup@grab@column@or) +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% +% +% +% +% \begin{macro}{\if@fail} +% \begin{macrocode} +\newif\if@fail +\def\@failfalse{\global\let\if@fail\iffalse} +\def\@failtrue{\global\let\if@fail\iftrue} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\setup@float@placement} +% +% \begin{macrocode} +\def\setup@float@placement { +% initialise before trial loop (needs work) +%<*trace> + \@tracepush{setup@float@placement} +%</trace> +% \end{macrocode} +% A bit statistics: how many floats do we have on the +% |\@activelist|? +% \begin{macrocode} +%<*progress> + \def\@elt{\global\advance\trial@count\@ne\@gobble} + \@activelist + \let\@elt\relax + \progress@separator + \progress@nl{STATS:~ floats~ waiting~ =~ \the\trial@count + \space on~ page~ \the\absolute@page@number} + \progress@separator + \global\trial@count\z@ +%</progress> +% \end{macrocode} +% We need the list of here floats during all trials. They are +% therefore saved in |\saved@herelist| at this point which is then +% used to initialise |\@herelist| at the beginning of each trial. +% \begin{macrocode} + \global\let\saved@herelist\@herelist +% \end{macrocode} +% +% \begin{macrocode} + \tighten@float@placement@conditions +% \end{macrocode} +% First time we run the |\float@placement@loop| we run it without +% actually trying any floats (i.e., we are just cutting the +% galley).\footnote{Could be improved: if there are no floats then +% we run it once too often this way (per page) so\ldots} +% \begin{macrocode} + \run@with@floatsfalse + \float@placement@loop +%<*trace> + \@tracepop{setup@float@placement} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\float@placement@loop} +% Place the galley box back on the MVL. Needs to be done via the +% special output routine call |\mark@restore@state| to ensure that +% \TeX's primitive marks reflect the `logical' previous page rather +% than the previous actual output routine call. +% \begin{macrocode} +\def\float@placement@loop{ +%<*trace> + \@tracepush{float@placement@loop} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \deadcycles\z@ + \global\let\@activelist@empty@action\setup@best@column@or + \global\let\pretests@success@action\setup@grab@column@or +% \end{macrocode} +% +% If we are doing trials we have to place a special penalty at the +% end of the MVL but if we are cutting up the galley for +% typesetting we don't want this penalty. Since at this point it is +% not clear in which case we are we defer this action until +% later.\footnote{This part of the documentation is no longer true, +% we now add it below. CORRECT DOCU} +% +% |\mark@restore@state| state is a special output routine those +% only purpose is to reinitialise the state of the mark +% mechanism. Its argument is executed at the of that OR. +% \begin{macrocode} + \mark@restore@state{ +% \end{macrocode} +% Initialising the grabbing trials means putting the saved material +% back onto the MVL and reinitialising the here float list. +% \begin{macrocode} + \unvcopy\@holdpg + \ifnum\saved@outputpenalty > -1073741824\relax + \add@badly@guarded@penalty\output@collect@penalty + \fi + \global\let\@herelist\saved@herelist +% \end{macrocode} +% +% The we can start the actual loop: if we run with floats we go to +% |\trial@inner@loop| otherwise we immediately setup the grap +% column OR. +% \begin{macrocode} + \ifrun@with@floats + \trial@inner@loop + \else + \setup@grab@column@or + \fi + } +%<*trace> + \@tracepop{float@placement@loop} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\trial@inner@loop} +% Alternative entry into the float placement trial loop. This can +% be used by setting |\@activelist@empty@action| and +% |\pretests@success@action| to different values, e.g., for trying +% float pages without the overhead of the grabcolumn output +% routine, etc. +% \begin{macrocode} +\def\trial@inner@loop{ +%<*trace> + \@tracepush{trial@inner@loop} +%</trace> +% \end{macrocode} +% If |\if@fail| is true we have already tried the current float +% before. This means we either do a retry with relaxed conditions +% (in which case the current area to try was suitably modified +% beforhand) or else we have just started with a new float and +% should try the first area of |\this@open@areas|. +% \begin{macrocode} + \if@fail + \@failfalse + \@flushfailfalse +% \end{macrocode} +% +% \begin{macrocode} +%<*progress> + \global\advance\trial@count\@ne +%</progress> +% \end{macrocode} +% +% \begin{macrocode} + \do@next\try@this@area + \else + \do@next\try@next@float + \fi +%<*trace> + \@tracepop{trial@inner@loop} +%</trace> + \do@continue + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\trial@count} +% To gather statistics we count the number of trials per page. +% \begin{macrocode} +%<*progress> +\newcount\trial@count +%</progress> +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\try@this@area} +% |\try@this@area| is |\let| to the right definition before it is +% called so on top-level it is defined to be an error. +% \begin{macrocode} +\let\try@this@area\ERROR +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\try@next@area} +% |\try@next@area| first updates |\this@open@areas| by removing the +% first area in this list and then calls |\try@this@area|. Thus it +% should never be called if |\this@open@areas| is already empty. +% \begin{macrocode} +\def\try@next@area{ + \xdef\this@open@areas{\expandafter\@gobblethree\this@open@areas} +%<*progress> + \global\advance\trial@count\@ne +%</progress> + \try@this@area +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\try@next@float} +% If there is still a float on the active list take it and try to +% place it in the next open float area (which will be the same as +% the current area after a successful trial). If there are no +% floats left execute |\best@trial| to return to that state then +% switch to the bestcolumn output routine to begin typesetting +% columns. +% \begin{macrocode} +\def\try@next@float{ +%<*trace> + \@tracepush{try@next@float} +%</trace> + \@next\@currbox\@activelist{ +%<*trace> + \tr@ce{currbox:~ \@currbox} +%</trace> +%<*progress> + \progress{Float:~ \@currbox} +%</progress> + \expandafter\update@this@float@structure\the\toks\@currbox +%<*trace> + \tr@ce{saved@this@open@areas~(init):~ + \saved@this@open@areas\space :=~\this@open@areas} +%</trace> + \global\let\saved@this@open@areas\this@open@areas +%<*progress> + \global\advance\trial@count\@ne +%</progress> + \try@this@area + } +% \end{macrocode} +% no floats left\ldots +% \begin{macrocode} + { +%<*progress> + \progress@nl{STATS:~ trials~ =~ \the\trial@count} + \global\trial@count\z@ +%</progress> + \@activelist@empty@action + } +%<*trace> + \@tracepop{try@next@float} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\update@this@float@structure} +% Each float box has an associated token register storing several +% information fields. +% \begin{enumerate} +% \item[1] float caption (set by caption command) +% \item[2] Currently unused (could have callout page number, set by +% |\best@column@or|). +% \item[3] saved label string +% \item[4] `user counter' number (per-type count) set by float environment. +% \item[5] Allowed float areas (from default or optional arg.) +% \item[6] float type (currently this is the long name, eg figure) should +% probably be the single token name, to allow quicker testing. +% \item[7] float sequence number. +% \end{enumerate} +% +% This macro assumes that |\@currbox| is the box number for this structure +% \begin{macrocode} +\def\update@this@float@structure#1#2#3#4#5#6#7{ + \gdef\this@caption{#1} + \gdef\this@span@number{#2} + \gdef\this@usercnt{#4} + \gdef\this@fps{#5} + \gdef\this@type{#6} +% \end{macrocode} +% From the type we infer the class: +% \begin{macrocode} + \global\expandafter\let\expandafter + \this@class\csname sequence@class@#6\endcsname + \gdef\this@sequence@number{#7} +% \end{macrocode} +% If we want to consider all areas for each float (and storing +% closed areas via |\closed@|\meta{type}|@areas| we have to +% initialise |\this@open@areas| to |\used@areas| (which is +% derived from the |area-list| key. +% \begin{macrocode} + \global\let\this@open@areas\used@areas +% \end{macrocode} +% +% \begin{macrocode} + \global\expandafter\let\expandafter\this@closed@areas + \csname closed@\this@class @areas\endcsname % FMi tmp + \global\let\this@float@box\@currbox +%<*trace> +\tr@ce{This~float~structure:} +\toks@{#1}\tr@ce{~{\the\toks@}} +\tr@ce{~{#2}} +\tr@ce{~{#3}} +\tr@ce{~{#4}} +\tr@ce{~{#5}} +\tr@ce{~{#6}} +\tr@ce{~{#7}} +\tr@ce{~this@open@areas~ <-~ \this@open@areas} +\tr@ce{~this@closed@areas~ <-~ \this@closed@areas} +%</trace> +%<*progress> +\progress{~{#7}} +\progress{~{#6}~(\this@class)} +\progress{~{#4}} +%\progress{~{#2}} +%\progress{~{#3}} +%\progress{~{#5}} +\toks@{#1}\progress@nl{~{\the\toks@}} +%</progress> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\extract@this@float@actual@structure} +% As used by Chris in xo-final. Should probably be replaced by the +% one above or combined with the one above!\footnote{FIX!!} +% \begin{macrocode} +\def \extract@this@float@actual@structure #1#2#3#4#5#6#7 { + \gdef\this@caption{#1} + \gdef\this@span@number{#2} + \gdef\this@loglabel{#3} + \gdef\this@usercnt{#4} + \gdef\this@fps{#5} + \gdef\this@type{#6} + \global\expandafter\let\expandafter + \this@class\csname sequence@class@#6\endcsname + \gdef\this@sequence@number{#7} + } +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\update@here@float@structure} +% +% Similar to |\update@this@float@structure| but filling different +% macros.\footnote{We only need some of those macros, so this +% should be cleaned up at some stage.} +% +% This macro assumes that |\@currbox| is the box number for this +% structure. +% +% \begin{macrocode} +\def\update@here@float@structure#1#2#3#4#5#6#7{ + \gdef\here@span@number{#2} + \gdef\here@type{#6} + \global\expandafter\let\expandafter + \here@class\csname sequence@class@#6\endcsname + \gdef\here@sequence@number{#7} + \gdef\here@usercnt{#4} +% \gdef\here@fps{#5} + \gdef\here@caption{#1} + \global\let\here@float@box\@currbox +%<*trace> +\tr@ce{Here~object~structure:} +\toks@{#1}\tr@ce~{~{\the\toks@}} +\tr@ce{~{#2}} +\tr@ce{~{#3}} +\tr@ce{~{#4}} +\tr@ce{~{#5}} +\tr@ce{~{#6}} +\tr@ce{~{#7}} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \begin{macro}{\page@float@count} +% \begin{macrocode} +%\newcount\page@float@count +\let\page@float@count\@colnum +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\this@captioned@float} +% \begin{macrocode} +\newbox\this@captioned@float +% \end{macrocode} +% \end{macro} +% +% +% +% \newpage +% +% \subsection{Grab Column Output Routine} +% +% \begin{description} +% \item[Entry:] |\setup@grab@column@or| +% \item[Exit:] |\setup@cleanup@or| +% \item[Prereq:] +% \item[Description:] +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \setup@grab@column@or +% | +% New OR: \grab@column@or +% | +% V +% \grab@column@loop <------- +% | +% (when entering OR...) +% | +% <end of collection reached?> +% | | +% yes no +% | | +% | <col break requested?> +% | | | +% | yes no +% | | | +% | | <flush point encountered?> +% | | | | +% | | yes no +% | | | | +% | | <flush point <here point encountered?> +% | | too early?> | | +% | | | | yes no +% | | yes no | | +% | | | | ? ? +% | | | (ignore break) +% | | | | +% | | | | +% (end column now) <------- | +% | | +% V | +% <all cols produced?> | +% | | V +% yes no--------------------> (reenter \grab@column@loop) +% | +% (store results of trial) +% | +% V +% \setup@cleanup@or +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% +% +% \begin{macro}{\setup@grab@column@or} +% +% \begin{macrocode} +\def\setup@grab@column@or{ +%<*trace> + \@tracepush{setup@grab@column@or} +%</trace> +% \end{macrocode} +% +% We just returned to the MVL the current galley. We now add a +% special penalty to mark the point that we need to reach in order +% to remove everything after the trial run. +% This penalty has to be guarded against premature removal, e.g., +% if the algorithm would break exactly before it it would then be +% discarded which we can't allow.\footnote{Penalty now added +% earlier (normally). CORRECT DOCU} +% \begin{macrocode} + \ifnum\saved@outputpenalty = -1073741824\relax + \add@badly@guarded@penalty\output@collect@penalty + \fi +% \end{macrocode} +% +% \begin{macrocode} + \@failfalse + \global\curr@col@count\z@ +% \end{macrocode} +% In case there is a flush penalty in the collection we have to +% find out if we see it again during the trial. So we record the +% number of flush points we see during the trial. Same happens for +% here points. +% \begin{macrocode} + \gdef\trial@flush@seen@num{0} + \gdef\trial@here@seen@num{0} +% \end{macrocode} +% +% Moved from |\try@this@area| as it should be executed +% only if we really do a trial and thus back it out if +% unsuccessful---this was a bug as it changed +% |\fl@|\meta{col}|@|\meta{type} in cases we never came to this +% point here but recursed) +% \begin{macrocode} + \ifrun@with@floats +% \end{macrocode} +% Depending on the policy a spanning float can be considered belong +% to different columns. This influences the behaviour of the +% call-out contraint tests and is determined by the code stored in +% |\calculate@target@fl@column|. +% \begin{macrocode} + \calculate@target@fl@column +% \end{macrocode} +% |\calculate@target@fl@column| returns its calculated column +% number in |\count@|. +% \begin{macrocode} + \global\expandafter\let\expandafter\saved@fl@ + \csname fl@\the\count@ @\this@class\endcsname + \global\expandafter\let + \csname fl@\the\count@ @\this@class\endcsname + \this@sequence@number +%<*trace> + \tr@ce{~fl@\the\count@ @\this@class\space <-~ + \csname fl@\the\count@ @\this@class\endcsname} +%</trace> +% \end{macrocode} +% If we are adding to a top area we also have to update the +% corresponding |tfl@| commands: +% \begin{macrocode} + \if t\this@area@type + \global\expandafter\let\expandafter\saved@tfl@ + \csname tfl@\the\count@ @\this@class\endcsname + \global\expandafter\let + \csname tfl@\the\count@ @\this@class\endcsname + \this@sequence@number +%<*trace> + \tr@ce{~tfl@\the\count@ @\this@class\space <-~ + \csname tfl@\the\count@ @\this@class\endcsname} +%</trace> + \fi + \fi +% \end{macrocode} +% +% If we have seen any flush points during collection we need to +% save their current |min@col| positions in case we have to throw +% away the current trial. +% \begin{macrocode} + \if@flushseen + \count@\z@ + \@whilenum \flush@seq@num>\count@ \do + { \advance\count@\@ne + \global\expandafter\let + \csname saved@flush@min@col@\the\count@ \expandafter\endcsname + \csname flush@min@col@\the\count@\endcsname +%<*trace> + \tr@ce{saved@flush@min@col@\the\count@ \space <-~ + \csname flush@min@col@\the\count@\endcsname} +%</trace> + } + \fi +% \end{macrocode} +% +% \begin{macrocode} + \initialise@footins@action +% \end{macrocode} +% +% \begin{macrocode} + \global\output{\grab@column@or} + \grab@column@loop +% \end{macrocode} +% +% \begin{macrocode} +%<*trace> + \@tracepop{setup@grab@column@or} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\calculate@target@fl@column} +% \begin{macro}{\calculate@target@fl@column@flexible} +% \begin{macro}{\calculate@target@fl@column@strict} +% The purpose of |\calculate@target@fl@column| is to calculate +% the column number for which the |\fl@|\meta{col}|@number| has to +% be updated in case we place the current float into the area with +% start column |\this@area@col@number| and span-number +% |\this@area@span@number|. It returns the calculated number in +% |\count@|. +% +% For non-spanning floats it is simply returning +% |\this@area@col@number|. If we return this value also in case of +% spanning floats then this means that we claim that the float has +% be placed the first of its spanned columns. Alternatively we +% could return the last of the spanned columns which would if the +% |column| policy is in force, allow to place a float into |t12| +% even if its call-out is in the second column. +% +% The real value for |\calculate@target@fl@column| will be assigned +% in the page setup template. +% \begin{macrocode} +\let\calculate@target@fl@column \ERROR +% \end{macrocode} +% +% And here are the two possibilities. +% \begin{macrocode} +\def\calculate@target@fl@column@flexible { + \count@\this@area@col@number\relax + \advance\count@\this@area@span@number\relax + \advance\count@\m@ne +} +% \end{macrocode} +% +% \begin{macrocode} +\def\calculate@target@fl@column@strict { + \count@\this@area@col@number\relax +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\ifrun@with@floats} +% \begin{macro}{\run@with@floatstrue} +% \begin{macro}{\run@with@floatsfalse} +% +% \begin{macrocode} +\newif\ifrun@with@floats +\def\run@with@floatsfalse{\global\let\ifrun@with@floats\iffalse} +\def\run@with@floatstrue{\global\let\ifrun@with@floats\iftrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\grab@column@loop} +% The |\grab@column@or| output routine is responsible for +% constructing one column of a layout trial. The loop command +% increments the column count and sets vsize to the target height +% for the current column (which has already been set based on the +% size and position of the floats in this trial layout. +% \begin{macrocode} +\def\grab@column@loop{ +%<*trace> + \@tracepush{grab@column@loop} +%</trace> + \global\advance\curr@col@count\@ne + \global\vsize\csname col@ht@ \the\curr@col@count\endcsname +%<*trace> + \@tracepop{grab@column@loop} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \begin{macro}{\some@column@or} +% |\grab@column@or| and |\best@column@or| are sharing most of their +% code which is therefore placed into a separate macro. At the +% moment it takes 4 arguments: the name (``grab'' or ``best''), +% what to do when we actually finish the column +% (``|\grab@column@or@finish|'' or ``|\best@column@or@finish|''), +% what to do for a flush point, and what to do when we encounter a +% here float.\footnote{This code needs a bit of redesign to deal +% properly with the case that we have stumbled upon one of the +% special penalties. In this case we need to ensure that we also +% remove the special box after the penalty in case we are at a +% column break. This is not done right now so that in this case we +% will not dicard material at the top of the column properly. FIX!!!!} +% \begin{macrocode} +\def\some@column@or #1#2#3#4{ +%<*trace> + \@tracepush{#1@column@or} + \tr@ce{output~pen:~ \the\outputpenalty} + \tr@ce{#1~ col:~ \the\curr@col@count\space of~ \the\col@count} +%</trace> + \handle@case@of@premature@ending + \handle@case@of@forced@pagebreak +% \end{macrocode} +% If the |\outputpenalty| is |-\output@flush@float@penalty| we +% have reached a float flush point in the galley. +% \begin{macrocode} + \ifnum\outputpenalty=-\output@flush@float@penalty + \gincrement@num\trial@flush@seen@num +%<*trace> + \tr@ce{flush~ point~(\trial@flush@seen@num,~ + affects:~ \csname flush@classes@list@\trial@flush@seen@num\endcsname,~ + mincol:~ \csname flush@min@col@\trial@flush@seen@num\endcsname,~ + lastfloat:~ \csname flush@last@float@\trial@flush@seen@num\endcsname + )~ reached} +%</trace> +% \end{macrocode} +% We then remove the guard box from the output (which is at the end +% of box |\@cclv|. +% \begin{macrocode} + \remove@guard@box@from@cclv +% \end{macrocode} +% If the flush penalty moved to an earlier column than in the last +% trial we end the current column (by calling +% |\#1@column@or@finish|) and reinsert the penalty so that it will +% be seen again if we do the next column. +% \begin{macrocode} + \ifnum\csname flush@min@col@\trial@flush@seen@num\endcsname + > \curr@col@count +%<*trace> + \tr@ce{flush@min@col@\trial@flush@seen@num\space >~ + curr@col@count~ + (\csname flush@min@col@\trial@flush@seen@num\endcsname + \space >~ \the\curr@col@count)~ ->~ ending~ column} +%</trace> + \gdecrement@num\trial@flush@seen@num + \readd@guarded@penalty\output@flush@float@penalty + #2 + \else +% \end{macrocode} +% Otherwise the flush point is in an acceptable position which +% means we ignore it and carry on collecting material for the +% current column. This is done be putting everything back onto the +% MVL except the guard box and the penalty.\footnote{We lose a +% potential break point here (acceptable?) See comments in +% best@column@or!!} +% \begin{macrocode} +%<*trace> + \tr@ce{flush@min@col@\trial@flush@seen@num\space + <=~ curr@col@count~ + (\csname flush@min@col@\trial@flush@seen@num\endcsname + \space <=~ \the\curr@col@count)} +%</trace> +% \end{macrocode} +% What exactly happens here (beside the above) depends on the +% calling macro. +% \begin{macrocode} + #3 + \fi + \else +% \end{macrocode} +% If it was not a flush point we might have a here point to take +% care of. This is more or less like the code above. +% \begin{macrocode} + \ifnum\outputpenalty=-\output@here@float@penalty + \gincrement@num\trial@here@seen@num +%<*trace> + \tr@ce{here~ penalty~(\trial@here@seen@num)~ reached} +%</trace> + \remove@guard@box@from@cclv + \ifnum\csname here@min@col@\trial@here@seen@num\endcsname + > \curr@col@count +%<*trace> + \tr@ce{here@min@col@\trial@here@seen@num\space >~curr@col@count~ + (\csname here@min@col@\trial@here@seen@num\endcsname + \space >~ \the\curr@col@count)~ ->~ ending~ column} +%</trace> + \split@off@last@line + \gdecrement@num\trial@here@seen@num + \readd@guarded@penalty\output@here@float@penalty + #2 + \else + \@tempdima \pagegoal + \advance\@tempdima -\pagetotal + \ifdim \@tempdima < + \csname + here@required@space@\trial@here@seen@num + \endcsname \relax +%<*trace> + \tr@ce{here@required@space@\trial@here@seen@num\space >~ + \pagegoal-\pagetotal \space + (\csname here@required@space@\trial@here@seen@num\endcsname + \space >~ \the\pagegoal\space + -~ \the\pagetotal\space =~ + \the\@tempdima)~ + ->~ ending~ column} +%</trace> + \split@off@last@line + \gdecrement@num\trial@here@seen@num + \readd@guarded@penalty\output@here@float@penalty + #2 + \else +%<*trace> + \tr@ce{here@required@space@\trial@here@seen@num\space <=~ + \pagegoal-\pagetotal \space + (\csname here@required@space@\trial@here@seen@num\endcsname + \space <=~ \the\pagegoal\space + -~ \the\pagetotal\space =~ + \the\@tempdima)~ + ->~ accepting~ here~ point} +%</trace> + \@reinserts + \unvbox\@cclv + \@next\@currbox\@herelist{ +%<*trace> + \tr@ce{@currbox:~ \@currbox} +%</trace> + \expandafter\update@here@float@structure\the\toks\@currbox +% \end{macrocode} +% Different things need to be done depending on the type of the +% here point: +% \begin{macrocode} + \def\@tempa{mpar} + \ifx\@tempa\here@type + \typeset@a@marginpar + \else + \def\@tempa{rspace} + \ifx\@tempa\here@type + % do nothing + \else + #4 + \fi + \fi + } +% \end{macrocode} +% If there is no here object left the algorithm has screwed up +% (i.e., a ``this can't happen'' situation). +% \begin{macrocode} + \ERROR + \fi + \fi + \else +% \end{macrocode} +% If it is neither a flush nor a here point it might be a grid point: +% \begin{macrocode} + \ifnum\outputpenalty=-\output@grid@align@penalty + \align@collected@galley@and@restart +% \end{macrocode} +% So we now know that it wasn't one of our special points so this +% must have been a normal end of the galley: +% \begin{macrocode} + \else + #2 + \fi + \fi + \fi +%<*trace> + \@tracepop{#1@column@or} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\grab@column@or} +% Here is the output routine used during trials, an instantiation +% of |\some@column@or|. +% \begin{macrocode} +\def\grab@column@or{\some@column@or{grab} + \grab@column@or@finish + \grab@column@or@flushcheck + \check@and@typeset@a@here@float +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\grab@column@or@flushcheck} +% +% The |\grab@column@or@flushcheck| code checks for restrictions +% regarding the placement of the current float. It is called when +% we just have encountered a flush float penalty while grabbing the +% text for a column and now have to see which floats (if any) need +% to be positioned before that flush point. +% \begin{macrocode} +\def\grab@column@or@flushcheck{ +%<*trace> + \@tracepush{grab@column@or@flushcheck} +%</trace> +% \end{macrocode} +% If we are making a dry-run without floats then there is no need to +% do much, so we skip all testing that involves flush points and +% only do the cleanup actions at the end. +% \begin{macrocode} + \ifrun@with@floats + \expandafter\xin@\expandafter\this@class + \csname flush@classes@list@\trial@flush@seen@num\endcsname + \ifin@ +%<*trace> + \tr@ce{flush:~ class~ \this@class\space in~ + {\csname flush@classes@list@\trial@flush@seen@num\endcsname}} +%</trace> +% \end{macrocode} +% We store in |\count@| the float sequence number of the last float +% that would be affected by the current flush penalty. This value +% is then used in the tests below. +% \begin{macrocode} + \count@\csname flush@last@float@\trial@flush@seen@num\endcsname\relax +% \end{macrocode} +% +% If the current float number is higher than float number stored in +% |\flush@last@float@|\meta{num} with the flush penalty, we are +% dealing with a float whose call-out is after the flush penalty +% and thus we have no restriction. +% \begin{macrocode} + \ifnum\this@sequence@number>\count@ +%<*trace> + \tr@ce{???:\this@sequence@number>\the\count@} + \tr@ce{this~float~ past~flush~point} +%</trace> + \else +% \end{macrocode} +% Otherwise check if this float is placed in an acceptable position +% with respect to the current flush point. For this we run +% different code depending on the ``fuzziness'' of the flush point +% under check: +% \begin{macrocode} + \csname flush@fuzziness@\trial@flush@seen@num \endcsname + \fi +%<*trace> + \else + \tr@ce{flush:~ class~ \this@class\space not~ in~ + {\csname flush@classes@list@\trial@flush@seen@num\endcsname}} +%</trace> + \fi + \fi +% \end{macrocode} +% If we failed above we additionally record that the failure is +% due to violating restrictions for a flush point. +% \begin{macrocode} + \if@fail + \@flushfailtrue +% \end{macrocode} +% +% \begin{macrocode} + \global\setbox\@cclv\box\voidb@x + \global\setbox\footins\box\voidb@x +% \end{macrocode} +% We have to immediately abort the current trial otherwise a +% flush point following in the galley might be encountered and +% processed before we reach |\evaluate@results@of@trial|. That +% would result in updating the wrong data structure there (due to +% the fact that there it assumes that |\trial@flush@seen@num| +% refers to the flush point that is the reason for +% failure).\footnote{Implementation could be improved!} +% \begin{macrocode} + \global\curr@col@count\col@count + \grab@column@or@finish + \else +% \end{macrocode} +% If we haven't failed we might have to update the +% |\flush@min@col|\meta{num} for the current flush point in case it +% moved to a new column. +% \begin{macrocode} + \ifnum\csname flush@min@col@\trial@flush@seen@num\endcsname<\curr@col@count + \expandafter\xdef + \csname flush@min@col@\trial@flush@seen@num\endcsname + {\the\curr@col@count} +%<*trace> + \tr@ce{set~ flush@min@col@\trial@flush@seen@num:~ + \csname flush@min@col@\trial@flush@seen@num\endcsname} +%</trace> + \fi +% \end{macrocode} +% We have to return the collected footnotes first or else \TeX{} +% might decide that it is better to break before +% them.\footnote{Quite likely that this needs some refinement as it +% might mess up vertical spacing in other respects. Look out for +% other places where \texttt{\string\@reinserts} is used, if this +% needs fixing.} +% \begin{macrocode} + \@reinserts + \unvbox\@cclv +% \end{macrocode} +% What penalty to return???\footnote{FIX!!!} +% \begin{macrocode} +% \penalty\z@ % none i think now (in the current version) but this + % will change again + \fi +%<*trace> + \@tracepop{grab@column@or@flushcheck} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\flushcheck@page} +% \begin{macrocode} +\def\flushcheck@page { +%<*trace> + \tr@ce{OK:~flush~check~ (same~page)} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\flushcheck@spread} +% +% This is actually a dummy definition. There is more to do if we +% want to provide support for spreads!\footnote{Finish implementation} +% \begin{macrocode} +\def\flushcheck@spread { +%<*trace> + \tr@ce{OK:~flush~check~ (using~page~not~ spread)} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\flushcheck@strict} +% \begin{macrocode} +\def\flushcheck@strict { +%<*trace> + \@tracepush{flushcheck@strict} +%</trace> +% \end{macrocode} +% If strict flushing is required we look where the current float is +% being placed. If it +% is placed in a column which is earlier than the current column +% then it is definitely before the flush point and thus we are okay. +% \begin{macrocode} + \ifnum\this@area@col@number<\curr@col@count +%<*trace> + \tr@ce{OK:~flush~check~ + (\this@area@col@number<\the\curr@col@count,~\this@area)} +%</trace> + \else +% \end{macrocode} +% Otherwise we test if the float is placed into the current +% column. If this is the case it might be okay, but only if it is +% not placed into the bottom area. +% \begin{macrocode} + \ifnum\this@area@col@number=\curr@col@count +% \end{macrocode} +% To test for the bottom area(s) means looking at the first token +% in the area identifier. If it is |b| we are past the flush +% point.\footnote{It might be an interesting extension to allow +% relaxing the flush situation to allow the floats to appear +% anywhere on the current column (on which the flush point ends up), +% or even allowing that it only has to appear on the current page +% or page spread.} +% \begin{macrocode} + \if b \this@area@type + \@failtrue +%<*progress> + \progress@failed{area~ below~ flush~ point~ + (\this@area@col@number=\the\curr@col@count,~\this@area)} +%</progress> +%<*trace> + \tr@ce{Fail:~flush~check~ + (\this@area@col@number=\the\curr@col@count,~\this@area)} +% \end{macrocode} +% Otherwise the float was placed into an area that is still before +% the flush point. +% \begin{macrocode} + \else + \tr@ce{OK:~flush~check~ + (\this@area@col@number=\the\curr@col@count,~\this@area)} +%</trace> + \fi +% \end{macrocode} +% If the float was neither placed before nor into the current +% column we have to conclude that it was placed into a later column +% which means it was placed after the flush point --- thus we fail. +% \begin{macrocode} + \else + \@failtrue +%<*progress> + \progress@failed{area~ after~ flush~ point~ + (\this@area@col@number>\the\curr@col@count,~\this@area)} +%</progress> +%<*trace> + \tr@ce{Fail:~flush~check~ + (\this@area@col@number>\the\curr@col@count,~\this@area)} +%</trace> + \fi + \fi +%<*trace> + \@tracepop{flushcheck@strict} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\flushcheck@column} +% \begin{macrocode} +\def\flushcheck@column { + \ifnum\this@area@col@number>\curr@col@count + \@failtrue +%<*progress> + \progress@failed{area~ after~ flush~ point~ column~ + (\this@area@col@number>\the\curr@col@count,~\this@area)} +%</progress> +%<*trace> + \tr@ce{Fail:~flush~check~ + (\this@area@col@number>\the\curr@col@count,~\this@area)} + \else + \tr@ce{OK:~flush~check~ + (\this@area@col@number<=\the\curr@col@count,~\this@area)} +%</trace> + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\grab@column@or@finish} +% \begin{macrocode} +\def\grab@column@or@finish{ +%<*trace> + \@tracepush{grab@column@or@finish} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \mark@update@structure +% \end{macrocode} +% +% \begin{macrocode} + \deal@with@footins@action +% \end{macrocode} +% +% First check if there are some special constraints that should be +% met (this is, for example, used to check if there are both bottom +% floats and footnotes). If the constraints are not met don't +% bother to check the callout/float constraints. +% \begin{macrocode} + \if@fail\else + \ifrun@with@floats + \check@some@constraints + \fi + \fi + \if@fail\else +% \end{macrocode} +% For each float sequence class, call |\check@callout@constraints| +% this will be set via a call to a pagesetup template to do an +% appropriate check on the float placement relative to float +% call-out. +% \begin{macrocode} + \ifrun@with@floats + \let\@elt\check@callout@constraints + \float@classes@list + \fi + \fi +% \end{macrocode} +% +% Throw the text away (it will be reset later if this trial is +% in fact chosen). +% \begin{macrocode} + \global\setbox\@cclv\box\voidb@x + \global\setbox\footins\box\voidb@x +% \end{macrocode} +% After the last column we evaluate the results of the trial (and +% if the result looks ok remember it as a candidate for the final +% solution). We then switch to the `clean up' OR which will +% collect up the main vertical list as far as the special penalty +% marking the end of the collection pass, to clear the MVL for the +% next trial. If this isn't the last column, set up the next +% column. +% \begin{macrocode} + \ifnum\curr@col@count=\col@count + \evaluate@results@of@trial + \setup@cleanup@or + \else + \grab@column@loop + \fi +%<*trace> + \@tracepop{grab@column@or@finish} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\handle@case@of@premature@ending} +% Next |\ifnum| is a fix that needs rethinking: what is the best +% approach if we hit the penalty which denotes the end of the +% collected galley too early, e.g., in the middle of a trial using +% |\grab@column@or| or when producing the final columns with +% |\best@column@or|? Current solution gets the stuff out, but is it +% probably not the best solution. +% correct? +% \begin{macrocode} +\def\handle@case@of@premature@ending{ + \ifnum\outputpenalty=-\output@collect@penalty + \remove@guard@box@from@cclv + \readd@guarded@penalty\output@collect@penalty + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\check@some@constraints} +% By default there are no additional constraints to check for. +% \begin{macrocode} +\let\check@some@constraints\relax +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\evaluate@results@of@trial} +% +% The purpose of |\evaluate@results@of@trial| is to determine if +% the current trial is a potential candiate for the final solution +% and if so store it away. We can determine if the trial failed by +% looking at the switch |@fail|. +% \begin{macrocode} +\def\evaluate@results@of@trial{ +%<*trace> + \@tracepush{evaluate@results@of@trial} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \ifrun@with@floats + \ifx\try@this@area\std@try@this@area + \count@\trial@here@seen@num\relax + \advance\count@\page@float@count + \ifnum \pagesetup@max@float@num < \count@ +%<*trace> + \tr@ce{Failed:~ area~ +~ here~ floats~ exceed~ max~ floats} +%</trace> +%<*progress> + \progress@failed{area~ +~ here~ floats~ exceed~ max~ floats} +%</progress> + \@failtrue + \fi + \fi + \fi +% \end{macrocode} +% +% \begin{macrocode} + \if@fail +%<*trace> + \tr@ce{fail:~true} +%</trace> +% \end{macrocode} +% If the trial has failed we have to distinguish two cases: +% \begin{itemize} +% \item +% There has been a request for flushing out floats up to a +% certain float somewhere +% and the current float belongs to the list of floats to flush. +% \item +% There has been no such request. +% \end{itemize} +% +% If there have been flush points we need to restore their +% |min@col| values since we might have updated them. +% \begin{macrocode} + \if@flushseen + \count@\z@ + \@whilenum \flush@seq@num>\count@ \do + { \advance\count@\@ne + \global\expandafter\let + \csname flush@min@col@\the\count@ \expandafter\endcsname + \csname saved@flush@min@col@\the\count@\endcsname +%<*trace> + \tr@ce{flush@min@col@\the\count@ \space <-~ + \csname flush@min@col@\the\count@\endcsname \space + (restore) } +%</trace> + } + \fi + + \if@flushfail +%<*trace> + \tr@ce{flushfail:~true} +%</trace> +% \end{macrocode} +% If we have failed and |\try@this@area| is already the ``relaxed'' +% version we have to artificially move the offending flush point to +% the next column and hope that this way we get ourselves some new +% options (worst case is that eventually the flush point is removed +% from the page in which case we can as a last resort defer the +% float). +% \begin{macrocode} + \ifx\try@this@area\relaxed@try@this@area + + \expandafter\gincrement@num + \csname flush@min@col@\trial@flush@seen@num\endcsname +%<*trace> + \tr@ce{flush@min@col@\trial@flush@seen@num~ <-~ + \csname flush@min@col@\trial@flush@seen@num\endcsname} +%</trace> +%<*progress> + \progress@failed{flush~ point~ \trial@flush@seen@num\space + moved~ to~ column~ + \csname flush@min@col@\trial@flush@seen@num\endcsname} +%</progress> + \else + + \ifx\saved@this@open@areas\@empty +%<*debug> + \tr@ce{saved@this@open@areas:~empty ????????} +%</debug> + \ERROR + \else + \global\let\this@open@areas\saved@this@open@areas +%<*trace> + \tr@ce{~this@open@areas~ <-~ \this@open@areas \space (reopen)} +%</trace> + \fi + \relax@float@placement@conditions + \fi + \else +%<*trace> + \tr@ce{flushfail:~false} +%</trace> + \xdef\this@open@areas{\expandafter\@gobblethree\this@open@areas} + \fi + +%<*trace> + \tr@ce{open:~\this@open@areas} + + \tr@ce{restore:~last~allocated:~\saved@fl@} +%</trace> +% \end{macrocode} +% To restore the previous state we have to recalculate the target +% |fl@| column. +% \begin{macrocode} + \calculate@target@fl@column + \global\expandafter\let + \csname fl@\the\count@ @\this@class\endcsname + \saved@fl@ +%<*trace> + \tr@ce{~fl@\the\count@ @\this@class\space <-~ + \saved@fl@ \space (restored)} +%</trace> +% \end{macrocode} +% And if we tried a top area we also have to restored the +% corresponding |tfl@| macro. +% \begin{macrocode} + \if t\this@area@type + \global\expandafter\let + \csname tfl@\the\count@ @\this@class\endcsname + \saved@tfl@ +%<*trace> + \tr@ce{~tfl@\the\count@ @\this@class\space <-~ + \saved@tfl@ \space (restored)} +%</trace> + \fi +% \end{macrocode} +% And we better don't forget to restore the heights.\footnote{This +% is most likely buggy: I seem to restore all column values but i think +% i don't save all of them! FIX!!!!} +% \begin{macrocode} + \update@this@area@columns + { +%<*trace> + \tr@ce{restore:~saved@col@ht@ \the\count@:~ + \csname saved@col@ht@ \the\count@\endcsname} +%</trace> + \global\csname col@ht@ \the\count@\endcsname + \csname saved@col@ht@ \the\count@\endcsname\relax + \global\expandafter\let + \csname col@ \this@area@type @delta@ \the\count@ + \expandafter \endcsname + \csname saved@col@ \this@area@type @delta@ \the\count@ \endcsname +%<*trace> + \tr@ce{GRID (delta):~ column~\the\count@\this@area@type:~ + \csname saved@col@ \this@area@type @delta@ \the\count@ + \endcsname\space (restore) } +%</trace> + } + \else +%<*trace> + \tr@ce{fail:~false} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} +%<*progress> + \let\progress@inform@later\@empty +%</progress> +% \end{macrocode} +% If this trial is valid and we haven't seen all flush penalties +% again we must have pushed them to the next page. We record +% this fact by setting |flush@min@col@...| to |\maxdimen|. +% \begin{macrocode} + \if@flushseen + \count@\flush@seq@num\relax + \loop + \ifnum \trial@flush@seen@num < \count@ + \global\@namedef{flush@min@col@\the\count@}{\maxdimen} +%<*trace> + \tr@ce{flush@min@col@\the\count@\space <-~ maxdimen} +%</trace> + \advance\count@\m@ne + \repeat +% \end{macrocode} +% If there has been a flush point (ie if |\trial@flush@seen@num| und +% thus |\count@| is greater than 0) we test whether or not the +% float recently placed was the last one affected by the last flush +% point on the current page and if so tighten the float placement +% setting again.\footnote{correct logic?} +% \begin{macrocode} +%<*progress> + \let\progress@inform@later\@empty +%</progress> + \ifrun@with@floats + \ifnum \count@ > \z@ + \ifnum \csname flush@last@float@\trial@flush@seen@num\endcsname = + \this@sequence@number \relax +%<*trace> + \tr@ce{flush:~ last~float~affected~ by~ flush~ point~ + \trial@flush@seen@num\space placed~ ->~ + use~ partly~ normal~ placement~ conditions~ again} +%</trace> +%<*progress> + \def\progress@inform@later{ + \progress@nl{->~ past~ flush~ point:~ -->~ + tighten~ conditions~ again} + \progress@nl{} + } +%</progress> + \partly@tighten@float@placement@conditions + \fi + \fi + \fi +% \end{macrocode} +% Having placed a float we need to update |\flush@classes@list@max| to +% reflect which float types are affected by the flush points +% currently on the page as this might be needed when trying to +% place or rather defer the next float. +% +% So we loop and concatenate all |\flush@classes@list@|\meta{num} that +% belong to flush points on the current page. This might result in +% the list containing types several times but for the test we need +% to do this doesn't make any difference (and it is far faster than +% unifying the list). +% \begin{macrocode} + \count@\z@ + \global\let\flush@classes@list@max\@empty + \loop + \ifnum \trial@flush@seen@num > \count@ + \advance\count@\@ne + \xdef\flush@classes@list@max{ + \flush@classes@list@max; + \csname flush@classes@list@\the\count@\endcsname + } +%<*trace> + \tr@ce{flush@classes@list@max~ <-~ \flush@classes@list@max} +%</trace> + \repeat + \fi +% \end{macrocode} +% +% With this algorithm a trial which passed so far is always +% considered to be better than previous trials (meaning more floats +% on the page are better). So we always update the best trial data +% (unless this was the run without adding floats in which case we +% only change the |run@with@floats| switch. +% \begin{macrocode} + \ifrun@with@floats + \update@best@trial +%<*progress> + \progress@inform@later +%</progress> + \else + \run@with@floatstrue + \fi + \fi +%<*trace> + \@tracepop{evaluate@results@of@trial} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{Best Trial Data} +% +% +% \begin{macro}{\best@trial} +% \begin{macrocode} +\let\best@trial\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\update@best@trial} +% Not all of this belongs into this macro!\footnote{redistribute} +% \begin{macrocode} +\def\update@best@trial{ +%<*trace> + \@tracepush{update@best@trial} +%</trace> +%<*progress> + \progress@nl{->~ accepted} +%</progress> + \global\let\best@trial\@empty + \forall@columns{ + \expandafter + \g@addto@macro\expandafter\best@trial\expandafter + { + \expandafter + \global + \csname col@ht@ \the\curr@col@count\expandafter\endcsname + \the\csname col@ht@ \the\curr@col@count\endcsname + } + } +% \end{macrocode} +% +% Frank says this needs to be documented (the rest of the code is self evident) +% |\this@float@box| is |\let| to |\@currbox| which is defed to a chardefed +% token from newinsert. so this is OK. honest. +% \begin{macrocode} + \expandafter\@cons\csname area@\this@area\expandafter\endcsname + \this@float@box +% \end{macrocode} +% +% \begin{macrocode} +%<*trace> + \tr@ce{this@page@closed~ \this@page@closed\space +~ + "\csname pagesetup@\this@area @all@close\endcsname"} + \tr@ce{this@closed@areas~ \this@closed@areas\space +~ + "\csname pagesetup@\this@area @class@close\endcsname"} +%</trace> + \xdef\this@page@closed{\this@page@closed, + \csname pagesetup@\this@area @all@close\endcsname} + \xdef\this@closed@areas{\this@closed@areas, + \csname pagesetup@\this@area @class@close\endcsname} +% \end{macrocode} +% +% \begin{macrocode} + \global\expandafter\let\csname open@\this@class + @areas\endcsname % FMi tmp + \this@open@areas + \global\expandafter\let\csname closed@\this@class + @areas\endcsname % FMi tmp + \this@closed@areas +% \end{macrocode} +% moving the captioned float to the main float box is put into a +% separate macro so that we can suppress this in cases where we +% potentially want to revert to a previous stage.\footnote{FIX} +% \begin{macrocode} +%<*obsolete> + \add@caption@to@float@box +%</obsolete> +% \end{macrocode} +% +% \begin{macrocode} + \global\advance\page@float@count\@ne + \global\advance\csname \this@area @float@count\endcsname\@ne +% \end{macrocode} +% +% Since the trial was successful, we have to update the the macros +% that hold the number of top or bottom floats we have seen so far +% in each column.\footnote{Code for this is similar to the one in +% construct@and@test@col@ht and elsewhere; perhaps there should be +% a subroutine for it!} +% \begin{macrocode} + \update@this@area@columns + { + \expandafter + \gincrement@num + \csname col@ \this@area@type + @floats@ \the\count@ @number\endcsname +%<*trace> + \tr@ce{col@ \this@area@type + @floats@ \the\count@ @number <-~ + \csname col@ \this@area@type + @floats@ \the\count@ @number\endcsname} +%</trace> + } +% \end{macrocode} +% +% \begin{macrocode} +%<*trace> + \tr@ce{\meaning\best@trial} + \tr@ce{area:~\this@area\space\csname area@\this@area\endcsname} + \@tracepop{update@best@trial} +%</trace> +} +% \end{macrocode} +% \end{macro} +% + +% \begin{macro}{\add@caption@to@float@box} +% This is a hook really to be able to prevent moving the caption +% back into |\this@float@box| (by making this macro |\relax| and +% this is what happens later on in xo-final). Yes we know the +% coding here needs changing!\footnote{David FIX!!!} +% \begin{macrocode} +%<*obsolete> +\def\add@caption@to@float@box{ + \global\setbox\this@float@box\box\this@captioned@float +} +%</obsolete> +% \end{macrocode} +% \end{macro} +% +% +% \newpage +% +% \subsection{Best Column Output Routine} +% +% \begin{description} +% \item[Entry:] |\setup@best@column@or| +% \item[Exit:] |\setup@collection@or| +% \item[Prereq:] +% \item[Description:] +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \setup@best@column@or +% | +% New OR: \best@column@or +% | +% V +% \best@column@loop <------- +% | +% (when entering OR...) +% | +% <end of collection reached?> +% | | +% yes no +% | | +% | <col break requested?> +% | | | +% | yes no +% | | | +% | | <flush point encountered?> +% | | | | +% | | yes no +% | | | | +% | | <flush point <here point encountered?> +% | | too early?> | | +% | | | | yes no +% | | yes no | | +% | | | | ? ? +% | | | (ignore break) +% | | | | +% | | | | +% | | | | +% | | | | +% | | | | +% | | | | +% | | | | +% | | | | +% | | | | +% (end column now) <------- | +% | | +% V | +% <all cols produced?> | +% | | V +% yes no--------------------> (reenter \best@column@loop) +% | +% (produce final page) +% | +% V +% \initialise@next@page +% | +% V +% (try to make float pages) +% | +% V +% \setup@collection@or +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% +% After the best trial is chosen the `best@column@or' output routines +% are executed. Structurally this is similar to the grab column output +% routines used during the trials, but this time information +% about the float placements is recorded in the float area lists +% and also optionally in float placement control files. +% +% \begin{macro}{\setup@best@column@or} +% This is the initialisation code for producing the final best set +% of columns (via the @best@column@or output routine). +% \begin{macrocode} +\def\setup@best@column@or{ +%<*trace> + \@tracepush{setup@best@column@or} +% Elsewhere now: +% \tr@ce{reinsert~penalty:~ \saved@outputpenalty\space (unless~ 10000)} +%</trace> +% \penalty +% \ifnum\saved@outputpenalty=\@M +% \z@ +% \else +% \saved@outputpenalty\relax +% \fi + \global\curr@col@count\z@ + \gdef\trial@flush@seen@num{0} + \gdef\trial@here@seen@num{0} + \perhaps@write@placements@to@fpl@file + \best@trial +% \end{macrocode} +% +% \begin{macrocode} + \initialise@footins@action +% \end{macrocode} +% +% \begin{macrocode} + \global\output{\best@column@or} + \best@column@loop +%<*trace> + \@tracepop{setup@best@column@or} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\best@column@loop} +% \begin{macrocode} +\def\best@column@loop{ +%<*trace> + \@tracepush{best@column@loop} +%</trace> + \global\advance\curr@col@count\@ne + \global\vsize\csname col@ht@ \the\curr@col@count\endcsname +%<*trace> + \tr@ce{vsize~ <-~ \the\vsize } + \@tracepop{best@column@loop} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\best@column@or} +% Here is the output routine used when preparing the final columns, +% an instantiation of |\some@column@or|. In contrast to the version +% used for |\grab@column@or| it doesn't do the tests. +% \begin{macrocode} +\def\best@column@or{\some@column@or{best} + \best@column@or@finish + { + \@reinserts + \unvbox\@cclv +% \end{macrocode} +% Next line not okay! we need to add a penalty here but which one? +% Or we need a different mechanism using either |\holdinginserts| +% or a partial box line in collection OR.\footnote{FIX!!! there is +% also another place like this!} +% \begin{macrocode} +% \penalty\z@ %FMi? + } + { + \perhaps@write@to@fpl@file{ + \@spaces Area:~hhh^^J + \expandafter\perhaps@write@placements@to@fpl@file@aux\the\toks\@currbox} + \typeset@a@here@float + } +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \begin{macro}{\best@column@or@finish} +% +% \begin{macrocode} +\def\best@column@or@finish{ +%<*trace> + \@tracepush{best@column@or@finish} +%</trace> + \mark@update@structure +% \end{macrocode} +% +% \begin{macrocode} + \deal@with@footins@action +% \end{macrocode} +% +% save all marks here\footnote{not done yet!} +% +% add floats and footnotes etc to collected column +% +% \begin{macrocode} + \produce@final@column +% \end{macrocode} +% +% \begin{macrocode} + \ifnum\curr@col@count=\col@count + \produce@final@page + \initialise@next@page + \try@float@pages + \place@deferred@floats + \setup@collection@or +%{\showoutput\showlists} + \else + \best@column@loop + \fi +%<*trace> + \@tracepop{best@column@or@finish} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\initialise@next@page} +% Initialises the column heights to text height. Clear the float +% area lists, zero holdinginserts to allow footnote texts to arrive +% in the insertion box. +% \begin{macrocode} +\def\initialise@next@page{ +%<*trace> + \@tracepush{initialise@next@page} +%</trace> +% +% \end{macrocode} +% +% \begin{macrocode} + \initialise@column@data +% \end{macrocode} +% +% \begin{macrocode} + \initialise@areas +% \end{macrocode} +% +% \begin{macrocode} + \global\page@float@count\z@ +% \end{macrocode} +% +% \begin{macrocode} + \initialise@flush@data +% \end{macrocode} +% +% \begin{macrocode} + \initialise@here@data +% \end{macrocode} +% +% \begin{macrocode} + \initialise@footins@action +% \end{macrocode} +% +% Nothing is closed when we are at the start of a page. +% \begin{macrocode} + \global\let\this@page@closed\@empty +% \end{macrocode} +% +% \begin{macrocode} + \let\@elt\initialise@float@class + \float@classes@list + \let\@elt\relax +% +%\showfloatlists +%\show\area@ddd\show\@activelist +% for safety + \global\let\this@float@box\@undefined +%<*trace> + \@tracepop{initialise@next@page} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\handle@case@of@forced@pagebreak} +% This is related to |\handle@case@of@premature@ending| but we have +% to return the penalty only if we haven't reached the last column. +% If we don't do this we would start collecting material in the +% middle of final page generation! +% \begin{macrocode} +\def \handle@case@of@forced@pagebreak{ + \ifnum\curr@col@count<\col@count + \ifnum\outputpenalty=-\@M + \@emptycol + \fi + \fi + + \ifnum\outputpenalty=-\output@balance@penalty +%<*trace> + \tr@ce{BALANCE:~ end~ point~ seen~ again} +%</trace> + \remove@guard@box@from@cclv + \ifnum\curr@col@count<\col@count + \@emptycol + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% \newpage +% +% \subsection{Cleanup Output Routine} +% +% \begin{description} +% \item[Entry:] |\setup@cleanup@or| +% \item[Exit:] |\float@placement@loop| +% \item[Prereq:] +% \item[Description:] +% Responsible for discarding unused text still on Main Vertical +% List After the end of a trial. It eats everything until it sees +% the special penalty marking the end of the last collection output +% routine. This output routine may need to be called several times +% in succession due to forced penalties in the galley. +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \setup@cleanup@or +% | +% V +% New OR: \cleanup@or +% | +% V +% <special outputpenalty reached?> --> \float@placement@loop +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% +% \begin{macro}{\setup@cleanup@or} +% \begin{macrocode} +\def\setup@cleanup@or{ + \global\vsize\maxdimen + \global\output{\cleanup@or} + } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\cleanup@or} +% In the actual output routine we grab text and throw it away until +% we see the special output penalty. Then we prepare for the trials +% to place the floats properly. +% \begin{macrocode} +\def\cleanup@or{ +%<*trace> + \@tracepush{cleanup@or} + \tr@ce{output~pen:~ \the\outputpenalty} +%</trace> +% \end{macrocode} +% Throw everything away \ldots +% \begin{macrocode} + \global\setbox\@cclv\box\voidb@x + \global\setbox\footins\box\voidb@x +% \end{macrocode} +% \ldots\ until we see the special output penalty again. +% \begin{macrocode} + \ifnum\outputpenalty=-\output@collect@penalty + \float@placement@loop + \fi +%<*trace> + \@tracepop{cleanup@or} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \newpage +% +% \subsection{Making float pages} +% +% +% \begin{description} +% \item[Entry:] |\try@float@pages| +% \item[Exit:] --- (this happens within the OR)\\ +% On exit |\area@ddd| will be empty and the floats not being put +% onto float pages are moved to |\@activelist| (those that have +% their call outs on previous pages) and |\@mvllist| (those that +% have their call outs still on the MVL). +% \item[Prereq:] |\area@ddd| contains the float to work on; all other +% areas are empty. +% \item[Description:] +% \item[Flow:] +%\begin{footnotesize} +%\begin{verbatim} +% \try@float@pages +% | +% V +% <\area@ddd has floats?> +% | | +% ----no yes +% | | +% | V +% | (split \area@ddd into \@activelist and \@mvllist; +% | setup trial conditions) +% | | +% | V +% | \try@float@page <------------- +% | | | +% | <float page produced?> | +% | | | | +% | no yes | +% | | | | +% | | (output page) | +% | | | | +% | | (move new \area@ddd | +% | | to \@activelist) | +% | | | | +% | | ------------------ +% | | +% | | +% | (restore float conditions before last trial) +% | | +% | (restore trial condition to normal) +% | | +% ------------->| +% | +% V +%\end{verbatim} +%\end{footnotesize} +% \end{description} +% +% +% +% \begin{macro}{\try@float@pages} +% +% \begin{macrocode} +\def\try@float@pages { +%<*trace> + \@tracepush{try@float@pages} +%</trace> + \ifx\area@ddd\@empty +%<*trace> + \tr@ce{no~ deferred~ floats} +%</trace> + \else + \global\let\@activelist@empty@action\relax + \global\let\pretests@success@action\floatpage@pretests@success@action +% \end{macrocode} +% this is only a tmp: we just use |\relaxed@try@this@area| but of +% course there should be different rules for float pages (and +% different float areas and \ldots) +% \begin{macrocode} + \global\let\try@this@area\relaxed@try@this@area +% \end{macrocode} +% +% First thing to do is to split the list of deferred floats into +% those that have ther callouts already typeset (on previous pages) +% and those that we have only seen because we looked a bit +% ahead. For making float pages we can only use the former. +% \begin{macrocode} + \let\@elt\split@defer@list + \area@ddd + \let\@elt\relax + \global\let\area@ddd\@empty +% \end{macrocode} +% Now we loop until we fail to make float pages. The actual work is +% done in the macro |\try@float@page|. +% \begin{macrocode} + \@floatpagetrue + \loop + \if@floatpage + \begingroup % no nesting of \loop without grouping ... +% \end{macrocode} +% Next line prevents adding the caption to the float box. Of course +% the float page does come out even worse this way, but we don't +% get multiple captions if float page generation +% fails.\footnote{FIX by redesigning caption handling!} +% \begin{macrocode} +%<*obsolete> + \let\add@caption@to@float@box\relax %tmp!! +%</obsolete> +% \end{macrocode} +% +% A bit statistics: how many floats do we have on the +% |\@activelist|? +% \begin{macrocode} +%<*progress> + \def\@elt{\global\advance\trial@count\@ne\@gobble} + \@activelist + \let\@elt\relax + \progress@nl{} + \progress@separator + \progress@nl{STATS:~ floats~ waiting~ =~ \the\trial@count + \space on~ page~ \the\absolute@page@number\space (float~ page)} + \progress@separator + \global\trial@count\z@ +%</progress> +% \end{macrocode} +% \begin{macrocode} + \try@float@page + \endgroup + \repeat +% \end{macrocode} +% Once we are finished we have to return to normal trial +% conditions, so\ldots +% \begin{macrocode} + \global\let\try@this@area\std@try@this@area + \fi +%<*trace> + \@tracepop{try@float@pages} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\try@float@page} +% This macro tries to build a single float page from the floats in +% |\@activelist|. If it fails it (tries to) restores the state of +% the floats. If it succeeds it will output a float page and returns. +% \begin{macrocode} +\def\try@float@page { +%<*trace> + \@tracepush{try@float@page} +%</trace> +% \end{macrocode} +% Save the current state in case of failure then run the float +% placement loop (setup for this loop should have happened +% earlier). +% \begin{macrocode} + \save@current@float@state + \trial@inner@loop +% +%\typeout{float.list.after.trial} +%\showfloatlists +% +% \end{macrocode} +% Loop through all ``text columns'' and add up their heights. This +% is again only done to have some sort of measure for float pages +% and should be removed once some real code gets into this part. +% \begin{macrocode} + \dimen@\z@ + \forall@columns{ +%<*trace> + \tr@ce{\ht\the\curr@col@count=\the \csname + col@ht@ \the\curr@col@count \endcsname} +%</trace> + \advance\dimen@ \csname + col@ht@ \the\curr@col@count \endcsname + } +% \end{macrocode} +% +% If the sum of all white space is more than 300pt :-) +% \begin{macrocode} + \ifdim \dimen@ > 300pt \relax +% \end{macrocode} +% we fail +% \begin{macrocode} + \@floatpagefalse +%<*trace> + \tr@ce{float~page~failed} +%</trace> +%<*progress> + \progress@failed{no~ float~ page~ made} + \progress@nl{} +%</progress> +% \end{macrocode} +% Return to the previous state (and as can be seen by using +% |\initialise@next@page|) this needs some work; the latter might +% in fact do too much like calling +% |\initialise@flush@num|!\footnote{FIX} +% \begin{macrocode} + \saved@float@state +% \end{macrocode} +% To avoid having |\initialise@flush@num| do anything harmful we +% set |\trial@flush@seen@num| to zero at this point.\footnote{This +% needs fixing properly!} And the same is necessary for +% |\initialise@here@num|. +% \begin{macrocode} + \gdef\trial@flush@seen@num{0} + \gdef\trial@here@seen@num{0} + \initialise@next@page + \else +% \end{macrocode} +% Otherwise we claim we have a good float page. +% \begin{macrocode} +%<*trace> + \tr@ce{float~page~succeeded} + \tr@ce{We~ better~ output~ something~ now~ ...} +%</trace> +%<*progress> + \progress@nl{succeeded} + \progress@nl{} +%</progress> +% \end{macrocode} +% producing this page is rubbish as well but it can't be written +% before we have parameters and rules for making float pages. +% \begin{macrocode} + \forall@columns{ + \global\setbox\csname col@box@\the\curr@col@count\endcsname + \vbox to \csname col@ht@ \the\curr@col@count\endcsname{} + \produce@final@column + } + \perhaps@write@placements@to@fpl@file + \produce@final@page + \initialise@next@page +% \end{macrocode} +% But the final lines are for real: if we did succeed we need to +% provide a new |\@activelist| for the next potential float page. +% It should be the floats we deferred while trying to make the +% current float page followed by the floats that are still on the +% active list (i.e., those we haven't even tried for the current +% page). +% \begin{macrocode} + \xdef\@activelist{\area@ddd\@activelist} + \global\let\area@ddd\@empty + \fi +% +%\typeout{float.list.after.shipout.float.page.or.fail} +%\showfloatlists +% +%<*trace> + \@tracepop{try@float@page} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\if@floatpage} +% \begin{macro}{\@floatpagefalse} +% \begin{macro}{\@floatpagetrue} +% Switch which is set to true while we are in the process of making +% float pages and haven't failed. +% \begin{macrocode} +\newif\if@floatpage +\def\@floatpagefalse{\global\let\if@floatpage\iffalse} +\def\@floatpagetrue{\global\let\if@floatpage\iftrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\save@current@float@state} +% +% Save the current state of affairs concerning +% floats\footnote{Needs more work, there are now other data +% structures that should be saved if this is every going to be of +% much use. (its current usage actually could be achieved with +% simpler means). FIX or fold!}. In case of failure return to +% this state by executing |\saved@float@state|. +% \begin{macrocode} +\def\save@current@float@state { +%<*trace> + \@tracepush{save@current@float@state} +%</trace> + \xdef\saved@float@state{\gdef\noexpand\@activelist{\@activelist}} + \forall@columns { + \expandafter + \g@addto@macro + \expandafter \saved@float@state + \expandafter { \expandafter \global + \csname col@ht@ \the\curr@col@count\expandafter\endcsname + \the \csname col@ht@ \the\curr@col@count\endcsname +% \end{macrocode} +% No final |\relax| needed since this is followed by area data. And +% if there are no areas we wouldn't call this code, would we? +% \begin{macrocode} + } + } +% \end{macrocode} +% Save current state of all used float areas by looping though them. +% \begin{macrocode} + \expandafter\save@area@info\used@areas ddd\relax\relax\relax +%<*trace> + \tr@ce{saved:~ \meaning\saved@float@state} + \@tracepop{save@current@float@state} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\save@area@info} +% Save information about area and recourse. +% \begin{macrocode} +\def\save@area@info#1#2#3{ + \ifx#1\relax + \else + \edef\@tempa { + \global\csname #1#2#3@float@count\endcsname + \the\csname #1#2#3@float@count\endcsname +% \end{macrocode} +% No |\relax| needed since followed by a |\gdef|. +% \begin{macrocode} + \gdef \expandafter\noexpand \csname area@#1#2#3\endcsname + {\csname area@#1#2#3\endcsname} + } + \expandafter + \g@addto@macro + \expandafter \saved@float@state + \expandafter { \@tempa } + + \expandafter\save@area@info + \fi} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\saved@float@state} +% To return to the saved float state execute |\saved@float@state|. +% \begin{macrocode} +\let\saved@float@state\@empty +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\split@defer@list} +% +% Split |\area@ddd| list, moving those floats whose callouts have +% been typeset to |\@activelist| for consideration for (one day) +% float pages, and for allocating to text page float areas. +% +% Floats whose callouts are still on MVL are placed on |\@mvllist|. +% \begin{macrocode} +\def\split@defer@list #1 { + \def\@currbox{#1} + \expandafter\extract@this@float@actual@structure\the\toks #1 +%<*trace> + \tr@ce { #1:~\LastMark{\this@class}~ ???~\this@sequence@number } +%</trace> + \ifnum 0\LastMark{\this@class} < \this@sequence@number +%<*trace> + \tr@ce {#1:~ not~ really~ defered } +%</trace> + \@cons \@mvllist #1 + \else +%<*trace> + \tr@ce {#1:~ callout~ has~ been~ typeset} +%</trace> + \@cons \@activelist #1 + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{Preassign deferred floats} +% +% +% +% \begin{macro}{\place@deferred@floats} +% +% The |\place@deferred@floats| is supposed to distribute from +% previous pages (i.e., from the top of |\area@ddd| or more exactly +% those currently on the |\@activelist| since the |\area@ddd| was +% already split when trying to build float pages) into the areas +% of the page to be build. After all we know that for those floats +% the call outs are on previous pages so testing for them +% is unnecessary and we could save time by bypassing this stuff. +% +% On the other hand if we have flush points in the upcoming text +% all our placements might be wrong, so perhaps this doesn't really +% save so much time after all and the extra complication might not +% be worth the effort. +% +% Perhaps a compromise is to make a first column grab without any +% floats to see if we end up with a flush point (not implemented). +% +% So if we don't do this then the only thing we need to do at this +% point is to move the floats from the |\@mvllist| to the end of +% the |\@activelist|. +% \begin{macrocode} +\def\place@deferred@floats { +%<*trace> + \@tracepush{place@deferred@floats} +%</trace> + \xdef\@activelist{\@activelist\@mvllist} + \global\let\@mvllist\@empty +%\showfloatlists +%<*trace> + \@tracepop{place@deferred@floats} +%</trace> +} +% \end{macrocode} +% +% +% Here is an alternate definition which does the preassigning but +% it would need to be extended by checking for flush points or by a +% flag that ensures that if we later encounter a flush point that +% we know we could backtrack if necessary (e.g., the preassignment +% might have already deferred some floats past the flush +% point).\footnote{Extend, fix, or get rid of.} +% \begin{macrocode} +\iffalse % we don't do it right now +\def\place@deferred@floats { +%<*trace> + \@tracepush{place@deferred@floats} +%</trace> +%\showfloatlists +% \let\@elt\split@defer@list +% \area@ddd +% \let\@elt\relax +% \global\let\area@ddd\@empty + \global\let\@activelist@empty@action\relax + \global\let\pretests@success@action\floatpage@pretests@success@action +\showfloatlists + \trial@inner@loop + \xdef\@activelist{\area@ddd\@mvllist} + \global\let\area@ddd\@empty + \global\let\@mvllist\@empty +%\showfloatlists +%<*trace> + \@tracepop{place@deferred@floats} +%</trace> +} +\fi +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\floatpage@pretests@success@action} +% Version of |\pretests@success@action| for use in initial phase +% when previously deferred floats are being allocated to float areas. +% \begin{macrocode} +\def\floatpage@pretests@success@action{ +%<*trace> + \@tracepush{floatpage@pretests@success@action} +%</trace> + \update@best@trial + \trial@inner@loop +%<*trace> + \@tracepop{floatpage@pretests@success@action} +%</trace> + } +% \end{macrocode} +% \end{macro} +% +% +% +% \newpage +% +% \subsection{Support for Balancing} +% +% Code in this section (and related code in other sections) is not +% used at the moment and will most likely be replaced with something +% completely different. +% +% \begin{macro}{\if@balance} +% |@balance| is set to true if we encounter a balance penalty +% during collection. +% \begin{macrocode} +\newif\if@balance +\def\@balancefalse{\global\let\if@balance\iffalse} +\def\@balancetrue{\global\let\if@balance\iftrue} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\balancecolumns} +% +% \begin{macrocode} +\def\balancecolumns { + \add@badly@guarded@penalty\output@balance@penalty +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \newpage +% +% \subsection{Support for Flush Points} +% +% +% \begin{macro}{\if@flushseen} +% \begin{macro}{\if@flushfail} +% +% |@flushseen| is set to true if we encounter a flush penalty +% during collection. +% +% |@flushfail| is set to true if we fail a trial due to placing the +% float after the flush penalty. +% \begin{macrocode} +\newif\if@flushseen +\def\@flushseenfalse{\global\let\if@flushseen\iffalse} +\def\@flushseentrue{\global\let\if@flushseen\iftrue} +\newif\if@flushfail +\def\@flushfailfalse{\global\let\if@flushfail\iffalse} +\def\@flushfailtrue{\global\let\if@flushfail\iftrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\flushfloats} +% +% Possible variants: +% +% Flush only one (some) types. +% +% Fuzzyflush or, more precisely, flush-to-this-column +% or -page or -spread.\footnote{Right now "spread" is not implemented.} +% +% Parts of the flushpenalty (all types) data structure: +% +% |\flush@min@col@|\meta{num} +% |\saved@flush@min@col@|\meta{num} +% |\flush@prev@float@num@|\meta{num}\footnote{what is this Chris?} +% +% |\flush@seq@num| is the number of these so that +% \meta{num} has range [1, |\flush@seq@num|] +% +% In addition, whilst doing an fp trial we need |\trial@flush@seen@num| +% to record that we have, in this trial so far, seen the +% flush points [1, |\trial@flush@seen@num|]. +% +% +% \begin{macrocode} +\DeclareDocumentCommand\flushfloats { o O{strict} } + { \flush@floats {#1} {#2} } +% \end{macrocode} +% +% \begin{macrocode} +\def\flush@floats #1 #2 { + \add@badly@guarded@penalty\output@flush@float@penalty +% \end{macrocode} +% +% \begin{macrocode} + \gincrement@num\flush@seq@num +% \end{macrocode} +% +% \begin{macrocode} + \global\@namedef{flush@min@col@\flush@seq@num}{1} +% \end{macrocode} +% +% \begin{macrocode} + \expandafter\xdef + \csname flush@last@float@\flush@seq@num \endcsname + {\the\float@sequence@count} +% \end{macrocode} +% If |#1| is |\NoValue| the current flush point affects all float +% sequence classes, thus we store in +% |\flush@classes@list@|\meta{num} a list of all float sequence +% classes separated by semicolons. Otherwise we assume that we got +% a single float type(!) as argument and flush the corresponding +% class. +% \begin{macrocode} + \IfNoValueTF{#1}{ + \def\@elt##1{##1;} + \expandafter\xdef + \csname flush@classes@list@\flush@seq@num \endcsname + {\float@classes@list} + \let\@elt\relax + } + {\expandafter\ifx\csname sequence@class@#1\endcsname + \relax + \ErrorArgumentNotAFloatType + \else + \global\expandafter\let + \csname flush@classes@list@\flush@seq@num + \expandafter\endcsname + \csname sequence@class@#1\endcsname + \fi + } +% \end{macrocode} +% The argument |#2| holds the fuzziness of the flush point which +% currently can be either |strict|, |column| or |page|. +% We link |\flush@fuzziness@|\meta{num} to the code stored in +% |\flushcheck@#2| after making sure that such code +% exists.\footnote{Improve error handling (as elsewhere)} +% \begin{macrocode} + \@ifundefined {flushcheck@#2} + \userinputERROR + {\global\expandafter\let + \csname flush@fuzziness@\flush@seq@num \expandafter \endcsname + \csname flushcheck@#2\endcsname +%<*trace> + \tr@ce{flush@fuzziness@\flush@seq@num \space + =:~ \expandafter\noexpand\csname flushcheck@#2\endcsname + } +%</trace> + } +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\clearpage} +% \LaTeX's |\clearpage| command now looks like this: +% \begin{macrocode} +\def\clearpage{ \flushfloats \newpage } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\doubleclearpage} +% \LaTeX's |\doubleclearpage| command also needs a new +% definition:\footnote{But not this one :-) FIX!} +% \begin{macrocode} +\def\doubleclearpage{ \clearpage } +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\flush@seq@num} +% The number |\flush@seq@num| records the number of flush +% points we have have seen during collection. +% \begin{macrocode} +\def\flush@seq@num{0} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\trial@flush@seen@num} +% The number |\trial@flush@seen@num| records the number of flush +% points we have seen so far during a trial, i.e., it will be +% initialised to zero at the beginning of the trial and advanced by +% one for each flush point encountered. +% \begin{macrocode} +\def\trial@flush@seen@num{0} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\flush@last@float@xxx} +% \begin{macro}{\flush@min@col@xxx} +% \begin{macro}{\flush@classes@list@xxx} +% \begin{macro}{\flush@fuzziness@xxx} +% +% For each flush point we have a data structure in which we store +% relevant information. This data structure is provided by a set of +% macros which can be accessed by using the number of the current +% flush point and constructing |\csname|s from it, e.g., to get at +% the ``flush min col'' for the flush point with number 3 would be +% |\csname flush@min@col@3\endcsname|. + +% |\flush@min@col@|\meta{num} holds the column number in which we +% last seen the flush penalty while trying to find a solution for +% the current page. This is initialised to 1 in collection@or when +% a flush penalty is encountered during collection (since 1 is the +% earliest column in which the flush penalty finally may fall). By +% adding additional floats to the page the penalty might move to a +% later column but normally not back to an earlier +% one\footnote{There is a possibility that this happens if there is +% enough space vanishing at the new break.} If we end up with the +% flush penalty moving backwards we force a break at this point +% until we reach the column where it was before. The reason for +% this action is that we might have allocated floats to later +% columns that would otherwise end after after the flush penalty. +% +% If by adding floats to the trials the flush penalty is moved to +% the next page we set |\flush@min@col@|\meta{num} to +% |\maxdimen|. The actual test to see if a flush penalty still +% belongs to the current page is to check against |\curr@col@count| +% (so |\curr@col@count+1| would be sufficient, but using +% |\maxdimen| avoids calculations. +% +% |\flush@classes@list@|\meta{num} holds a list of float types which +% are affected by the current flush point. +% +% |\flush@fuzziness@|\meta{num} holds the fuzziness associated with +% the flushpoint, valid values are |strict| and |page|. +% +% By defining (some of) them on top-level we avoid unnecessary +% entries on the savestack since they would otherwise be +% constructed (locally) first within the output routine (when doing +% |\ifx| testing), resulting in |\relax| being stored on the +% savestack. +% \begin{macrocode} +\expandafter\let\csname flush@last@float@1 \endcsname\ERROR +\expandafter\let\csname flush@classes@list@1 \endcsname\ERROR +\expandafter\let\csname flush@min@col@1 \endcsname\ERROR +\expandafter\let\csname flush@fuzziness@1 \endcsname\ERROR +\expandafter\let\csname flush@last@float@2 \endcsname\ERROR +\expandafter\let\csname flush@classes@list@2 \endcsname\ERROR +\expandafter\let\csname flush@min@col@2 \endcsname\ERROR +\expandafter\let\csname flush@fuzziness@2 \endcsname\ERROR +\expandafter\let\csname flush@last@float@3 \endcsname\ERROR +\expandafter\let\csname flush@classes@list@3 \endcsname\ERROR +\expandafter\let\csname flush@min@col@3 \endcsname\ERROR +\expandafter\let\csname flush@fuzziness@3 \endcsname\ERROR +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% +% \begin{macro}{\flush@classes@list@max} +% |\flush@classes@list@max| holds the concatenation of all +% |\flush@classes@list@|\meta{num} on the page currently +% constructed. This information is needed in case we get to a new +% float and the preliminary tests suggests that it needs to be +% deferred. In that case we need to know which flush points have +% been seen previously to decide whether or not we can defer the +% new float. +% \begin{macrocode} +\let\flush@classes@list@max\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\initialise@flush@data} +% \begin{macrocode} +\def \initialise@flush@data{ +%<*trace> + \@tracepush{initialise@flush@data} +%</trace> +% \end{macrocode} +% Does this need any documentation? +% +% Well, we have to get rid of all information relating to flush +% float penalties that have been typeset on the previous page and +% move the remaining ones (if any) to the front. +% \begin{macrocode} + \count@\flush@seq@num\relax + \advance\count@ -\trial@flush@seen@num +%<*trace> + \tr@ce{flush@seq@num~ + =~ \flush@seq@num\space <-~ + \the\count@ } +%</trace> +% \end{macrocode} +% Something wrong here if we get negative values! +% \begin{macrocode} +%<*debug> + \ifnum\count@<\z@ \ERROR \fi +%</debug> +% \end{macrocode} +% +% \begin{macrocode} + \xdef\flush@seq@num{\the\count@} +% \end{macrocode} +% +% \begin{macrocode} + \@tempcnta\trial@flush@seen@num + \@tempcntb\z@ + \loop + \ifnum \@tempcntb < \count@ + + \advance\@tempcnta\@ne + \advance\@tempcntb\@ne +%<*trace> + \tr@ce{flush@fuzziness@\the\@tempcntb\space + =~ \expandafter \noexpand + \csname flush@fuzziness@\the\@tempcntb\endcsname\space + <-~ \expandafter \noexpand + \csname flush@fuzziness@\the\@tempcnta \endcsname + } + \tr@ce{flush@last@float@\the\@tempcntb\space + =~ \csname flush@last@float@\the\@tempcntb\endcsname\space <-~ + \csname flush@last@float@\the\@tempcnta \endcsname + } + \tr@ce{flush@classes@list@\the\@tempcntb\space + =~ \csname flush@classes@list@\the\@tempcntb\endcsname\space <-~ + \csname flush@classes@list@\the\@tempcnta \endcsname + } + \tr@ce{flush@min@col@\the\@tempcntb\space <-~ 1} +%</trace> + \global\expandafter\let + \csname flush@fuzziness@\the\@tempcntb \expandafter\endcsname + \csname flush@fuzziness@\the\@tempcnta \endcsname + + \global\expandafter\let + \csname flush@last@float@\the\@tempcntb \expandafter\endcsname + \csname flush@last@float@\the\@tempcnta \endcsname + + \global\expandafter\let + \csname flush@classes@list@\the\@tempcntb \expandafter\endcsname + \csname flush@classes@list@\the\@tempcnta \endcsname + + \global\@namedef{flush@min@col@\the\@tempcntb}{1} + \repeat +% \end{macrocode} +% +% \begin{macrocode} + \global\let\flush@classes@list@max\@empty +% \end{macrocode} +% Need to reset |\trial@flush@seen@num| in case the current macro +% is called again too early, e.g., if it is called to initialize a +% float page and then again to initialize a text page. +% \begin{macrocode} + \gdef\trial@flush@seen@num{0} +%<*trace> + \@tracepop{initialise@flush@data} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{Support for Here Points} +% +% A ``Here Point'' is a place in the galley at which something is +% supposed to happen. For example, a marginal note needs to be +% attached to the column, or a float needs to be inserted into the +% column (here float), or it needs to be made sure that from that +% point on there is still a certain amount of space available in the +% column. +% +% With each here point there is associated a float structure (i.e. a +% box and its corresponding |\toks| register) although in most cases +% only parts of that structure is used. In addition each here point +% has an associated dimension which denotes the amount of available +% space which is required after the here point in the column to allow +% to place the here point into this column. If this requirement is not +% met the here point is moved to the next column (or page) by ending +% the current column prematurely at the last legal breakpoint before +% the here point (not at the here point itself\footnote{It should be +% considered to allow breaking directly at the here point in special +% cases, i.e., specified at the here point declaration.}). This +% behaviour will ensure that a line of text preceding the here point +% will also be moved to the next column or page which is important in +% case of marginals and similar situations. In case of here floats it +% might not be a requirements so perhaps this should be made +% customisable. +% +% At the moment the ``type'' in the float structure is used to define +% the type of here point. E.g., +% \begin{description} +% \item[mpar] denotes a marginal +% \item[rspace] denotes a requested space +% \item[figure,table,\ldots] all normal float types identify the here +% point as belonging to a here float. +% \end{description} +% The down side of this approach is that ``mpar'' can't be used as a +% float type any longer and the whole approach might be too difficult +% to extend this way. This needs certainly needs a cleanup. +% +% It is quite likely that there will be additional values that need +% storing on a per here point basis. For this reason the code below +% provides the requiredspace as a data structure external to the float +% structure. Otherwise it could probably be integrated therein. +% +% When a here point is encountered while making columns for a trial or +% for the final page, its requirements are checked. If they are +% fulfilled then a here-point-type specific function will update the +% column material (e.g. by adding a here float or a marginal). +% +% Here points are in many aspects like flush points. So most of the +% code below should not be very surprising. +% +% \begin{macro}{\here@seq@num} +% The number |\here@seq@num| records the number of here +% points we have have seen during collection. +% \begin{macrocode} +\def\here@seq@num{0} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\trial@here@seen@num} +% The number |\trial@here@seen@num| records the number of here +% points we have seen so far during a trial, i.e., it will be +% initialised to zero at the beginning of the trial and advanced by +% one for each here point encountered. +% \begin{macrocode} +\def\trial@here@seen@num{0} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\@herelist} +% |\@elt| list of floats that should appear at a here point. +% \begin{macrocode} +\let\@herelist\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\saved@herelist} +% Saved version of the |\@herelist| while we run a through the +% float placement trial since we need the full |\@herelist| again in +% the next trial. +% \begin{macrocode} +\let\saved@herelist\@empty +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\here@point} +% |\here@point| adds a here point to the MVL. It takes two +% arguments: the box reference associated with the here point and +% the vertical space that needs to be reserved for the material +% added. +% \begin{macrocode} +\def\here@point #1#2{ +% \end{macrocode} +% +% \begin{macrocode} + \@cons\@herelist#1 +% \end{macrocode} +% +% \begin{macrocode} + \gincrement@num\here@seq@num +% \end{macrocode} +% +% \begin{macrocode} + \global\@namedef{here@min@col@\here@seq@num}{1} +% \end{macrocode} +% +% \begin{macrocode} + \setlength\dimen@{#2} + \expandafter\xdef + \csname here@required@space@\here@seq@num \endcsname + {\the\dimen@} +% \end{macrocode} +% +% \begin{macrocode} + \add@badly@guarded@penalty\output@here@float@penalty +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\initialise@here@data} +% \begin{macrocode} +\def \initialise@here@data{ +%<*trace> + \@tracepush{initialise@here@data} +%</trace> +% Does this need any documentation? +% +% Well, we have to get rid of all information relating to here +% float penalties that have been typeset on the previous page and +% move the remaining ones (if any) to the front. +% \begin{macrocode} + \count@\here@seq@num\relax + \advance\count@ -\trial@here@seen@num +%<*trace> + \tr@ce{here@seq@num~ + =~ \here@seq@num\space <-~ + \the\count@ } +%</trace> +% \end{macrocode} +% Something wrong hereif we get negative values! +% \begin{macrocode} +%<*debug> + \ifnum\count@<\z@ \ERROR \fi +%</debug> +% \end{macrocode} +% +% \begin{macrocode} + \xdef\here@seq@num{\the\count@} +% \end{macrocode} +% +% \begin{macrocode} + \@tempcnta\trial@here@seen@num + \@tempcntb\z@ + \loop + \ifnum \@tempcntb < \count@ + + \advance\@tempcnta\@ne + \advance\@tempcntb\@ne +%<*trace> + \tr@ce{here@required@space@\the\@tempcntb\space + =~ \csname here@required@space@\the\@tempcntb\endcsname\space <-~ + \csname here@required@space@\the\@tempcnta \endcsname + } + \tr@ce{here@min@col@\the\@tempcntb\space <-~ 1} +%</trace> + \global\expandafter\let + \csname here@required@space@\the\@tempcntb \expandafter\endcsname + \csname here@required@space@\the\@tempcnta \endcsname + + \global\@namedef{here@min@col@\the\@tempcntb}{1} + \repeat +%<*trace> + \@tracepop{initialise@here@data} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\split@off@last@line} +% +% When a here point doesn't fit onto the current page or column for +% some reason it will be moved into the next column. In some cases, +% e.g., when the here point is associated with the line before it +% (as, for example, in marginals) it is necessary to move the line +% also to the later column. +% +% The purpose of |\split@off@last@line| (to be called inside the +% OR) is to split box 255 at the latest possible breakpoint before +% the end and return the material following this breakpoint to the +% MVL. +% +% The idea is as follows: if we subtract 1sp from the height of +% box 255 and also subtract all of its internal shrinkability and +% then split it to this height it can't any longer reach the final +% breakpoint (by 1sp). Thus it will settle with some earlier +% breakpoint and chances are very very good that this will be the +% prefinal one. +% \begin{macrocode} +\def \split@off@last@line{ +%<*trace> + \@tracepush{split@off@last@line} + \tr@ce{goal:~ \the\pagegoal;~ total:~ \the\pagetotal;~ shrink:~ + \the\pageshrink} + \tr@ce{ht255:~ \the\ht255;~ dp255:~ \the\dp255} +%</trace> +% \end{macrocode} +% +% +% \begin{macrocode} + \dimen@\ht\@cclv +% \end{macrocode} +% Looking at |\ht255| should be the same as |\pagetotal-\pagedepth| +% or not?\footnote{Doesn't seem to be the case, bug in the code, +% the program, or in my thinking? (seems to be a bug in \TeX: +% pagedepth is always zero in the OR!)} +% \begin{macrocode} + \advance\dimen@-\pageshrink + \advance\dimen@-1sp +%{\showoutput\showbox\@cclv} +% \end{macrocode} +% Before splitting we have to ensure that the maximum depth is not +% larger than the maximum depth allowed on the MVL. +% \begin{macrocode} + \splitmaxdepth\@maxdepth + \setbox\z@\vsplit\@cclv to\dimen@ +%{\showoutput\showbox\z@} +%{\showoutput\showbox\@cclv} +% \end{macrocode} +% +% Before we now |\unvbox| 255 back onto the MVL we have to make sure +% that the sum of its vertical dimensions plus the requested space +% for the current here point is smaller than a full column height. +% +% If we don't do that we might end up with a situation where we are +% pushing the two from column to columns since they will never fit. +% \begin{macrocode} + \dimen@\csname + here@required@space@\trial@here@seen@num + \endcsname + \advance\dimen@\ht\@cclv + \advance\dimen@\dp\@cclv +% \end{macrocode} +% If the sum is too large we reduce the required space for the here +% point and complain (not really done yet the latter). +% \begin{macrocode} + \ifdim \dimen@ > \textheight + \ERROR-HERE-TOO-LARGE + \dimen@\textheight + \advance\dimen@-\ht\@cclv + \advance\dimen@-\dp\@cclv + \expandafter\xdef\csname + here@required@space@\trial@here@seen@num + \endcsname{\the\dimen@} + \fi +% \end{macrocode} +% So now we can |\unvbox| and then move the top from the split back +% into 255 (essentially to have it taken out of that register by +% the code following, but such is life). +% \begin{macrocode} + \unvbox\@cclv + \global\setbox\@cclv\box\z@ +%<*trace> + \@tracepop{split@off@last@line} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{Support for Grid Points} +% +% +% +% +% \begin{macro}{\align@collected@galley@and@restart} +% |\align@collected@galley@and@restart| is called inside +% |\some@column@or| when we have encountered a grid point. It is +% supposed to align the current line with the text grid and then +% restarts the galley processing. +% +% We do this by putting the material gathered so far into a box of +% appropriate size, and then push this pack onto the recent +% contributions for reconsideration. +% \begin{macrocode} +\def \align@collected@galley@and@restart { +%<*trace> + \@tracepush{align@collected@galley@and@restart} + \tr@ce{GRID:~ page~ goal~\space\space\space =~ \the\pagegoal} + \tr@ce{GRID:~ page~ total~\space\space =~ \the\pagetotal} + \tr@ce{GRID:~ page~ depth~\space\space =~ \the\pagedepth} + \tr@ce{GRID:~ page~ shrink~\space =~ \the\pageshrink} + \tr@ce{GRID:~ page~ stretch~ =~ \the\pagestretch} + \tr@ce{GRID:~ page~ fil~ stretch~ =~ \the\pagefilstretch} + \tr@ce{GRID:~ page~ fill~ stretch~ =~ \the\pagefillstretch} + \tr@ce{GRID:~ page~ filll~ stretch~ =~ \the\pagefillstretch} + \tr@ce{GRID:~ ht~ 255~\space =~ \the\ht\@cclv} + \tr@ce{GRID:~ dp~ 255~\space =~ \the\dp\@cclv} +%</trace> +% \end{macrocode} +% As a first step we remove the guard box since it has now served +% its purpose. +% \begin{macrocode} + \remove@guard@box@from@cclv +% \end{macrocode} +% Then we calculate the distance to nearby grid points. +% \begin{macrocode} + \snap@to@grid{\ht\@cclv}\pagesetup@grid@point@sep +% \end{macrocode} +% So the next step is to make a decision which grid point to +% use. The strategy used below can probably be refined +% further\ldots +% +% First we test if the next grid point down makes us fall off the +% page\footnote{We should use \texttt{\string\pagegoal} for the +% test I think, not the commented out construct below, since in +% case of footnotes the available space for text might has be +% reduced!}, if so\ldots +% \begin{macrocode} + \ifdim \returned@size > \pagegoal + % \csname col@ht@ \the\curr@col@count\endcsname % not! +% \end{macrocode} +% \ldots we better try using the previous grid point. +% \begin{macrocode} + \ifdim \returned@lower@delta@size < \pageshrink +% \end{macrocode} +% If the |\pageshrink| allows us to reach the previous point then +% use it. +% \begin{macrocode} +% can use it: do so +%<*trace> + \tr@ce{GRID:~ outside~ page,~ choosing~ lower~ grid~ point} +%</trace> + \global\let \returned@size \returned@lower@size + \xdef \returned@delta@size {-\returned@lower@delta@size } + \else +% \end{macrocode} +% Otherwise, ouch \ldots{} what now? Can this happen? Unfortunately +% yes, it seems to happen, for example, when we are trying to place +% floats.\footnote{Analyse this situation and decide on a course of +% action if necessary.} +% \begin{macrocode} + \OuchERROR + \fi +% \end{macrocode} +% Otherwise we are in the normal case, i.e., somewhere in the +% middle of the page. +% \begin{macrocode} + \else +% \end{macrocode} +% So now we can in principle choose either grid point. The code +% below makes the decision based on which grid point is closer but +% chooses the previous point only if |\pageshink| allows +% it.\footnote{One could also have a look at the available +% stretchability and base the decision on the resulting badness, +% this might in fact be the more appropriate way!} +% \begin{macrocode} + \ifdim \returned@lower@delta@size < \returned@delta@size \relax + \ifdim \returned@lower@delta@size < \pageshrink +%<*trace> + \tr@ce{GRID:~ choosing~ lower~ grid~ point} +%</trace> + \global\let \returned@size \returned@lower@size + \xdef \returned@delta@size {-\returned@lower@delta@size } + \fi + \fi + \fi +%<*trace> + \tr@ce{GRID:~ adjustment:~ \the\ht\@cclv\space ->~ \returned@size} +%</trace> +% \end{macrocode} +% Whatever the decision was, we finally bundle up all material in a +% box with the vertical size being that of the chosen grid point +% (no |\maxdepth| setting in this case) and return this box to the +% MVL followed by any footnotes found in that process. These +% footnotes are reinserted so that they will be reconsidered but +% since we have no break point between the box and them they will +% be considered as a unit. +% \begin{macrocode} + \vbox to\returned@size{\unvbox\@cclv} + \@reinserts +% \end{macrocode} +% We know that the material returned to the MVL is followered +% immediately by a box of size zero followed by a penalty thus +% there will be a breakpoint in the right place (or so we hope) so +% that the box plus the following footnotes will still fit into the +% column when reprocessed. +% \begin{macrocode} +%<*trace> + \@tracepop{align@collected@galley@and@restart} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\OuchERROR} +% This part of the code (as far as I can see right now) will be +% executed if there is some larger display object (ie off grid) +% which will just fit onto the page unaligned but not if we align +% to the next grid point. The reason for this is that somewhere on +% the column there are also footnotes for example, which result in +% the column not being an integral number of grid lines. +% \begin{macrocode} +\def\OuchERROR{ +%<*trace> + \tr@ce{Failed:~grid~ overflowing~ column~ \the\curr@col@count} +%</trace> +%<*progress> + \progress@failed{next~ possible~ grid~ point~ in~ column~ + \the\curr@col@count\space outside~ page} +%</progress> +% \end{macrocode} +% I think essentially what is needed here is to split the column +% just before the current line, ie, using something like +% |\split@off@last@line| (except that this only works for here +% points right now) and this move the grid align penalty to the +% next column.\footnote{Not done! FIX} +% \begin{macrocode} +% \split@off@last@line +% \(re)???add@guarded@penalty\output@grid@align@penalty +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\std@AlignToGrid} +% This is the definition for |\AlignToGrid| if we are really doing +% grid based layout. +% \begin{macrocode} +\def\std@AlignToGrid{ + \add@badly@guarded@penalty\output@grid@align@penalty +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\IgnoreAlignToGrid} +% \begin{macro}{\ObeyAlignToGrid} +% |\IgnoreAlignToGrid| will turn off automatic grid alignment for a +% while, while |\ObeyAlignToGrid| will turn it on again. This is +% needed in commands that want to set something outside the grid +% and then realign afterwards, e.g., a heading. If that heading +% would follow, say, a list that issued a |\AlignToGrid| to be +% executed on the next paragraph, that |\AlignToGrid| would +% effectively appear on the heading title thus forcing that to be +% on a grid line, which is typically not intended. So the heading +% macro first says |\IgnoreAlignToGrid| then typesets the material +% which should be not aligned, then says |\ObeyAlignToGrid| and +% prepares to install its own |\AlignToGrid| (typically after the +% first line of text via |\everypar|). +% \begin{macrocode} +\def\IgnoreAlignToGrid{ + \global\let\AlignToGrid\relax +} +\def\ObeyAlignToGrid{ + \global\let\AlignToGrid\std@AlignToGrid +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% +% \begin{macro}{\AlignToGrid} +% |\AlignToGrid| is the command that inserts a grid point which +% triggers alignment to the text grid for the current line (if we +% are doing grid based design). It should be set in the page setup +% so the default is an error. +% \begin{macrocode} +\let\AlignToGrid\ERROR +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\TextAlignToGrid} +% In nearly all cases the alignment should be done for a text line, +% so we provide this abbreviation which starts horizontal mode if +% necessary. +% \begin{macrocode} +\def\TextAlignToGrid{ \leavevmode \AlignToGrid } +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \subsection{Initialisations} +% +% The initialisation at begin document isn't properly done +% yet. Some bits are done unnecessarily here (by calling +% initialisation commands that do too much and some bits are +% problably still in the wrong place. Furthermore the column data +% initialisation needs to be resolved properly. Right now we +% hardwire a maximum of 6 columns down there and initialise the +% data structures for all the potential columns independently of +% whether or not they are ever being used.\footnote{SORT OUT!} +% \begin{macrocode} +\AtBeginDocument{ + \begingroup + \col@count6\relax + \initialise@column@data +% \end{macrocode} +% More column data stuff which needs to be set only the very first +% time! +% \begin{macrocode} + \forall@columns { +% \end{macrocode} +% +% \begin{macrocode} + \def\@elt#1{ + \global\@namedef{fl@\the\curr@col@count @#1}{0} + \global\@namedef{tfl@\the\curr@col@count @#1}{0} + } + \float@classes@list +% \end{macrocode} +% Setting |\@elt| back to |\relax| is done below. +% \begin{macrocode} + } +% \end{macrocode} +% +% The default for fps should be all areas known (not only those +% currently used!) +% \begin{macrocode} + \def\@elt#1{ + \global\expandafter\let\csname fps@#1\endcsname\known@areas + \global\@namedef{fl@0@#1}{0} + } + \float@classes@list + \endgroup +% \end{macrocode} +% +% \begin{macrocode} +% \initialise@next@page +% \end{macrocode} +% Start the document by collecting text. +% \begin{macrocode} + \@collecting@new@materialtrue + \setup@collection@or +} +% \end{macrocode} +% +% +% \endinput +\endinput +% +% $Log: xo-or.dtx,v $ +% Revision 1.53 2000/08/11 07:14:25 latex3 +% added header +% +% Revision 1.52 2000/08/11 06:49:21 latex3 +% untabify +% +% Revision 1.51 2000/08/11 06:46:48 latex3 +% change logic for handling special penalties once more (and still not +% okay) +% +% Revision 1.50 2000/08/06 19:03:44 latex3 +% change initialisation at \begin{document} +% fix \columnbreak +% +% Revision 1.49 2000/08/04 13:58:16 latex3 +% documented issue when grid point overflows column +% +% Revision 1.48 2000/08/04 10:22:31 latex3 +% added \split@skip (probably not final version) +% +% Revision 1.47 2000/07/26 20:37:03 latex3 +% working version of grid points (text grids) +% +% Revision 1.46 2000/07/21 13:52:13 latex3 +% more renaming for float sequence class concept +% +% Revision 1.45 2000/07/19 17:12:08 latex3 +% introduced float sequence class concept +% added variables for float area separation +% +% Revision 1.44 2000/07/10 19:24:59 latex3 +% some start at supporting "balance points" (unfinished). +% added \initialise@column@data. +% getting rid of extra empty page at end due to old defnition of +% \clearpage. +% +% Revision 1.43 2000/07/04 19:45:40 latex3 +% fix GRID stuff (restore all values as needed) +% +% Revision 1.42 2000/07/01 16:07:26 latex3 +% use \update@this@area@columns +% integrate code to support grid design (first draft) +% +% Revision 1.41 2000/06/29 17:40:44 latex3 +% introduced \setup@this@area +% +% Revision 1.40 2000/06/26 15:16:15 latex3 +% prototype support for \pagesetup@float@area@sep +% +% Revision 1.39 2000/06/22 20:07:51 latex3 +% renamed some macros to get them more uniform +% +% Revision 1.38 2000/06/22 10:59:57 latex3 +% Included support for writing fpl files +% +% Revision 1.37 2000/06/21 09:55:41 latex3 +% fix typo +% +% Revision 1.36 2000/06/19 19:03:56 latex3 +% make \gincrement@num and \gdecrement@num behave (not update \count@) +% cleanup flushing (if fail only move flush point one column) +% +% Revision 1.35 2000/06/18 14:59:50 latex3 +% docu updates (and a bug fix due to typo) +% +% Revision 1.34 2000/06/16 11:21:14 latex3 +% rename \construct@and@test@col@height to \construct@and@test@col@ht +% rename \construct@and@test@col@heights to \construct@and@test@col@hts +% rename \cl@height1 to \@col@ht@1 (etc) +% +% Revision 1.33 2000/06/16 11:05:25 latex3 +% implemented tfl@ support (top area float sequences) +% support float-callout-span-constraint +% more documentation +% +% Revision 1.32 2000/06/15 15:20:16 latex3 +% implemented new semantics for area names +% +% Revision 1.31 2000/06/15 09:32:18 latex3 +% added mising \end{macro}'s +% +% Revision 1.30 2000/06/13 20:44:25 latex3 +% guard the output@collect@penalty +% implemented fuzzy flushing (except for spreads) +% +% Revision 1.29 2000/06/06 11:03:21 latex3 +% before attempting fuzzyflush +% +% Revision 1.28 2000/05/03 20:17:31 latex3 +% need more info about here floats +% +% Revision 1.27 2000/05/03 18:45:40 latex3 +% fix bugs: always have a trial run wihtout floats to initialise here +% and flush points; reset \trial@flush@seen@num after using it to update +% the data structures on a new pages; have adding to the defer area +% close other areas :-) +% more documentation +% +% Revision 1.26 2000/04/27 19:50:11 latex3 +% some stats gathered now +% combine \grab@column@or and \best@column@or as far as possible +% some bug fixes and additional documentation +% +% Revision 1.25 2000/04/21 19:08:43 latex3 +% code cleanup +% additional documentation +% fixes for here points +% support for footnote setup +% +% Revision 1.24 2000/04/11 21:06:06 latex3 +% basically Chris's 1.24 plus my changes +% +% Revision 1.24 2000/04/10 16:41:14 car2 +% typos, comments and guardbox removal +% +% Revision 1.23 2000/04/09 20:02:00 latex3 +% fix topskip problem in collection +% added first draft of marginpar support +% +% Revision 1.22 2000/04/08 09:47:06 latex3 +% first draft of here point implementation +% code cleanup +% further documentation +% +% Revision 1.21 2000/03/31 17:12:41 latex3 +% disable preplacing deferred floats (until caption handling is fixed) +% fix float page handling +% ensure that float pages don't add additional captions (don't mind that +% the float page comes out even worse) +% +% Revision 1.20 2000/03/26 21:05:11 latex3 +% work on float pages +% some renaming in particular \try@this@area +% and \try@next@area +% some more documentation +% +% Revision 1.19 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.18 2000/03/22 15:51:11 latex3 +% some normalisations of names +% moved code around +% lot of updates +% +% Revision 1.17 2000/03/17 20:26:40 latex3 +% more fixes to flushing (looks good now) +% +% Revision 1.16 2000/03/16 10:28:29 latex3 +% partial and full flush working for the first time +% +% Revision 1.15 2000/03/05 19:36:53 latex3 +% some renaming +% support multiple columns (6 max right now) +% fix flush float logic (hopefully) +% +% Revision 1.14 2000/02/28 23:41:14 david +% deadcycles +% +% Revision 1.13 2000/02/27 15:39:53 david +% *** empty log message *** +% +% Revision 1.12 2000/02/27 15:12:00 david +% 2nd attempt at flush floats (working as far as implemented) +% +% Revision 1.11 2000/02/27 11:26:35 david +% first attempt at flush floats +% +% Revision 1.10 2000/02/26 18:20:09 david +% added pre-allocation of deferred floats to float areas +% +% Revision 1.9 2000/02/21 23:25:11 david +% t11|t22 support in optional argument +% +% Revision 1.8 2000/02/19 23:14:58 david +% chris' doc fix +% +% Revision 1.7 2000/02/16 13:40:40 latex3 +% added 3col support +% +% Revision 1.6 2000/02/16 10:07:13 latex3 +% added further documentation +% fixed bug by removing code from \try@this@area to +% \pretests@success@action +% handle case of hitting special output penalty during trial or +% page production +% handle case of \newpage ie penalty -10000 +% +% Revision 1.5 2000/02/15 01:08:25 david +% dead code +% +% Revision 1.4 2000/02/13 22:40:13 latex3 +% moved some stuff around and added macro environments +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-page.dtx b/Master/texmf-dist/source/latex3/xor/xo-page.dtx new file mode 100644 index 00000000000..7dff99b8119 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-page.dtx @@ -0,0 +1,694 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-page.dtx,v 1.34 2000/08/11 07:14:27 latex3 Exp $ +% \end{macrocode} +% +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% +% \subsection{Footnote setup} +% +% \begin{macro}{\initialise@footins@action} +% The |\initialise@footins@action| is a hook to add code to the +% page initialisation phase related to the footnote insertions. For +% example, when all footnotes are accumulated in the last column we +% need to make footnote insertions invisible when gathering +% material for the first columns. +% \begin{macrocode} +\let\initialise@footins@action\relax +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\deal@with@footins@action} +% The |\deal@with@footins@action| hook is called in the +% |\grab@column@or| and the |best@column@or| output routine to do +% something to the accumulated footnote insertions if +% necessary. I.e., it is called for every column. +% \begin{macrocode} +\let\deal@with@footins@action\relax +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macrocode} +\DeclareTemplateType{footnotesetup}{0} +% \end{macrocode} +% +% +% +% +% \begin{macrocode} +\DeclareTemplate{footnotesetup}{std}{0}{ + text-sep =+l \skip\footins, + max-height =+l \dimen\footins, + } + { + + \global\skip\footins 10pt plus 5pt + \global\dimen\footins.7\textheight + + \DoParameterAssignments + + \let\initialise@footins@action\relax + \let\deal@with@footins@action\relax + + \global\count\footins\@m + + } +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{footnotesetup}{ftnright}{0}{ + text-sep =+l \rcol@footinsskip, + max-height =+l \dimen\footins, + } + { + + \global\rcol@footinsskip 10pt plus 5pt + \global\dimen\footins\textheight + + \DoParameterAssignments + + \let\initialise@footins@action\initialise@footins@ftnright + \let\deal@with@footins@action\deal@with@footins@ftnright + + } +% \end{macrocode} +% +% +% Setting |max-height| as done below has not the desired effect and +% needs investigation.\footnote{FIX!} +% +% \begin{macrocode} +\DeclareTemplate{footnotesetup}{margin}{0}{ + max-height =+l \dimen\footins, + } + { + + \global\dimen\footins.7\textheight + + \DoParameterAssignments + + \let\initialise@footins@action\initialise@footins@margin + \let\deal@with@footins@action\deal@with@footins@margin + +% \end{macrocode} +% If the footnote do not appear within the columns we have to +% ensure that the |\insert| does not change the page +% calculations. This needs changes in two places: +% \begin{macrocode} + \global\count\footins\z@ + \global\skip\footins \z@ + + } +% \end{macrocode} +% +% +% +% +% \subsubsection{Footnote setup ftnright} +% +% In this section we provide the code for running all footnotes in the +% last column. +% +% \begin{macro}{\saved@footins} +% +% \begin{macrocode} +\newbox\saved@footins +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\rcol@footinsskip} +% \begin{macrocode} +\newskip\rcol@footinsskip +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\initialise@footins@ftnright} +% \begin{macrocode} +\def \initialise@footins@ftnright { + \global\setbox\saved@footins\box\voidb@x + \global\skip\footins\z@ + \global\count\footins\z@ + \global\dimen\footins\textheight +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \begin{macro}{\deal@with@footins@ftnright} +% \begin{macrocode} +\def \deal@with@footins@ftnright { +%<*trace> + \@tracepush{deal@with@footins@ftnright} +%</trace> +% \end{macrocode} +% If we are not in the last column we save any footnote accumulated +% in |\footins| in a separate |\saved@footins| box. This way any +% later code that checks |\footins| for constraints will not fire +% incorrectly. +% \begin{macrocode} + \ifnum\curr@col@count<\col@count +%<*trace> + \tr@ce{not~ last~ col} +%</trace> + \ifvoid\footins + \else + \global\setbox\saved@footins + \vbox{\unvbox\saved@footins + \unvbox\footins} + \fi +% \end{macrocode} +% If we are in the second last column we have to change the +% procedure: we now have to return all saved footnotes to the MVL +% and modify the insertion register values so that from now on +% footnotes need space in the column.\footnote{Not correctly +% handled is the case that we have accumulated more than a full +% column of footnotes before!} +% \begin{macrocode} + \count@\col@count + \advance\count@\m@ne + \ifnum\curr@col@count=\count@ % cur col = second last col +%<*trace> + \tr@ce{second~ last~ col} +%</trace> + \global\count\footins\@m + \global\skip\footins\rcol@footinsskip + \ifvoid\saved@footins + \else + \insert\footins{\unvbox\saved@footins} + \fi + \fi + \fi +%<*trace> + \@tracepop{deal@with@footins@ftnright} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\deal@with@footins@margin} +% \begin{macrocode} +\def \deal@with@footins@margin { +%<*trace> + \@tracepush{deal@with@footins@margin} +%</trace> + \ifvoid\footins + \else + \global\setbox\saved@footins + \vbox{\unvbox\saved@footins + \unvbox\footins} + \fi +%<*trace> + \@tracepop{deal@with@footins@margin} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\deal@with@footins@margin} +% \begin{macrocode} +\def \initialise@footins@margin { + \global\setbox\saved@footins\box\voidb@x +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{A basic page setup template} +% +% +% \begin{macro}{\test@named@key} +% This should perhaps be made more general +% \begin{macrocode} +\def\test@named@key #1#2#3#4 { + \global\expandafter\let \expandafter #1 + \csname #2 \endcsname + \ifx #1 \relax + \PackageError{template}{#3~ unknown} + {#3~ can~ be~ either~ #4} + \fi +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\DeclareFloatArea} +% We declare new float areas and (for the moment) internally use the +% template mechanism. But this is more or less overkill and should +% probably be replaced in the end. +% \begin{macrocode} +\def\DeclareFloatArea#1#2{ + \xdef\known@areas{\known@areas#1} + \DeclareInstance{floatareasetup}{#1}{std} + { name = #1, #2 } +% \end{macrocode} +% We need to do some intialisation here in case the area isn't +% really used. (Since it is added to |\known@areas| it will be +% considered and that will die if the initialisation isn't done) +% \begin{macrocode} + \UseInstance{floatareasetup}{#1} +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macrocode} +\DeclareTemplateType{floatareasetup}{0} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{floatareasetup}{std}{0}{ + name =n \floatareasetup@name, + class-close-list=n \floatareasetup@class@close, + all-close-list =n \floatareasetup@all@close, + max-float-num =C \floatareasetup@maxfloats, + } + { + + \DoParameterAssignments +% \end{macrocode} +% +% Declare area data structures if necessary\ldots +% \begin{macrocode} + \@ifundefined{\floatareasetup@name @float@count} + {\expandafter\newcount\csname \floatareasetup@name + @float@count\endcsname} + {} +% \end{macrocode} +% \ldots and initialise them +% \begin{macrocode} + \global\expandafter\let + \csname pagesetup@ \floatareasetup@name @float@num\endcsname + \floatareasetup@maxfloats + \global\expandafter\let + \csname pagesetup@ \floatareasetup@name @class@close\endcsname + \floatareasetup@class@close + \global\expandafter\let + \csname pagesetup@ \floatareasetup@name @all@close\endcsname + \floatareasetup@all@close +% \end{macrocode} +% Let's not forget that area itself (some macros wouldn't like if +% this is |\relax| rather than |\@empty|. +% \begin{macrocode} + \global\expandafter\let + \csname area@\floatareasetup@name\endcsname + \@empty +} +% \end{macrocode} +% +% +% \begin{macrocode} +\DeclareTemplateType{pagesetup2}{0} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareTemplate{pagesetup2}{std}{0}{ + column-num =+c \col@count, + column-width =+l \columnwidth, + column-height =+l \textheight, % FMi tmp + column-sep =+l \columnsep, + max-float-num =C \pagesetup@max@float@num, + float-callout-constraint =n \pagesetup@float@callout, + float-callout-span-constraint =n \pagesetup@float@callout@span, + bottom-float-footnote-constraint =n \pagesetup@float@footnote, + flush-float-callout-constraint =n \pagesetup@flush@float@callout, + flush-float-callout-span-constraint =n \pagesetup@flush@float@callout@span, + flush-bottom-float-footnote-constraint =n + \pagesetup@flush@float@footnote, +% +% \end{macrocode} +% +% \begin{macrocode} + area-list =n \pagesetup@area@list, +% \end{macrocode} +% \begin{macrocode} + defer-class-close-list=n \pagesetup@ddd@class@close, + defer-all-close-list =n \pagesetup@ddd@all@close, +% \end{macrocode} +% +% \begin{macrocode} + footnote-setup =i {footnotesetup} \pagesetup@footnote@setup, +% \end{macrocode} +% +% \begin{macrocode} + float-float-sep =+l \pagesetup@float@float@sep, + float-area-sep =+l \pagesetup@float@area@sep, + float-text-sep =+l \pagesetup@float@text@sep, + float-inline-sep =+l \pagesetup@float@inline@sep, +% \end{macrocode} +% +% \begin{macrocode} + grid-point-sep =+L \pagesetup@grid@point@sep, + } + { +% \end{macrocode} +% We start off with ensuring that we are at the top of a page. This +% is a temporary solution until after pagesetup is more settled and +% those bits which are only possible if there is nothing left on +% recent contributions are properly separated from those things +% which can be changed midway. +% \begin{macrocode} + \newpage + + \global\col@count\@ne + \def\pagesetup@max@float@num{3} + \def\pagesetup@float@callout{column} + \def\pagesetup@float@footnote{none} + \def\pagesetup@flush@float@callout{\pagesetup@float@callout} + \def\pagesetup@flush@float@footnote{\pagesetup@float@footnote} + \def\pagesetup@float@callout@span{flexible} + \def\pagesetup@flush@float@callout@span{\pagesetup@float@callout@span} +% \end{macrocode} +% +% \begin{macrocode} + \let\pagesetup@ddd@class@close\maxdimen %impossible value + \let\pagesetup@ddd@all@close\@empty +% \end{macrocode} +% +% \begin{macrocode} +% tmp: + \def\pagesetup@footnote@setup{\UseTemplate{footnotesetup}{std}{}} +% \end{macrocode} +% +% \begin{macrocode} + \global\let\pagesetup@grid@point@sep\z@ % no grid points by default + + \DoParameterAssignments +% \end{macrocode} +% +% \begin{macrocode} + \ifdim \pagesetup@grid@point@sep = \z@ + \global\let\snap@to@grid\dummy@snap@to@grid +% \end{macrocode} +% Next two lines need some refinement, we need some mechanism to +% fully disable those grid points. |\IgnoreAlignToGrid| doesn't do +% the trick.\footnote{FIX!} +% \begin{macrocode} + \IgnoreAlignToGrid + \global\let\std@AlignToGrid\relax + \else + \global\let\snap@to@grid\std@snap@to@grid + \ObeyAlignToGrid + \fi +% \end{macrocode} +% Split the |\pagesetup@float@text@sep| specification and store the +% minus part in |\pagesetup@float@text@shrink|. Right now the plus +% part is not used. Actually this is only really necessary if we do +% grid typesetting but we do it anyway so that the spec is always +% checked for offending infinite stretch. +% \begin{macrocode} + \split@skip{float-text-sep} + \pagesetup@float@text@sep + \dimen@ + {\global\pagesetup@float@text@shrink} +% \end{macrocode} +% +% \begin{macrocode} + \split@skip{float-inline-sep} + \pagesetup@float@inline@sep + \dimen@ + {\global\pagesetup@float@inline@shrink} + \global\pagesetup@float@inline@sep \@ne\pagesetup@float@inline@sep +% \end{macrocode} +% +% \begin{macrocode} + \global\hsize\columnwidth + \global\linewidth\columnwidth + +% all taken away from AtBeginDocument (where it is was added in xo-final) + \setlength \@tempdima {\headheight + \headsep} + \xdef \pagebodytopvpos {\the\@tempdima} + + \setlength \@tempdima {\@tempdima + \textheight} + \xdef \pagebodybotvpos {\the\@tempdima} + +%% horiz + \setlength \@tempdima {\columnwidth + \columnsep} + \xdef \columndisplacement {\the\@tempdima} + +% \end{macrocode} +% +% Perhaps we could use |\known@areas| instead and save the +% test (would need a change in xo-place as well!).\footnote{Check!} +% \begin{macrocode} + \ifx\pagesetup@ddd@class@close\maxdimen % not set? + \let\pagesetup@ddd@class@close\pagesetup@area@list + \fi +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \std@check@callout@constraints + {check@callout@\pagesetup@float@callout} + {float-callout-constraint} + {`none',~ `page',~ `column',~ or~ `after'} +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \relaxed@check@callout@constraints + {check@callout@\pagesetup@flush@float@callout} + {flush-float-callout-constraint} + {`none',~ `page',~ `column',~ or~ `after'} +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \std@check@some@constraints + {check@float@footnote@\pagesetup@float@footnote} + {bottom-float-footnote-constraint} + {`none'~ or~ `forbidden'} +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \relaxed@check@some@constraints + {check@float@footnote@\pagesetup@flush@float@footnote} + {flush-bottom-float-footnote-constraint} + {`none'~ or~ `forbidden'} +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \std@calculate@target@fl@column + {calculate@target@fl@column@\pagesetup@float@callout@span} + {float-callout-span-constraint} + {`strict'~ or~ `flexible'} +% \end{macrocode} +% +% \begin{macrocode} + \test@named@key + \relaxed@calculate@target@fl@column + {calculate@target@fl@column@\pagesetup@flush@float@callout@span} + {flush-float-callout-span-constraint} + {`strict'~ or~ `flexible'} +% \end{macrocode} +% +% \begin{macrocode} + \global\let\check@some@constraints\std@check@some@constraints + \global\let\check@callout@constraints\std@check@callout@constraints + \global\let\calculate@target@fl@column\std@calculate@target@fl@column +% \end{macrocode} +% +% \begin{macrocode} + \global\let\used@areas\@empty +% \end{macrocode} +% +% \begin{macrocode} + \expandafter + \@for \expandafter \@tempa \expandafter:\expandafter= + \pagesetup@area@list \do + { +% \end{macrocode} +% Perhaps the instance should be called the moment we declare the +% area. on the other hand calling it within the page setup would +% allow to use collections!\footnote{Think and decide} +% \begin{macrocode} + \xdef\used@areas{\used@areas\@tempa} +% after next line \@tempa is gone ... David, template.sty needs a cleanup + \UseInstance{floatareasetup}{\@tempa} +%\show\@tempa + } + +% \end{macrocode} +% +% \begin{macrocode} + \pagesetup@footnote@setup +% \end{macrocode} +% +% Finally another bit of the initalisation that we have to redo at +% this point since now some of the values may have +% changed.\footnote{Temporary solution until the initialisation bit +% and the pagesetup is properly sorted out.} +% \begin{macrocode} + \initialise@next@page + \setup@collection@or + } +% +% \end{macrocode} +% +% \begin{macrocode} +\endinput +% \end{macrocode} +% +% \endinput +% +% $Log: xo-page.dtx,v $ +% Revision 1.34 2000/08/11 07:14:27 latex3 +% added header +% +% Revision 1.33 2000/08/07 19:50:48 latex3 +% setup the collection@or again when a pagesetup is selected since its +% parameter might have changed. +% +% Revision 1.32 2000/08/06 19:02:51 latex3 +% move parts initialisation to \begin{document} +% move \newpage in pagesetup template first to ensure that previous page +% is finished with old values +% +% Revision 1.31 2000/08/06 09:02:57 latex3 +% documented that footnotehandling needs fixing +% +% Revision 1.30 2000/08/04 10:23:24 latex3 +% removed float-text-shrink and float-inline-shrink keys and instead +% used \split@skip +% +% Revision 1.29 2000/07/26 20:45:51 latex3 +% first implementation of grid point support +% +% Revision 1.28 2000/07/21 13:52:53 latex3 +% more renaming for float sequence class concept +% +% Revision 1.27 2000/07/18 21:07:03 latex3 +% introduced float sequence classes +% +% Revision 1.26 2000/07/12 16:47:44 latex3 +% use grid points properly in template +% +% Revision 1.25 2000/07/10 21:04:30 latex3 +% integration of float specing parameters in page setup +% support for grid typesetting in page setup +% +% Revision 1.24 2000/07/04 19:44:58 latex3 +% fix marginal footnote template (did change column calculations) +% +% Revision 1.23 2000/06/26 15:01:29 latex3 +% docu update +% +% Revision 1.22 2000/06/21 09:56:09 latex3 +% update docu +% +% Revision 1.21 2000/06/18 15:00:35 latex3 +% move "Bottom float footnote relation" to xo-place file +% +% Revision 1.20 2000/06/16 11:06:05 latex3 +% support float-callout-span-constraint +% +% Revision 1.19 2000/06/15 17:49:55 latex3 +% moved macros about placment checking to xo-place since they don't +% belong here +% +% Revision 1.18 2000/06/15 15:21:33 latex3 +% implemented new semantics for area names +% +% Revision 1.17 2000/06/13 21:21:08 latex3 +% added support for columnheight (tmp) +% define \pagebodytopvpos etc inside template so that it can change +% +% Revision 1.16 2000/05/03 18:48:42 latex3 +% initialise float area data structure the moment the float area is +% declared (otherwise you can't declare areas if they are not used!) +% +% add keys defer-type-close-list and defer-all-close-list to pagesetup2 +% template +% +% Revision 1.15 2000/04/21 19:03:58 latex3 +% added footnote setup +% cleanup pagesetup code +% +% Revision 1.14 2000/04/08 10:48:42 latex3 +% code cleanup +% +% Revision 1.13 2000/04/08 08:16:53 latex3 +% default for \pagesetup@flush@float@callout changed +% +% Revision 1.12 2000/03/31 17:07:24 latex3 +% don't fail in footnote/float test if there isn't any bottom area at +% all! +% +% Revision 1.11 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.10 2000/03/22 15:51:51 latex3 +% some normalisations of names +% +% Revision 1.9 2000/03/17 20:25:02 latex3 +% initialise fl@0 +% support relaxing constraints when flushing +% +% Revision 1.8 2000/03/15 19:58:00 latex3 +% assigning values to \column@number should always be done globally +% +% Revision 1.7 2000/03/05 19:41:21 latex3 +% support multiple columns (6 max right now) +% +% Revision 1.6 2000/02/26 18:21:16 david +% fixed footnote bottom constraint code +% +% Revision 1.5 2000/02/26 16:52:25 david +% *** empty log message *** +% +% Revision 1.4 2000/02/17 22:41:38 david +% *** empty log message *** +% +% Revision 1.4 2000/02/16 13:41:06 latex3 +% added 3col support +% +% Revision 1.3 2000/02/13 14:38:53 latex3 +% was 1.2.1.2 +% +% Revision 1.2.1.2 2000/02/13 11:51:27 latex3 +% fixed \check@callout@after (hopefully correct now) +% added \check@some@constraints logic +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-place.dtx b/Master/texmf-dist/source/latex3/xor/xo-place.dtx new file mode 100644 index 00000000000..0a208459540 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-place.dtx @@ -0,0 +1,1537 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-place.dtx,v 1.37 2000/08/11 07:14:28 latex3 Exp $ +% \end{macrocode} +% +% +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% +% \subsection{Selecting the next area to try} +% +% +% \begin{macro}{\std@try@this@area} +% The |\std@try@this@area| command is called when we have +% selected a float from the |\@activelist| and want to place it +% in one of the open areas to see if it fits there. If we succeed +% in finding a potential candidate place we will exit using +% |\contruct@trial| which will run a trial cutting the galley to +% see if each column gets the right kind of text and contains the +% right kind of callouts. +% The areas are tried in a defined order. +% +% If we don't find any open areas we return putting the current +% float onto the |\area@ddd| and then calling |\@trynextfloat|. +% +% If we find an open area but for some reason the float is not +% allowed to go there we close that area for floats of this type +% and recurse (i.e. try to use the next open area for this type). +% +% The reasons for failure to place the float into the first open +% area are numerous. First there are restrictions on the number of +% floats on a page (if we reach this all areas get closed) there +% there are similar restrictions for each individual float area. +% +% If those tests are passed we trial typeset the float with its +% caption (or rather typeset and attach its caption) to determine +% the size needed by the float. That will give us a dimension to +% test against restrictions for the amount of space floats are +% allowed to occupy etc. +% +% \begin{macrocode} +\def\std@try@this@area{ +%<*trace> + \@tracepush{std@try@this@area} +%</trace> +% \end{macrocode} +% If all areas for the float type are closed we have to defer this float. +% \begin{macrocode} + \ifx\this@open@areas\@empty +%<*trace> + \tr@ce{defer:~no~open~area~ available} +%</trace> + \do@next\defer@and@try@next@float + \else +% \end{macrocode} +% Otherwise the next area to try is the first of |\this@open@areas|: +% \begin{macrocode} + \setup@this@area{\expandafter\@carcube\this@open@areas\@nil} +%<*trace> + \tr@ce{area~trial:~ \this@area} +%</trace> +%<*progress> + \progress{~ area~trial:~ \this@area} +%</progress> +% \end{macrocode} +% Next test needs cleanup once the span has a decent data +% structure.\footnote{FIX!!} +% \begin{macrocode} + \ifnum \this@area@span@number = \if!\this@span@number! 1\else % big hack + \this@span@number \fi + \relax +%<*trace> + \tr@ce{span~ count~ okay:~ \this@area \space =~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \ifnum \pagesetup@max@float@num > \page@float@count +% \end{macrocode} +% +% \begin{macrocode} + \ifnum\csname pagesetup@\this@area @float@num\endcsname = + \csname \this@area @float@count \endcsname +% +% \end{macrocode} +% Current area doesn't accept any more floats, so try next one (if any) +% \begin{macrocode} +%<*trace> + \tr@ce{close~area:~\this@area\space float~num~reached ~ + (\csname pagesetup@\this@area @float@num\endcsname)} +%</trace> +%<*progress> + \progress@failed{\this@area\space float~num~reached ~ + (\csname pagesetup@\this@area @float@num\endcsname)} +%</progress> + \do@next\try@next@area +% \end{macrocode} +% +% \begin{macrocode} + \else + \xin@\this@area + \this@page@closed + \ifin@ +%<*trace> + \tr@ce{area~ closed~ for~ all~ types;~ member~ of~ + (\this@page@closed)} +%</trace> +%<*progress> + \progress@failed{area~ closed~ for~ all~ types} +%</progress> + \do@next\try@next@area + \else +%<*trace> + \tr@ce{area~ not~ closed~ for~ all~ types:~ not~ member~ of~ + (\this@page@closed)} +%</trace> + \xin@\this@area + \this@closed@areas + \ifin@ +%<*trace> + \tr@ce{area~ closed~ for~ class~ \this@class;~ member~ of~ + (\this@closed@areas)} +%</trace> +%<*progress> + \progress@failed + {area~ closed~ for~ class~ \this@class} +%</progress> + \do@next\try@next@area + \else +%<*trace> + \tr@ce{area~ open~ for~ class~ \this@class;~ not~ member~ of~ + (\this@closed@areas)} +%</trace> + \xin@\this@area\this@fps + \ifin@ +% + \append@caption@to@float + \construct@and@test@col@hts + \if@test + \do@next\try@next@area + \else + \do@next\pretests@success@action + \fi + + \else +%<*trace> + \tr@ce{close~area:~\this@area\space float~not~allowed~ + by~ user~ control~ (\this@fps)} +%</trace> +%<*progress> + \progress@failed{\this@area\space float~not~allowed~ + by~ user~ control~ (\this@fps)} +%</progress> + \do@next\try@next@area + \fi + \fi + \fi + \fi + \else +% defer + \global\let\this@open@areas\@empty +%<*trace> + \tr@ce{defer:~max~float~num~reached ~(\pagesetup@max@float@num)} +%</trace> +%<*progress> + \progress@failed{max~float~num~reached ~(\pagesetup@max@float@num)} +%</progress> + \do@next\defer@and@try@next@float + \fi + \else +%<*trace> + \tr@ce{span~ count~ unsuitable:~ \this@area \space /=~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</trace> +%<*progress> + \progress@failed{span~ count~ \this@area \space /=~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</progress> + \do@next\try@next@area + \fi + \fi +%<*trace> + \@tracepop{std@try@this@area} +%</trace> + \do@continue +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\do@next} +% Emergency macro to reduce the number of input levels (as the code +% got past the internal default of 300). This is because we have a +% lot of recursion going on without being tail +% recursion. Essentially this means some of the code needs slightly +% different implementation.\footnote{fix} +% \begin{macrocode} +\def\do@next{\let\do@continue} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\relaxed@try@this@area} +% \begin{macrocode} +\def\relaxed@try@this@area{ +%<*trace> + \@tracepush{relaxed@try@this@area} +%</trace> +% \end{macrocode} +% If all areas for the float type are closed we have to defer this float. +% \begin{macrocode} + \ifx\this@open@areas\@empty +%<*trace> + \tr@ce{defer:~no~open~area~ available} +%</trace> + \do@next\defer@and@try@next@float + \else +% \end{macrocode} +% Otherwise the next area to try is the first of |\this@open@areas|: +% \begin{macrocode} + \setup@this@area{\expandafter\@carcube\this@open@areas\@nil} +%<*trace> + \tr@ce{area~trial:~ \this@area} +%</trace> +%<*progress> + \progress{~ area~trial:~ \this@area} +%</progress> +% \end{macrocode} +% Next test needs cleanup once the span has a decent data +% structure.\footnote{FIX!!} +% \begin{macrocode} + \ifnum \this@area@span@number = \if!\this@span@number! 1\else % big hack + \this@span@number \fi + \relax +%<*trace> + \tr@ce{span~ count~ okay:~ \this@area \space =~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</trace> +% \end{macrocode} +% +% \begin{macrocode} + \xin@\this@area\this@page@closed + \ifin@ +%<*trace> + \tr@ce{area~ closed~ for~ all~ types;~ member~ of~ + (\this@page@closed)} +%</trace> +%<*progress> + \progress@failed{area~ closed~ for~ all~ types} +%</progress> + \do@next\try@next@area + \else +%<*trace> + \tr@ce{area~ not~ closed~ for~ all~ types:~ not~ member~ of~ + (\this@page@closed)} +%</trace> + \xin@\this@area + \this@closed@areas + \ifin@ +%<*trace> + \tr@ce{area~ closed~ for~ class~ \this@class;~ member~ of~ + (\this@closed@areas)} +%</trace> +%<*progress> + \progress@failed + {area~ closed~ for~ class~ \this@class} +%</progress> + \do@next\try@next@area + \else +%<*trace> + \tr@ce{area~ open~ for~ class~ \this@class;~ not~ member~ of~ + (\this@closed@areas)} +%</trace> + \append@caption@to@float + \construct@and@test@col@hts + \if@test + \do@next\try@next@area + \else + \do@next\pretests@success@action + \fi + \fi + \fi + \else +%<*trace> + \tr@ce{span~ count~ unsuitable:~ \this@area \space /=~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</trace> +%<*progress> + \progress@failed{span~ count~ \this@area \space /=~ + \if!\this@span@number! 1\else % big hack + \this@span@number \fi} +%</progress> + \do@next\try@next@area + \fi + \fi +%<*trace> + \@tracepop{relaxed@try@this@area} +%</trace> + \do@continue +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \begin{macro}{\construct@and@test@col@hts} +% The |\construct@and@test@col@hts| loops over all columns +% affected by the float area we want to place our float into +% and reduces the column size as +% needed. It sets the switch |@test| to true in case the float +% doesn't fit into area for some reason. It is up to the calling +% macro to take proper action in this case (including resetting +% column heights to their former values). +% \begin{macrocode} +\def\construct@and@test@col@hts { +% \end{macrocode} +% We use the information from the area not from the float (which +% allows us to put small floats into larger areas. +% \begin{macrocode} + \update@this@area@columns + { + \expandafter + \construct@and@test@col@ht + \csname col@ht@ \the\count@ \endcsname + {\the\count@} +% \end{macrocode} +% We need to break out of the updating loop if we found a column that +% doesn't work, a) to save time and b) since the +% |\construct@and@test@col@ht| resets the switch again to false +% (in the current implementation). +% \begin{macrocode} + \if@test + \count@\z@ % break out of loop + \fi + } +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\construct@and@test@col@ht} +% The |\construct@and@test@col@ht| reduces the height of one column +% by the size of the current float (plus some suitable extra space) +% and tests if this reduction is possible/allowed. It sets the +% switch |@test| to true if it encounters a problem. +% \begin{macrocode} +\def\construct@and@test@col@ht#1#2{ +%<*trace> + \tr@ce{col height~before:~ \the#1 (\string#1)} +%</trace> +% \end{macrocode} +% In |\@tempdima| we calculate the amount of space we need if we +% place the float. This is the size of the float, i.e., its height +% and depth, plus either |\pagesetup@float@text@sep| if this is the +% very first float in this column (on top or on bottom), or +% |\pagesetup@float@area@sep| if it is the first float in the +% current area, or |\pagesetup@float@float@sep| if we already have +% floats in this area. +% \begin{macrocode} + \@tempdima \ht\this@captioned@float + \advance \@tempdima \dp\this@captioned@float + \ifnum \csname col@ \this@area@type + @floats@#2@number\endcsname + = \z@ +%<*trace> + \tr@ce{first~ float~ in~ any~ \this@area@type\space + in~ column~ #2:~ + adding~ \string\pagesetup@float@text@sep + =\the\pagesetup@float@text@sep} +%</trace> + \advance \@tempdima \pagesetup@float@text@sep + \else + \advance \@tempdima + \expandafter + \ifx \csname area@\this@area\endcsname\@empty + \pagesetup@float@area@sep +%<*trace> + \tr@ce{first~ float~ in~ \this@area :~ + adding~ \string\pagesetup@float@area@sep + =\the\pagesetup@float@area@sep} +%</trace> + \else + \pagesetup@float@float@sep +%<*trace> + \tr@ce{additional~ float~ in~ \this@area :~ + adding~ \string\pagesetup@float@float@sep + = \the\pagesetup@float@float@sep} +%</trace> + \fi + \fi +% \end{macrocode} +% Now we make the area size fully fall into the page grid (if there +% is one). To do this we first substract any delta that has been +% accumulated for the column (to get back to the real size) and +% then run |\snap@to@grid| to get the next grid point. +% \begin{macrocode} + \advance \@tempdima + -\csname col@ \this@area@type @delta@ #2 \endcsname \relax +% \end{macrocode} +% The |\col@|\meta{area-type}|@delta@|\meta{col} are macros but +% fortunately low-level \TeX{} supports register assignments of the +% form |--3pt| so the above will work even if the macro contains a +% negative value. +% \begin{macrocode} + \snap@to@grid \@tempdima \pagesetup@grid@point@sep +% \end{macrocode} +% +% If the distance to the next grid point is larger than the +% distance to the previous one, and if the space between floats and +% text is allowed to shrink by the needed amount we will use the +% previous grid point. +% \begin{macrocode} + \ifdim \returned@lower@delta@size < \returned@delta@size \relax + \ifdim \returned@lower@delta@size < \pagesetup@float@text@shrink +%<*trace> + \tr@ce{GRID:~ column~#2:~ choosing~ lower~ grid~ point} +%</trace> +% \end{macrocode} +% We do this by copying the |\returned@lower@...| to the macros +% used below. Note that for the delta size we have to use the +% negation since we want to backup by this amount and delta sizes +% are always given in absolute values. +% \begin{macrocode} + \global\let \returned@size \returned@lower@size + \xdef \returned@delta@size {-\returned@lower@delta@size } + \fi + \fi +%<*trace> + \tr@ce{GRID:~ column~#2:~ \the\@tempdima\space ->~ \returned@size} +%</trace> + \@tempdima \returned@size +% \end{macrocode} +% +% After updating |\@tempdima| in this way we now have to check if +% the space remaining for the text column is large enough. +% \begin{macrocode} + \@tempdimb#1 + \advance \@tempdimb -\@tempdima + \@testfalse + \ifdim \textminlines\baselineskip > \@tempdimb +% \end{macrocode} +% If not we bail out +% \begin{macrocode} + \@testtrue +%<*trace> + \tr@ce{close~area:~\this@area\space not~ enough~ text~ lines~ + left~ + (\textminlines x\the\baselineskip> \the\@tempdimb)} +%</trace> +%<*progress> + \progress@failed{not~ enough~ text~ space~ + (\textminlines x\the\baselineskip\space + >~ \the\@tempdimb)} +%</progress> + \else +% \end{macrocode} +% Otherwise we have to update the column heights (and their saved +% version in case we back out later) as well as storing the new +% delta (which is still in |\returned@delta@size|). +% \begin{macrocode} +%<*trace> + \tr@ce{saved@col@ht@ #2~ <-~\the#1} +%</trace> + \expandafter\xdef + \csname saved@col@ht@ #2\endcsname{\the#1} + \global#1\@tempdimb + \global\expandafter\let + \csname saved@col@ \this@area@type @delta@ #2 \expandafter \endcsname + \csname col@ \this@area@type @delta@ #2 \endcsname + \global\expandafter\let + \csname col@ \this@area@type @delta@ #2 \endcsname + \returned@delta@size +%<*trace> + \tr@ce{GRID (delta):~ column~#2\this@area@type:~ + \csname saved@col@ \this@area@type @delta@ #2 + \endcsname\space ->~ \returned@delta@size} +%</trace> + \fi +%<*trace> + \tr@ce{col height~after:~ \the#1} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\textminlines} +% Tmp definition; should be interfaced to pagesetup. +% \begin{macrocode} +\def\textminlines{4} +% \end{macrocode} +% \end{macro} +% +% +% +% \subsection{Supporting grid based designs} +% +% +% +% \begin{macro}{\pagesetup@grid@point@sep} +% |\pagesetup@grid@point@sep| is the distance between grid points +% for page design or 0pt if we are not doing grid design. +% \begin{macrocode} +\let\pagesetup@grid@point@sep\ERROR +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\snap@to@grid} +% |\snap@to@grid| takes a dimension as first argument and a +% ``grid-size'' as second argument and from those two values +% calculates a new dimension which is a multiple of the grid-size +% and equal or larger than the first argument. +% +% It returns this calculated value globally in |\returned@size|. In +% addition it will return in |\returned@delta@size| the delta +% between the original and the new dimension. +% +% It also returns a lower or equal grid point in +% |\returned@lower@size| and the delta to it (absolute value) in +% |\returned@lower@delta@size|. +% +% Thus the first argument lies on a grid point if and only if +% |\returned@size| equals |\returned@lower@size|. +% +% If we are not doing grid typesetting then |\snap@to@grid| is +% actually a dummy which will return always the first argument in +% |\returned@size| and |\returned@lower@size|, and |0pt| in the +% deltas. +% +% The actual definition is assigned within the page setup. +% \begin{macrocode} +\let\snap@to@grid\ERROR +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\dummy@snap@to@grid} +% In case we don't do grids we simply pretend that all sizes lie on +% grid points. +% \begin{macrocode} +\def \dummy@snap@to@grid #1#2{ + \begingroup +% \end{macrocode} +% Definitions below can be optimised for speed but the ones used +% give better tracing. +% \begin{macrocode} + \@tempdima #1 \relax + \xdef \returned@size { \the\@tempdima } + \global\let \returned@lower@size \returned@size + \gdef \returned@delta@size {0pt} + \global\let \returned@lower@delta@size \returned@delta@size + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\std@snap@to@grid} +% But if we do grid typesetting we have to do a bit more work +% here. +% \begin{macrocode} +\def \std@snap@to@grid #1#2{ +% \end{macrocode} +% Everything is done in a group so that the register change do not +% affect other parts of the code. +% \begin{macrocode} + \begingroup +% \end{macrocode} +% First we calculate in |\@tempdimc| the nearest grid point which +% is smaller or equal to the given size in |#1| by using scaled +% point arithmetic. +% \begin{macrocode} + \@tempdima #1\relax + \@tempdimb #2\relax + \@tempcnta \@tempdima % orig size in sp + \@tempcntb \@tempdimb % grid size in sp + \divide \@tempcnta \@tempcntb + \@tempdimc \@tempcnta\@tempdimb +% \end{macrocode} +% If the calculated grid point is smaller than the original +% dimension use the next larger one. But record the other in +% |\returned@lower@size|. +% \begin{macrocode} + \ifdim \@tempdimc < \@tempdima + \xdef \returned@lower@size { \the\@tempdimc } + \advance\@tempdimc \@tempdimb + \fi +% \end{macrocode} +% The |\returned@size| will be whatever the result of the above is +% and |\returned@delta@size| the difference to the given value in +% |#1|. Note that |\returned@size| will always be larger or equal +% to this value so the difference computed below will also be +% non-negative! +% \begin{macrocode} + \xdef \returned@size { \the\@tempdimc } + \advance \@tempdimc -\@tempdima + \xdef \returned@delta@size { \the\@tempdimc } +% \end{macrocode} +% Now if this difference turns out to be zero then we actually +% started with a dimension exactly on a grid point. In this case we +% better define both |\returned@lower@size| and +% |\returned@lower@delta@size| to equal their counterparts. +% \begin{macrocode} + \ifdim \@tempdimc = \z@ + \global \let \returned@lower@size \returned@size + \global \let \returned@lower@delta@size \returned@delta@size +% \end{macrocode} +% Otherwise we only have to compute |\returned@lower@delta@size| +% since in that case we already recorded |\returned@lower@size| +% above (and we better had since by now we lost this information as +% we reused |\@tempdimc|). Now the value for this macro should be +% the difference between |\returned@delta@size| and our grid size +% both of which are already stored in some temp registers, +% thus\ldots +% \begin{macrocode} + \else + \advance\@tempdimb-\@tempdimc + \xdef \returned@lower@delta@size { \the\@tempdimb } + \fi + \endgroup +%<*trace> + \tr@ce{GRID:~ \string\returned@lower@size=\returned@lower@size} + \tr@ce{GRID:~ \string\returned@lower@delta@size=\returned@lower@delta@size} + \tr@ce{GRID:~ \string\returned@size=\returned@size} + \tr@ce{GRID:~ \string\returned@delta@size=\returned@delta@size} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% \subsection{Deferring a float} +% +% +% +% \begin{macro}{\really@defer@and@try@next@float} +% \begin{macrocode} +\def\really@defer@and@try@next@float{ +%<*progress> + \progress@failed{-->~ defer} + \progress@nl{} +%</progress> + \@cons\area@ddd\this@float@box +%<*trace> + \tr@ce{this@page@closed~ <-~ "\this@page@closed"~ +~ + "\pagesetup@ddd@all@close"} +%</trace> + \xdef\this@page@closed{\this@page@closed, + \pagesetup@ddd@all@close} + + \ifx\pagesetup@ddd@class@close\pagesetup@area@list +%<*trace> + \tr@ce{this@closed@areas~ <-~ + "\pagesetup@ddd@class@close"~ (all~ closed)} +%</trace> + \global\let\this@closed@areas\pagesetup@ddd@class@close + \else +%<*trace> + \tr@ce{this@closed@areas~ <-~ "\this@closed@areas"~ +~ + "\pagesetup@ddd@class@close"} +%</trace> + \xdef\this@closed@areas{\this@closed@areas, + \pagesetup@ddd@class@close} + \fi + + \global\expandafter\let\csname closed@\this@class + @areas\endcsname % FMi tmp + \this@closed@areas + \try@next@float +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\defer@and@try@next@float} +% +% This code either defers the current float and restarts by calling +% |\try@next@float| or recurses after relaxing the placement +% conditions (in case the current float should be flushed). +% +% If the placement conditions are already relaxed we move the first +% flush point that affects the current float one column forward and +% then retry. This might result in succeding to place the float, if +% not it will ultiamtely result in the flush point being moved from +% the page at which point the float can be deferred. +% +% \begin{macrocode} +\def\defer@and@try@next@float{ +%<*trace> + \@tracepush{defer@and@try@next@float} +%</trace> +% \end{macrocode} +% If there have been no flush points or if the flush points seen do +% not affect the current float we can immediately defer it. +% \begin{macrocode} + \if@flushseen + \xin@\this@class\flush@classes@list@max + \ifin@ +%<*trace> + \tr@ce{flush:~ class~ \this@class\space in~ + \flush@classes@list@max} +%</trace> +% \end{macrocode} +% First test is just there to avoid doing any of the loops +% (might not be worth having) +% \begin{macrocode} + \ifnum \csname flush@min@col@1\endcsname > \curr@col@count +%<*trace> + \tr@ce{flush:~ no~ flush~ points~ on~ page;~ defer} +%</trace> + \do@next\really@defer@and@try@next@float + \else +% \end{macrocode} +% +% The code is often invoked before there is an attempt to split the +% galley; this means we don't know which flush point affects the +% current float and thus have to manually get at it. +% +% So we loop through the |\flush@last@float@|\meta{num} values to +% find the first one that a) affects the current float type and b) +% holds a sequence number that is higher or equal to the sequence +% number of the current float. +% \begin{macrocode} + \count@ \@ne + \loop +% \end{macrocode} +% If |\count@| is greater than |\flush@seq@num| we have exhausted +% all possible flush points without finding a candidate. +% \begin{macrocode} + \ifnum \flush@seq@num < \count@ + \in@false + \else +% \end{macrocode} +% Otherwise, if |\this@sequence@number| is greater than +% |\flush@last@float@|\meta{num} the current flush point is before +% the call-out to the current float. +% \begin{macrocode} +%<*trace> + \tr@ce{flush:~ \this@sequence@number \space ???~ + \csname flush@last@float@ \the\count@ \endcsname} +%</trace> + \ifnum \this@sequence@number > + \csname flush@last@float@ \the\count@ \endcsname + \relax +% \end{macrocode} +% We set |\in@true| to get a repeat below with a new value of +% |\count@|. +% \begin{macrocode} + \in@true + \else +% \end{macrocode} +% Otherwise we have a flush point that is later in the galley in +% comparison to the call-out of the current float thus potentially +% affects it. Therefore we now have to check if the sequence class +% of the current float is affected by the flush point found: +% \begin{macrocode} + \expandafter\xin@\expandafter\this@class + \csname flush@classes@list@ \the\count@ \endcsname +% \end{macrocode} +% Now we could make good use of the |\unless| primitive of +% e\TeX. But since we want to run with standard \TeX{} and don't +% have |\xnotin@| available we invert the result. +% \begin{macrocode} + \ifin@ + \in@false + \else + \in@true +%<*trace> + \tr@ce{flush:~ class~ \this@class\space not~ in~ + \csname flush@classes@list@ \the\count@ \endcsname + \space (ignored) + } +%</trace> + \fi + \fi + \fi + \ifin@ + \advance\count@\@ne + \repeat +%<*trace> + \tr@ce{flush:~ first~ float~ point~ after~ float~ =~ + \the\count@} +%</trace> + \ifnum \flush@seq@num < \count@ +%<*trace> + \tr@ce{flush:~ this~ float~ past~all~flush~ points;~ defer} +%</trace> + \do@next\really@defer@and@try@next@float + \else +% \end{macrocode} +% Once a |flush@min@col| is larger than |\curr@col@count| it has +% moved to the next page. In particular this is true for the +% artificial value |\maxdimen| to which it is sometimes set to +% denote this fact. If so we can defer our float. +% \begin{macrocode} + \ifnum \csname flush@min@col@\the\count@\endcsname + > \curr@col@count +%<*trace> + \tr@ce{flush:~ float~ past~ all~ flush~ points~ + on~ current~ page;~ defer} +%</trace> + \do@next\really@defer@and@try@next@float + \else +% \end{macrocode} +% If we have already relaxed the conditions and we are still in +% conflict with a flush point on the current page we nearly ran out +% of options. In this case we are forced to move the flush point, +% but rather than moving it to the next page and defering the float +% we can move it one column further (which might make it fall off +% the page though) and then retry to place the float since we have +% now more space available. +% \begin{macrocode} + \ifx\try@this@area\relaxed@try@this@area +%<*trace> + \tr@ce{flush:~ defer~ forced;~ move~ + flush~ point~ columns} +%</trace> +%<*progress> + \progress@nl{} + \progress@nl{Flushing~ impossible~ -->~ breaking~ + before~ flush~ point~ and~ retry} +%</progress> +% \end{macrocode} +% We should only increment the |flush@min@col@| value of the first +% flush point that affects our float (this will automatically move +% later flush points if necessary). Incrementing the later ones is +% incorrect as they might not need moving! +% \begin{macrocode} + \expandafter \gincrement@num + \csname flush@min@col@ \the\count@ \endcsname +%<*trace> + \tr@ce{flush@min@col@\the\count@ \space <-~ + \csname flush@min@col@ \the\count@ \endcsname + } +%</trace> +%<*progress> + \progress@nl{} + \progress@nl{Defer~ impossible~ -->~ moving~ + flush~ point~ to~ column~ + \csname flush@min@col@ \the\count@\endcsname + \space + and~ retry} +%</progress> +% \end{macrocode} +% Not clear that it is really necessary to check all areas again, +% but it is late (after midnight) and it is definitely not +% wrong.\footnote{Check!} +% \begin{macrocode} + \relax@float@placement@conditions % needed to reset open areas + \do@next\try@this@area + + \else +% \end{macrocode} +% +% \begin{macrocode} + \relax@float@placement@conditions + \do@next\try@this@area + \fi + \fi + \fi + \fi + \else +%<*trace> + \tr@ce{flush:~ class~ \this@class\space not~ in~ + \flush@classes@list@max;~ defer} +%</trace> + \do@next\really@defer@and@try@next@float + \fi + + \else +%<*trace> + \tr@ce{flush:~ no~ flush~ point~ seen; defer} +%</trace> + \do@next\really@defer@and@try@next@float + \fi + +%<*trace> + \@tracepop{defer@and@try@next@float} +%</trace> + \do@continue +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\relax@float@placement@conditions} +% \begin{macrocode} +\def \relax@float@placement@conditions { +%<*progress> + \progress@failed{-->~ retry~ with~ relaxed~ conditions} + \progress@nl{} +%</progress> +%<*trace> + \tr@ce{flush:~relax~placement~conditions} +%</trace> + \global\let\try@this@area\relaxed@try@this@area +% next line perhaps external? + \global\let\this@open@areas\saved@this@open@areas + + \global\let\check@some@constraints\relaxed@check@some@constraints + \global\let\check@callout@constraints\relaxed@check@callout@constraints + \global\let\calculate@target@fl@column\relaxed@calculate@target@fl@column +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tighten@float@placement@conditions} +% \begin{macrocode} +\def\tighten@float@placement@conditions { +%<*trace> + \tr@ce{flush:~tighten~placement~conditions} +%</trace> + \global\let\try@this@area\std@try@this@area + + \global\let\check@some@constraints\std@check@some@constraints + \global\let\check@callout@constraints\std@check@callout@constraints + \global\let\calculate@target@fl@column\std@calculate@target@fl@column +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\partly@tighten@float@placement@conditions} +% This is used when we have placed the last float that is affected +% by a certain flush point. We don't want to tighten up completely +% since this would essentially mean that we can't place any further +% floats since callout relationships etc might be violated for +% them. Good question is whether or not the last restriction should +% be used again since this too might prevent any further placements. +% \begin{macrocode} +\def\partly@tighten@float@placement@conditions { +%<*trace> + \tr@ce{flush:~partly~tighten~placement~conditions} +%</trace> + \global\let\try@this@area\std@try@this@area + +% \global\let\check@some@constraints\std@check@some@constraints +% \global\let\check@callout@constraints\std@check@callout@constraints + \global\let\calculate@target@fl@column\std@calculate@target@fl@column +} +% \end{macrocode} +% \end{macro} +% +% +% +% \subsection{Checking float placement during trial} +% +% The interface to checking float placement in relation to its callout +% is the following piece of code in |\grab@column@or|: +%\begin{verbatim} +% \let\@elt\check@callout@constraints +% \float@classes@list +%\end{verbatim} +% This loops through all float types and executes +% |\check@callout@constraints| with the float type as an argument. The output +% routine |\grab@column@or| itself is called for each column of a trial +% configuration, thus the above loop is called for each column +% individually (|\curr@col@count| can be used to determine the current +% column number). +% +% By giving |\check@callout@constraints| an appropriate definition a +% pagesetup template can implement different relationships between +% callout and float. +% +% Possible tests (getting stronger): +% \begin{itemize} +% +% \item +% Don't check, i.e., add the float when you find it and it fits +% according to other criteria (like number of floats in the area, +% etc.). This is implemented in |\check@callout@none|. +% +% +% \item +% Check if callouts for all floats on the page (not column) are +% either on the same page or on an earlier page; i.e., callout can be +% late as long as the float is visible from the callout. +% +% Fail if for last column and all float types: +% last callout number for float type is smaller than maximum last float +% of type put into any column.\footnote{This description is +% probably wrong} +% +% This is implemented in |\check@callout@page|. +% +% \item +% Check if callouts for all floats in the column are either on the +% same column or on an earlier column. +% +% Fail if for any column and any float type: +% last callout number for float type is smaller last float sequence +% number for type recorded for this column. +% +% This case consists in fact of two subcases depending on how we +% interpret to which column a spanning float belongs. If we claim +% that a spanning float is placed into its starting column, then we +% fail if its call-out is in a later column even though this column +% might still be spanned by the float area. +% +% This is implemented in |\check@callout@column|. +% +% \item +% Check if callouts for all floats in the column are on an earlier +% column or if on the same column the float was added to the bottom +% (or marginal) area; i.e. strict float/callout order +% +% Fail if for each type and for any column: +% `top' callout number less than `top' float number +% (at top of text column) +%\begin{verbatim} +% [Corectness proof: +% TRUE => first callout's float comes before bottom +% and so comes too early +% => FAIL +% FALSE => first callout's float comes in bottom and all other +% callouts come later and so are in bottom or beyond +% => OK +% ] +%\end{verbatim} +% The proof above is in fact only valid if you look at the whole +% document and not only at a single page since a float in the bottom +% area of the last column with its callout on the next page will +% only be detected when testing the next page. Therefore one needs +% an additional check of type |\check@callout@column|. +% +% This is implemented in |\check@callout@after|. +% +% +% \end{itemize} +% +% +% \begin{macro}{\check@callout@none} +% This test is an easy one: just do nothing, i.e., gobble the argument. +% \begin{macrocode} +\let\check@callout@none\@gobble +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\check@callout@page} +% We are are only interested in the callout/float relation per page +% we only have to do a check when producing the last column, i.e., +% when |\curr@col@count| is |\col@count|. +% \begin{macrocode} +\def\check@callout@page#1{ +%<*trace> + \@tracepush{check@callout@page} +%</trace> + \ifnum\curr@col@count=\col@count +% \end{macrocode} +% We store in |\fl@max| the highest sequence number for floats of +% the current type up to the end of the page. For this we have to +% find the maximum of |\fl@0@|\meta{type} (highest float number on +% previous pages) and those for the columns, e.g., +% |\fl@|\meta{colnum}|@|\meta{type}; this is done by the following +% code: +% \begin{macrocode} + \global\expandafter\let\expandafter\fl@max + \csname fl@0@#1\endcsname + \forall@columns { + \ifnum\csname fl@\the\curr@col@count @#1\endcsname>\fl@max\relax + \xdef\fl@max{\csname fl@\the\curr@col@count @#1\endcsname} + \fi + } +% \end{macrocode} +% We then store the number of the last callout in |\count@|; the +% |0| will take care of the potential problem that there was never any +% callout so far. And we better have a |\relax| afterwards since +% otherwise we will expand the |\ifnum| before we have finished +% assigning the |\count@|. +% \begin{macrocode} + \count@0\LastMark{#1}\relax +%<*trace> + \tr@ce{Last~callout~ (#1)~ =~ \the\count@} +%</trace> +% \end{macrocode} +% Now we have to compare those two numbers to find out if that +% trial has failed: +% \begin{macrocode} + \ifnum\count@<\fl@max\relax + \@failtrue +%<*progress> + \progress@failed{last~callout~ + \the\count@\space~<~\fl@max + \space last~float~put~on~page~or~ earlier} +%</progress> +%<*trace> + \tr@ce{Failed:~(#1)~ last~callout~ + \the\count@\space~<~\fl@max + \space last~float~put~on~page~or~ earlier} + \else + \tr@ce{OK:~(#1)~ last~callout~ + \the\count@\space~>=~\fl@max + \space last~float~put~on~page~or~ earlier} +%</trace> + \fi + \fi +%<*trace> + \@tracepop{check@callout@page} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% \begin{macro}{\fl@max} +% The macro |\fl@max| is used within |\check@callout@page| to hold +% the highest sequence number of any allocated float on the current +% page for the type under testing. It will be recalculated on +% each pass.\footnote{One could generate this value while running through +% the trials --- this would perhaps be a bit more time efficient.} +% \begin{macrocode} +\let\fl@max\ERROR +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\check@callout@column} +% Checking each column separately means we have to compare for each +% type the last callout on this or previous columns (i.e., as +% returned by |\LastMark|) with the highest sequence number for +% floats of this type in the current column (as stored in +% |fl@|\meta{col}|@|\meta{type}). So we first store the callout +% info in |\count@|. +% \begin{macrocode} +\def\check@callout@column#1{ +%<*trace> + \@tracepush{check@callout@column} +%</trace> + \count@0\LastMark{#1}\relax +% \end{macrocode} +% Then we do the test. If there are no floats of the current type +% in the current column |\fl@|\meta{col}|@|\meta{type} will be zero +% and thus the following test will come out true. This is the +% correct behaviour as any callouts that might be present will be +% correctly evaluated in tests on neighboring columns with floats. +% \begin{macrocode} + \ifnum\count@<\csname fl@\the\curr@col@count @#1\endcsname\relax +%<*progress> + \progress@failed{last~ callout~ + \the\count@\space <~ + \csname fl@\the\curr@col@count @#1\endcsname + \space last~ float~ placed~ in~ column~ \the\curr@col@count} +%</progress> +%<*trace> + \tr@ce{Failed:~(#1)~ last~ callout~ + \the\count@\space <~ + \csname fl@\the\curr@col@count @#1\endcsname + \space last~float~placed} +%</trace> +% \end{macrocode} +% If the test fails we abort this trial by setting the switch +% |@fail| to true. We also set +% |\curr@col@count| to |\col@count| which will save us any further +% iteration (in case this wasn't the last column). Finally we +% locally set |\@elt| to |\@gobble| which will essentially about +% the current loop through the |\float@classes@list|. +% \begin{macrocode} + \@failtrue + \global\curr@col@count\col@count + \let\@elt\@gobble +% \end{macrocode} +% Otherwise the constraints for callout of current float type are +% met so we report this fact if we do tracing. +% \begin{macrocode} +%<*trace> + \else + \tr@ce{OK:~(#1)~ last~ callout~ + \the\count@\space >=~ + \csname fl@\the\curr@col@count @#1\endcsname + \space last~float~placed} +%</trace> + \fi +%<*trace> + \@tracepop{check@callout@column} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\check@callout@after} +% +% \begin{macrocode} +\def\check@callout@after#1{ +%<*trace> + \@tracepush{check@callout@after} +%</trace> +% \end{macrocode} +% +% We first check if all floats are either on the same column than +% their callout or on an later column by calling +% |\check@callout@column|. If this returns |@fail| we immediately +% abort any further processing. +% \begin{macrocode} + \check@callout@column{#1} + \if@fail\else +% \end{macrocode} +% +% If the above check found no violation we have to check for top +% area floats that might preceed their callouts. +% +% For this we look at the value of the +% |\tfl@|\meta{col}|@|\meta{float-type} macro which holds the +% highest float sequence number for floats of this type allocated +% in that column. +% \begin{macrocode} + \global\expandafter\let\expandafter + \returned@sequence@number + \csname tfl@\the\curr@col@count @#1\endcsname +% \end{macrocode} +% +% If there was no float in the top area we get |0| back and in +% that case we are done since all our constraints are met. +% \begin{macrocode} + \ifnum \returned@sequence@number = \z@ +%<*trace> + \tr@ce{OK:~(#1)~ top~ areas~ have~ no~ floats} +%</trace> + \else +% \end{macrocode} +% +% Otherwise we have to look at the top callout number and compare +% it to the last float number of the top area. +% \begin{macrocode} + \count@ 0\PreviousMark{#1}\relax +% \end{macrocode} +% If that callout number is less than the last float number we +% failed since this means that there is a float in the top area +% which callout has not yet been seem. So we abort the +% trial. Otherwise our constraints are met. +% \begin{macrocode} + \ifnum \count@ < \returned@sequence@number \relax +% \end{macrocode} +% But before aborting we give some information on why we +% failed. This has to come first since we change |\curr@col@count| +% below. +% \begin{macrocode} +%<*progress> + \progress@failed{top~ callout~ + \the\count@\space <~ \returned@sequence@number + \space last~ float~ put~ in~ top~ + of~ column~ \the\curr@col@count} +%</progress> + \@failtrue + \global\curr@col@count\col@count + \let\@elt\@gobble +%<*trace> + \tr@ce{Failed:~(#1)~ top~ callout~ + \the\count@\space <~ \returned@sequence@number + \space last~float~put~in~top} + \else + \tr@ce{OK:~(#1)~ top~ callout~ + \the\count@\space >=~ \returned@sequence@number + \space last~float~put~in~top} +%</trace> + \fi + \fi + \fi +%<*trace> + \@tracepop{check@callout@after} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% +% +% \subsection{Checking bottom float footnote constraints} +% +% In |\grab@column@or|, the output routine that grabs a single column +% during a trial, we have the command |\check@some@constraints| which +% allows to check some constraints and if they aren't met is supposed +% to set the switch |@fail|. +% +% This can, for example be used to implement a constraint that bottom +% floats are only allowed if there are no footnotes in the current +% column.\footnote{At the moment this is restricted to single column +% floats. Spanning floats are always allowed.} +% +% \begin{macro}{\check@float@footnote@forbidden} +% The command |\check@float@footnote@forbidden| is the +% implementation for |\check@some@constraints| that prevents bottom +% floats if the current column contains footnotes. +% \begin{macrocode} +\def\check@float@footnote@forbidden{ +%<*trace> + \@tracepush{check@float@footnote@forbidden} +%</trace> + \ifvoid\footins + \else +% \end{macrocode} +% If the current column contains footnotes and we have bottom +% floats we fail. First we check if there is a bottom area for this +% column defined if not we pretend there is an empty one. +% \begin{macrocode} + \expandafter + \ifx \csname area@b\the\curr@col@count1\endcsname + \relax + \global\expandafter\let + \csname area@b\the\curr@col@count1\endcsname + \@empty + \fi +% \end{macrocode} +% Then we check if the bottom area is empty and fail otherwise +% \begin{macrocode} + \expandafter + \ifx \csname area@b\the\curr@col@count1\endcsname + \@empty +%<*trace> + \tr@ce{OK:~ no~ old~ bottom~ floats} +%</trace> + \else +%<*progress> + \progress@failed{old~bottom~floats:~ \expandafter\meaning + \csname area@b\the\curr@col@count1\endcsname} +%</progress> +%<*trace> + \tr@ce{Failed:~ old~bottom~floats:~ \expandafter\meaning + \csname area@b1\the\curr@col@count\endcsname} +%</trace> + \@failtrue + \fi +% \end{macrocode} +% Finally we test if the float we are try to place is going onto a +% bottom area. +% +% However we only do this if the float doesn't span.\footnote{Extend?} +% \begin{macrocode} + \ifnum \this@area@span@number = \@ne +%<*trace> + \tr@ce{this@area,column:~ \this@area,~\the\curr@col@count} +%</trace> + \if b \this@area@type + \ifnum \this@area@col@number = \curr@col@count + \@failtrue + \fi + \fi + \fi + \if@fail +%<*progress> + \progress@failed{column~ \the\curr@col@count\space + contains~ footnotes~ and~ bottom~ floats} +%</progress> +%<*trace> + \tr@ce{Failed:~ column~ \the\curr@col@count\space + contains~ footnotes~ and~ bottom~ floats} +%</trace> + \global\curr@col@count\col@count + \fi + \fi +%<*trace> + \@tracepop{check@float@footnote@forbidden} +%</trace> +} +% \end{macrocode} +% \end{macro} +% +% +% \begin{macro}{\check@float@footnote@none} +% +% This is the implementation for |\check@some@constraints| if we +% don't care about mixing footnotes and bottom floats. The reason +% |\@empty| rather than |\relax| is used is that otherwise the +% |\ifx| test in the template would fail. +% \begin{macrocode} +\let\check@float@footnote@none\@empty +% \end{macrocode} +% \end{macro} +% +% +% +% +% +% +% \endinput +\endinput +% +% $Log: xo-place.dtx,v $ +% Revision 1.37 2000/08/11 07:14:28 latex3 +% added header +% +% Revision 1.36 2000/08/11 06:49:47 latex3 +% untabify +% +% Revision 1.35 2000/08/11 06:45:03 latex3 +% only partially tighten float constraints after passing a flush point +% +% Revision 1.34 2000/07/23 21:03:19 latex3 +% removed obsolete commentary +% +% Revision 1.33 2000/07/21 13:53:17 latex3 +% more renaming for float sequence class concept +% +% Revision 1.32 2000/07/18 21:06:36 latex3 +% introduced float sequence classes +% +% Revision 1.31 2000/07/12 17:24:53 latex3 +% more support for grids +% +% Revision 1.30 2000/07/10 21:00:57 latex3 +% support for grid typesetting +% +% Revision 1.29 2000/07/04 19:42:05 latex3 +% fix tracing for GRID stuff +% +% Revision 1.28 2000/07/01 15:57:25 latex3 +% use \update@this@area@columns +% integrate code to support grid design (first draft) +% +% Revision 1.27 2000/06/29 17:18:14 latex3 +% introduced \setup@this@area +% +% Revision 1.26 2000/06/26 15:03:40 latex3 +% making prototype for \pagesetup@float@area@sep +% +% Revision 1.25 2000/06/22 20:08:09 latex3 +% renamed some macros to get them more uniform +% +% Revision 1.24 2000/06/22 11:01:24 latex3 +% When substracting heights from columns do this for the columns spanned +% by the area. Don't use the span number from the float (in the future +% this might be smaller than the span number of the area) +% +% Revision 1.23 2000/06/19 21:38:04 latex3 +% fixed flush point handling when deferring +% +% Revision 1.22 2000/06/18 19:03:53 latex3 +% added "Checking bottom float footnote constraints" from xo-page +% +% Revision 1.21 2000/06/16 11:20:15 latex3 +% rename \construct@and@test@col@height to \construct@and@test@col@ht +% rename \construct@and@test@col@heights to \construct@and@test@col@hts +% rename \cl@height1 to \@col@ht@1 (etc) +% +% Revision 1.20 2000/06/16 11:06:37 latex3 +% support float-callout-span-constraint +% +% Revision 1.19 2000/06/16 07:49:49 latex3 +% improve progress info +% +% Revision 1.18 2000/06/15 17:49:02 latex3 +% moved macros from xo-page into here since they deal with placement +% +% Revision 1.17 2000/06/15 15:23:32 latex3 +% implemented new semantics for area names +% +% Revision 1.16 2000/06/13 20:48:18 latex3 +% docu update +% +% Revision 1.15 2000/06/06 12:50:40 latex3 +% before attempting fuzzy flushpoints +% +% Revision 1.14 2000/05/03 18:57:56 latex3 +% provide \construct@and@test@col@heights subroutine +% +% fix problem that deferred floats would not stop other floats going +% into earlier areas +% +% Revision 1.13 2000/03/31 17:08:50 latex3 +% avoid using up too much input stack by using tail recursion in +% strategic places (tmp fix) +% +% Revision 1.12 2000/03/26 21:04:03 latex3 +% some renaming of macros +% +% Revision 1.11 2000/03/24 15:34:27 latex3 +% version that starts supporting spans (still a hack yet) +% +% Revision 1.10 2000/03/22 15:52:37 latex3 +% some normalisations of names +% first go at spans (tmp version) +% +% Revision 1.9 2000/03/17 20:23:11 latex3 +% more fixes to flushing (looks good now) +% +% Revision 1.8 2000/03/16 10:28:29 latex3 +% partial and full flush working for the first time +% +% Revision 1.7 2000/03/05 19:31:56 latex3 +% some renaming +% extend to multiple columns (6 max right now) +% fix defer logic: when flushseen don't defer immediately +% +% Revision 1.6 2000/02/27 15:12:45 david +% *** empty log message *** +% +% Revision 1.5 2000/02/27 11:27:45 david +% first attempt at flush floats +% +% Revision 1.4 2000/02/26 18:24:21 david +% renaming, and using \initialise@areas +% +% Revision 1.3 2000/02/16 13:40:09 latex3 +% added 3col support +% +% Revision 1.2 2000/02/16 10:10:43 latex3 +% added documentation +% added test for float area size after adding float +% +% Revision 1.1 2000/02/13 22:27:39 latex3 +% Initial revision +% diff --git a/Master/texmf-dist/source/latex3/xor/xo-trace.dtx b/Master/texmf-dist/source/latex3/xor/xo-trace.dtx new file mode 100644 index 00000000000..435994f1682 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo-trace.dtx @@ -0,0 +1,140 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xo-trace.dtx,v 1.9 2000/08/11 07:14:29 latex3 Exp $ +% \end{macrocode} +% +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% \begin{macrocode} +\def\showmarks{ + \toks@\expandafter{\topmark}\typeout{topmark:\the\toks@} + \toks@\expandafter{\firstmark}\typeout{firstmark:\the\toks@} + \toks@\expandafter{\botmark}\typeout{botmark:\the\toks@} +} +% \end{macrocode} +% +% \begin{macrocode} +\def\showfloatlists{{ + \let\@elt\@empty + \typeout{free:~\@freelist} + \typeout{active:~\@activelist} + \typeout{mvl:~\@mvllist} + \typeout{defer:~\area@ddd} + \typeout{assigned:} + \showfloatarea{t13} + \showfloatarea{t12} + \showfloatarea{t22} + \showfloatarea{t11} + \showfloatarea{t21} + \showfloatarea{t31} + \showfloatarea{b11} + \showfloatarea{b21} + \showfloatarea{b31} + \edef\@tempa{currbox\expandafter\strip@prefix\meaning\@currbox>\space + this@float\expandafter\strip@prefix\meaning\this@float@box>} + \show\@tempa}} + +\def\showfloatarea#1{ + \@ifundefined{area@#1}{} + {\expandafter + \ifx\csname area@#1\endcsname\@empty + \else + \typeout{~\space\space #1:~\csname area@#1\endcsname} + \fi + } +} +% \end{macrocode} +% +% \begin{macrocode} +%<*trace> +\def \@tracemessage #1{% + \begingroup\let\@elt\space\typeout{:~\tf@indent~#1}\endgroup} +% \end{macrocode} +% +% \begin{macrocode} +\let\tf@indent\@empty +% \end{macrocode} +% +% \begin{macrocode} +\def\@tracepush#1{% + \tr@ce{entering~#1} + \xdef\tf@indent{-\tf@indent}} +% \end{macrocode} +% +% \begin{macrocode} +\def\@tracepop#1{% + \tr@ce{leaving~#1} + \xdef\tf@indent{\expandafter\@gobble\tf@indent}} +% \end{macrocode} +% +% \begin{macrocode} +\def \tracefloats{\global\let \tr@ce \@tracemessage} +% \end{macrocode} +% +% \begin{macrocode} +\def \notrace {\global\let \tr@ce \@gobble} +%\notrace +% \end{macrocode} +% +% \begin{macrocode} +% \end{macrocode} +% +% \begin{macrocode} +\def\traceonly#1{ + \notrace + \def\@trace@command{#1} + \gdef\@tracepush##1{ + \def\@trace@this{##1} + \ifx\@trace@this\@trace@command + \global\let\@this@tf@indent\tf@indent + \tracefloats + \tr@ce{entering~##1} + \fi + \xdef\tf@indent{-\tf@indent}} + \def\@tracepop##1{ + \tr@ce{leaving~##1} + \xdef\tf@indent{\expandafter\@gobble\tf@indent} + \ifx\@this@tf@indent\tf@indent + \global\let\@this@tf@indent\relax + \notrace + \fi} +} +% \end{macrocode} +% +% \begin{macrocode} +\tracefloats +% \end{macrocode} +% +% \begin{macrocode} +\def \@traceval #1{\tr@ce{\string #1~=~\the #1}} +%</trace> +%<-trace>\let\tr@ce\@gobble +% \end{macrocode} +% +% \begin{macrocode} +%<*progress> +\def \progress #1{\message{#1}} +\def \progress@separator{ + \progress{=============================== + ========================================^^J}} +\def \progress@nl #1{\progress{~ #1^^J}} +\def \progress@failed #1{\progress@nl{ ->~ failed:~ #1}} +%</progress> +% \end{macrocode} diff --git a/Master/texmf-dist/source/latex3/xor/xo.ins b/Master/texmf-dist/source/latex3/xor/xo.ins new file mode 100644 index 00000000000..be726b76dfa --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xo.ins @@ -0,0 +1,40 @@ +% +% $Id: xo.ins,v 1.4 2000/08/05 09:43:49 latex3 Exp $ + +\input docstrip +\keepsilent +\askforoverwritefalse + +\preamble + +Not for distribution + +(C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +All rights reserved. + +Not for general distribution. In its present form it is not allowed +to put this package onto CD or an archive without consulting the +the authors. +\endpreamble + + + +\generate{% + \file{xmarks.sty}{\from{xmarks.dtx}{package}} + \file{xo-alloc.sty}{\from{xo-alloc.dtx}{package}} + \file{xo-capt.sty}{\from{xo-capt.dtx}{package}} + \file{xo-final.sty}{\from{xo-final.dtx}{package}} + \file{xo-float.sty}{\from{xo-float.dtx}{package}} + \file{xo-grid.sty}{\from{xo-grid.dtx}{package}} + \file{xo-here.sty}{\from{xo-here.dtx}{package}} + \file{xo-new.sty}{\from{xo-new.dtx}{package}} + \file{xo-or.sty}{\from{xo-or.dtx}{package}} + \file{xo-page.sty}{\from{xo-page.dtx}{package}} + \file{xo-place.sty}{\from{xo-place.dtx}{package}} + \file{xo-trace.sty}{\from{xo-trace.dtx}{package,trace}} + \file{xoutput.sty}{\from{xoutput.dtx}{package}} +} + +\endbatchfile + +% \file{xo-implement.sty}{\from{xo-implement-generic-algorithm.dtx}{package}} diff --git a/Master/texmf-dist/source/latex3/xor/xoprogress.ins b/Master/texmf-dist/source/latex3/xor/xoprogress.ins new file mode 100644 index 00000000000..307853273dd --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xoprogress.ins @@ -0,0 +1,40 @@ +% +% $Id: xoprogress.ins,v 1.3 2000/08/04 15:54:51 latex3 Exp $ + +\input docstrip +\keepsilent +\askforoverwritefalse + +\preamble + +Not for distribution + +(C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +All rights reserved. + +Not for general distribution. In its present form it is not allowed +to put this package onto CD or an archive without consulting the +the authors. +\endpreamble + + + +\generate{% + \file{xmarks.sty}{\from{xmarks.dtx}{package}} + \file{xo-alloc.sty}{\from{xo-alloc.dtx}{package,progress}} + \file{xo-capt.sty}{\from{xo-capt.dtx}{package,progress}} + \file{xo-final.sty}{\from{xo-final.dtx}{package,progress}} + \file{xo-float.sty}{\from{xo-float.dtx}{package,progress}} + \file{xo-grid.sty}{\from{xo-grid.dtx}{package,progress}} + \file{xo-here.sty}{\from{xo-here.dtx}{package,progress}} + \file{xo-new.sty}{\from{xo-new.dtx}{package,progress}} + \file{xo-or.sty}{\from{xo-or.dtx}{package,progress}} + \file{xo-page.sty}{\from{xo-page.dtx}{package,progress}} + \file{xo-place.sty}{\from{xo-place.dtx}{package,progress}} + \file{xo-trace.sty}{\from{xo-trace.dtx}{package,progress,trace}} + \file{xoutput.sty}{\from{xoutput.dtx}{package,progress}} +} + +\endbatchfile + +% \file{xo-implement.sty}{\from{xo-implement-generic-algorithm.dtx}{package,progress}} diff --git a/Master/texmf-dist/source/latex3/xor/xotrace.ins b/Master/texmf-dist/source/latex3/xor/xotrace.ins new file mode 100644 index 00000000000..7c5f971dcce --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xotrace.ins @@ -0,0 +1,40 @@ +% +% $Id: xotrace.ins,v 1.4 2000/08/04 15:47:48 latex3 Exp $ + +\input docstrip +\keepsilent +\askforoverwritefalse + +\preamble + +Not for distribution + +(C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +All rights reserved. + +Not for general distribution. In its present form it is not allowed +to put this package onto CD or an archive without consulting the +the authors. +\endpreamble + + + +\generate{% + \file{xmarks.sty}{\from{xmarks.dtx}{package,trace}} + \file{xo-alloc.sty}{\from{xo-alloc.dtx}{package,trace}} + \file{xo-capt.sty}{\from{xo-capt.dtx}{package,trace}} + \file{xo-final.sty}{\from{xo-final.dtx}{package,trace}} + \file{xo-float.sty}{\from{xo-float.dtx}{package,trace}} + \file{xo-grid.sty}{\from{xo-grid.dtx}{package,trace}} + \file{xo-here.sty}{\from{xo-here.dtx}{package,trace}} + \file{xo-new.sty}{\from{xo-new.dtx}{package,trace}} + \file{xo-or.sty}{\from{xo-or.dtx}{package,trace}} + \file{xo-page.sty}{\from{xo-page.dtx}{package,trace}} + \file{xo-place.sty}{\from{xo-place.dtx}{package,trace}} + \file{xo-trace.sty}{\from{xo-trace.dtx}{package,trace}} + \file{xoutput.sty}{\from{xoutput.dtx}{package,trace}} +} + +\endbatchfile + +% \file{xo-implement.sty}{\from{xo-implement-generic-algorithm.dtx}{package,trace}} diff --git a/Master/texmf-dist/source/latex3/xor/xoutput.drv b/Master/texmf-dist/source/latex3/xor/xoutput.drv new file mode 100644 index 00000000000..ee33688cd25 --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xoutput.drv @@ -0,0 +1,144 @@ +\def\rcsdata#1: #2,v #3${ + \def\rcsdata{#2 #3}} +\rcsdata$Id: xoutput.drv,v 1.11 2000/08/04 16:42:11 latex3 Exp $ + +\documentclass[a4paper]{ltxdoc} + +\usepackage{hyperref} + +%\usepackage{trace,xoutput} + +\CodelineIndex +\EnableCrossrefs + +\setcounter{IndexColumns}{2} + +\DoNotIndex{\@elt,\@ne,\@tracepush,\@tracepop,\@empty,\@namedef} +\DoNotIndex{\@spaces} +\DoNotIndex{\advance,\aftergroup,\begingroup,\bgroup,\box,\chardef,\copy,\count,\countdef} +\DoNotIndex{\count@,\csname,\def,\do,\dimen,\dimendef\endgroup,\egroup,\else,\endcsname,\expandafter} +\DoNotIndex{\fi,\gdef,\global,\if,\ifdim,\ifeof,\ifnum,\iftrue,\ifx} +\DoNotIndex{\immediate,\let,\long,\m@ne,\mathchardef,\meaning,\message,\multiply} +\DoNotIndex{\noexpand,\read,\relax,\repeat,\setbox,\space,\string\the} +\DoNotIndex{\toks,\tr@ce,\tw@,\unskip,\unvbox,\unvcopy,\vadjust} +\DoNotIndex{\value,\vbox,\voidb@x,\vrule,\vskip,\vss,\wlog,\write,\z@} +\DoNotIndex{\hbox,\hrule,\ht,\dp,\wd,\ifinner} +\DoNotIndex{\RequirePackage,\typeout,\xdef,\tracingall} + + +\begin{document} + +\title{A new output routine for \LaTeX\thanks{\rcsdata}} +\author{\copyright\ Frank Mittelbach, David Carlisle and Chris Rowley} +\date{Started in 1996--7; first real implementation in Feb 2000 +} + +\maketitle +\tableofcontents + + +\iffalse + +\section{What has been done} + +To get a rough estimate of the work involved (and make me feel good) +look at the rcs change lines per file of the output routine +(as of June 21 2000) using: +\begin{verbatim} + for f in xo*dtx xo*tex ; do rlog $f ; done | \ + awk -f get-changes.awk |sort +\end{verbatim} + +\begin{scriptsize} +\begin{verbatim} +author: # changes # total lines # added lines # plus lines # minus lines +car2; 4 1.84332% 1907 7.21065% 773 7.97977% 1340 7.41684% -567 6.76611% +david; 51 23.5023% 3181 12.0278% 1935 19.9752% 2558 14.1584% -623 7.43437% +frank; 162 74.6544% 21359 80.7615% 6979 72.045% 14169 78.4248% +-7190 85.7995% +\end{verbatim} +\end{scriptsize} + +\fi + +\section{xoutput} +\DocInput{xoutput.dtx} + +\section{Output Routine Tracing} +\DocInput{xo-trace.dtx} + +\newpage +\section{Output Routines} +\DocInput{xo-or.dtx} + +\newpage +\section{Interfacing Here Points} +\DocInput{xo-here.dtx} + +\newpage +\section{Float Placement Algorithm} +\DocInput{xo-place.dtx} + +\newpage +\section{Page Makeup} +\DocInput{xo-final.dtx} + +\newpage +\section{Page Setup Templates} +\DocInput{xo-page.dtx} + +\newpage +\section{Float Environments} +\DocInput{xo-float.dtx} + +\section{Captions} +\DocInput{xo-capt.dtx} + +\section{Allocations} +\DocInput{xo-alloc.dtx} + +\section{Redefinitions for Grid Design} +\DocInput{xo-grid.dtx} + +\section{New stuff that needs merging (or cleanup)} +\DocInput{xo-new.dtx} + +\newpage + +\PrintIndex + +\typeout{=====================================================================} +\typeout{} +\typeout{To get proper index run the document using:} +\typeout{} +\typeout{latex xoutput.drv ; makeindex -s gind.ist xoutput ; latex xoutput.drv} +\typeout{} +\typeout{=====================================================================} + +\end{document} + +% $Log: xoutput.drv,v $ +% Revision 1.11 2000/08/04 16:42:11 latex3 +% *** empty log message *** +% +% Revision 1.10 2000/07/30 18:06:52 latex3 +% added xo-grid.dtx +% +% Revision 1.9 2000/06/15 09:34:37 latex3 +% use .dtx not .sty +% +% Revision 1.8 2000/04/21 19:09:14 latex3 +% added xo-here +% +% Revision 1.7 2000/04/07 07:29:56 latex3 +% added index +% +% Revision 1.6 2000/03/16 10:28:29 latex3 +% adding index +% +% Revision 1.5 2000/03/09 14:44:31 latex3 +% *** empty log message *** +% +% Revision 1.4 2000/03/05 19:42:59 latex3 +% new sections +% diff --git a/Master/texmf-dist/source/latex3/xor/xoutput.dtx b/Master/texmf-dist/source/latex3/xor/xoutput.dtx new file mode 100644 index 00000000000..6f0467022cc --- /dev/null +++ b/Master/texmf-dist/source/latex3/xor/xoutput.dtx @@ -0,0 +1,78 @@ +% \iffalse +%% +%% (C) Copyright 1999-2000 Frank Mittelbach, David Carlisle, Chris Rowley +%% All rights reserved. +%% +%% Not for general distribution. In its present form it is not allowed +%% to put this package onto CD or an archive without consulting the +%% the authors. +%% +% \fi +% + +% \begin{macrocode} +\def\@tempa#1: #2.dtx,v #3 #4 #5 #6 #7${ + \ProvidesPackage{#2}[#4 #3 #5 #6]} +\@tempa$Id: xoutput.dtx,v 1.13 2000/08/11 07:14:49 latex3 Exp $ +% \end{macrocode} +% +% \begin{macrocode} +\RequirePackage{ + ldcsetup, + template, + xmarks, + xparse, + xo-trace,xo-or, + xo-here, + xo-place,xo-page,xo-float,xo-capt,xo-final, + xo-alloc, + xo-new +} +% \end{macrocode} +% + + +% Ignore white space in this package. +% \begin{macrocode} +\IgnoreWhiteSpace +% \end{macrocode} +% +% +% +% +% \endinput +\endinput +% +% $Log: xoutput.dtx,v $ +% Revision 1.13 2000/08/11 07:14:49 latex3 +% added header +% +% Revision 1.12 2000/07/18 21:05:43 latex3 +% removed initialisations +% +% Revision 1.11 2000/07/12 19:44:58 latex3 +% removed some commented out code +% +% Revision 1.10 2000/06/13 21:22:29 latex3 +% turned into a dtx file +% +% Revision 1.9 2000/04/21 19:06:01 latex3 +% removed old initialisation +% added xo-here +% +% Revision 1.8 2000/03/31 17:00:18 latex3 +% fixed rcs log +% +% Revision 1.7 2000/03/22 15:53:39 latex3 +% added xparse +% +% Revision 1.6 2000/02/26 18:26:26 david +% xo-alloc and xo-new added +% +% Revision 1.5 2000/02/13 21:58:07 latex3 +% oops, my rcs again (probably something that will only show up here +% but to ensure that everything is fine I add an \endinput) +% +% Revision 1.4 2000/02/13 21:33:05 latex3 +% added xo-place (float trial placement tests) +% |