summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-flt.mkvi
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/strc-flt.mkvi')
-rw-r--r--tex/context/base/strc-flt.mkvi1061
1 files changed, 557 insertions, 504 deletions
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 05cfa40e3..07013b292 100644
--- a/tex/context/base/strc-flt.mkvi
+++ b/tex/context/base/strc-flt.mkvi
@@ -23,8 +23,10 @@
%
% todo: strc_floats_analyze_variables_two could trigger a setup
% and we could have nofmethods of them
-
-% Less globals!
+%
+% todo: move variables from page-flt to strc-flt
+%
+% todo: less globals!
%D This module is being converted into a mkvi one.
%D
@@ -44,7 +46,7 @@
\let\setupcaption \setupfloatcaption
\let\setupcaptions\setupfloatcaption
-\def\dohandlenextfloatindent
+\unexpanded\def\dohandlenextfloatindent
{\useindentnextparameter\floatparameter
\dorechecknextindentation}
@@ -118,7 +120,7 @@
\c!textmethod=\ifgridsnapping2\else0\fi, % 0=raw 1=safe (.99pg) 2=tight (-1pt) % THIS WILL CHANGE
\c!sidemethod=\ifgridsnapping2\else1\fi, % 0=raw 1=safe (.99pg) 2=tight (-1pt) % THIS WILL CHANGE
\c!indentnext=\v!no,
- \c!margin=1em,
+ \c!margin=1\emwidth,
\c!method=1,
\c!cache=\v!yes, % when no, then intermediate flush
\c!leftmargin=\zeropoint, % displacement in 'normal floats'
@@ -129,7 +131,7 @@
\c!rightmargindistance=\floatparameter\c!leftmargindistance,
\c!ntop=2,
\c!nbottom=0,
- \c!nlines=4,
+ \c!nlines=4, % used?
%\c!local=,
%\c!bottombefore=, % e.g. \vfill
%\c!bottomafter=,
@@ -144,45 +146,44 @@
\let\currentfloat\currentfloatcaption
\ifx\currentfloat\empty \else
\strc_counter_setup_using_parameter\currentfloatcaption\floatcaptionparameter
- \strc_counters_check_setup\currentfloatcaption
\fi
\to \everysetupfloatcaption
%D Definitions:
-\let\saveddefinefloat\definefloat
+\let\strc_floats_define_saved\definefloat
\unexpanded\def\definefloat
- {\dotripleempty\dodefinefloat}
+ {\dotripleempty\strc_floats_define}
-\def\dodefinefloat[#1][#2][#3]% #1=naam #2=meervoud #3=parent
+\def\strc_floats_define[#1][#2][#3]% #1=naam #2=meervoud #3=parent
{\ifthirdargument
- \redodefinefloat[#1][#2][#3]%
+ \strc_floats_define_cloned[#1][#2][#3]%
\else\ifsecondargument
- \dododefinefloat[#1][#2]%
+ \strc_floats_define_normal[#1][#2]%
\else
- \dododefinefloat[#1][#1]%
+ \strc_floats_define_normal[#1][#1]%
\fi\fi}
-\def\dododefinefloat[#1][#2]%
+\def\strc_floats_define_normal[#1][#2]%
{\definefloatcaption[#1]%
\definecounter[#1]%
\definelist[#1]%
\presetlabeltext[#1=\Word{#1}~]%
\presetheadtext[#2=\Word{#2}]%
- \saveddefinefloat[#1]%
- \dodefinefloatcommands[#1][#2]}
+ \strc_floats_define_saved[#1]%
+ \strc_floats_define_commands{#1}{#2}}
-\def\redodefinefloat[#1][#2][#3]%
+\def\strc_floats_define_cloned[#1][#2][#3]%
{\definefloatcaption[#1][#3]%
\definecounter[#1][#3]%
\definelist[#1][#3]%
\presetlabeltext[#1=\Word{#3}~]%
\presetheadtext[#2=\Word{#2}]%
- \saveddefinefloat[#1][#3]%
- \dodefinefloatcommands[#1][#2]}
+ \strc_floats_define_saved[#1][#3]%
+ \strc_floats_define_commands{#1}{#2}}
-\def\dodefinefloatcommands[#1][#2]%
+\def\strc_floats_define_commands#1#2%
{\setuvalue {\e!place\e!listof#2}{\dodoubleempty\strc_lists_place[#1]}% call will change
\setuvalue {\e!complete\e!listof#2}{\dotripleempty\strc_lists_complete_indeed[#1][#2]}% call will change
\setuevalue {\e!place#1}{\strc_floats_place{#1}}%
@@ -254,11 +255,11 @@
% begin of todo
-\unexpanded\def\placefloatcaption{\dodoubleempty\doplacefloatcaption}
-\unexpanded\def\setfloatcaption {\dodoubleempty\dodosetfloatcaption}
+\unexpanded\def\placefloatcaption{\dodoubleempty\strc_floats_place_caption}
+\unexpanded\def\setfloatcaption {\dodoubleempty\strc_floats_set_caption}
-\def\doplacefloatcaption[#tag][#reference]#caption{[not supported]}
-\def\dodosetfloatcaption[#tag][#reference]#caption{[not supported]} % \dosetfloatcaption already in use
+\def\strc_floats_place_caption[#tag][#reference]#caption{[not supported]}
+\def\strc_floats_set_caption [#tag][#reference]#caption{[not supported]}
\unexpanded\def\placefloatcaptiontext [#tag]{[not suported yet]}
\unexpanded\def\placefloatcaptionnumber [#tag]{[not suported yet]}
@@ -441,11 +442,15 @@
% we're really dealing with the float. Some day I'll root out
% the global settings.
+\let\lastplacedfloat\empty
+
\def\strc_floats_set_current_tag#tag%
{\edef\currentfloat{#tag}%
\ifx\currentfloat\empty
\let\currentfloat\v!figure % a bit of a hack
\fi
+ \global\let\lastplacedfloat\currentfloat
+ \let\m_strc_floats_saved_userdata\empty
\let\currentfloatcaption\currentfloat}
\def\strc_floats_reset_variables
@@ -483,22 +488,36 @@
% start-stop
+% \startplacefigure[title=oeps][subtitle=whatever]
+% \framed[width=10cm,height=5cm]{\floatuserdataparameter{subtitle}}
+% \stopplacefigure
+
+\installcorenamespace{floatuserdata}
+
+\installsetuponlycommandhandler \??floatuserdata {floatuserdata}
+
+\let\m_strc_floats_saved_userdata\empty % todo: reset this in non start|stop cases
+
\unexpanded\def\strc_floats_start_place#tag%
{\flushnotes
\page_otr_command_flush_side_floats % here !
\strc_floats_begin_group
\strc_floats_set_current_tag{#tag}%
- \dosingleempty\strc_floats_start_place_indeed}
+ \dodoubleempty\strc_floats_start_place_indeed}
-\def\strc_floats_start_place_indeed[#settings]% tricky ... saved not ok yet
+\def\strc_floats_start_place_indeed[#settings][#userdata]%
{\strc_floats_reset_variables
\edef\savedfloatlocation{\floatcaptionparameter\c!location}%
\setupcurrentfloatcaption[\c!location=,\c!reference=,\c!title=,\c!marking=,\c!list=,\c!bookmark=,#settings]%
+ \def\m_strc_floats_saved_userdata{#2}%
\edef\floatlocation{\floatcaptionparameter\c!location}%
\setupcurrentfloatcaption[\c!location=\savedfloatlocation]%
\ifx\floatlocation\empty
\edef\floatlocation{\floatparameter\c!default}%
\fi
+ \ifsecondargument
+ \setupcurrentfloatuserdata[#userdata]%
+ \fi
\doifinsetelse\v!split\floatlocation\strc_floats_place_next_box_split\strc_floats_place_next_box_normal
\bgroup
\ignorespaces}
@@ -569,15 +588,18 @@
% special hack
-\def\strc_floats_begin_group {\begingroup}
-\def\strc_floats_end_group {\carryoverpar\endgroup}
-\def\strc_floats_end_split_group {\endgroup}
-
-\def\strc_floats_begin_text_group {\begingroup\let\strc_floats_end_group\relax}
-\def\strc_floats_end_text_group {\endgroup}
+\def\strc_floats_begin_group {\begingroup}
+\def\strc_floats_end_group {\carryoverpar\endgroup}
+\def\strc_floats_end_split_group {\endgroup}
+\def\strc_floats_begin_text_group{\begingroup\let\strc_floats_end_group\relax}
+\def\strc_floats_end_text_group {\endgroup}
% implementation
+%setnewconstant\c_page_one_float_method \zerocount % 0=raw 1=safe (.99) 2=tight (-1pt) / belongs in page-one
+\setnewconstant\c_strc_floats_rotation \zerocount % 0 90 180 270
+\newconditional\c_strc_floats_par_float
+
\ifdefined\page_margin_strc_floats_before \else \let\page_margin_strc_floats_before \relax \fi
\ifdefined\page_margin_strc_floats_set_hsize \else \let\page_margin_strc_floats_set_hsize\relax \fi
@@ -595,7 +617,7 @@
\splitfloat{\strc_floats_place_next_box_normal}}
\unexpanded\def\strc_floats_place_next_box_normal
- {\ifsomefloatwaiting
+ {\ifconditional\c_page_floats_some_waiting
% this was \checkwaitingfloats spread all over
\doifinsetelse\v!always\floatlocation
{\showmessage\m!floatblocks5\empty}
@@ -628,63 +650,58 @@
\strc_floats_place_packaged_boxes
\dostoptagged % tricky ... needs checking
% we need to carry over the par because of side floats
- \global\sidefloatdownshift \zeropoint
- \global\sidefloatextrashift\zeropoint
- \ifparfloat
+ \global\d_page_sides_downshift \zeropoint
+ \global\d_page_sides_extrashift\zeropoint
+ \ifconditional\c_strc_floats_par_float
\doifinset\v!reset\floatlocation\page_sides_forget_floats
\doinhibitblank
\fi
\strc_floats_end_group}
-\setnewconstant\textfloatmethod\zerocount % 0=raw 1=safe (.99) 2=tight (-1pt)
-\setnewconstant\floatrotation \zerocount % 0 90 180 270
-
% nicer is a bunch of states and one loop that sets those states
\def\strc_floats_analyze_variables_two
{\ifinsidecolumns
- \global\parfloatfalse
+ \global\setfalse\c_strc_floats_par_float
\else
- \doifcommonelse
- {\floatlocation}
- {\flushfloatslist}
- {\global\parfloattrue}
- {\global\parfloatfalse}%
+ \doifcommonelse\floatlocation\flushfloatslist
+ {\global\settrue \c_strc_floats_par_float}
+ {\global\setfalse\c_strc_floats_par_float}%
\fi
- \global\sidefloatshift\zeropoint
- \global\sidefloatmaximum\zeropoint
- \global\sidefloatmethod\floatparameter\c!sidemethod
- \global\textfloatmethod\floatparameter\c!textmethod
- \global\sidefloatalign\zerocount
- \global\floatrotation\zerocount
+ \global\d_page_sides_shift \zeropoint
+ \global\d_page_sides_maximum \zeropoint
+ \global\c_page_sides_method \floatparameter\c!sidemethod
+ \global\c_page_one_float_method \floatparameter\c!textmethod
+ \global\c_page_sides_align \zerocount
+ \global\c_strc_floats_rotation \zerocount
\strc_floats_calculate_skips
- \ifparfloat
+ \ifconditional\c_strc_floats_par_float
\processaction
[\floatparameter\c!sidealign]
- [\v!height=>\global\sidefloatalign\plusone,%
- \v!line=>\global\sidefloatalign\plustwo,% (***)
- \v!depth=>\global\sidefloatalign\plusthree,%
- \v!grid=>\global\sidefloatalign\plusfour,%
- \v!halfline=>\global\sidefloatalign\plusfive]%
- \ifcase\sidefloatalign\relax % todo: optie v!lokaal => \else
- \doifinset\v!height \floatlocation{\global\sidefloatalign\plusone}%
- \doifinset\v!line \floatlocation{\global\sidefloatalign\plustwo}%
- \doifinset\v!depth \floatlocation{\global\sidefloatalign\plusthree}%
- \doifinset\v!grid \floatlocation{\global\sidefloatalign\plusfour}%
- \doifinset\v!halfline\floatlocation{\global\sidefloatalign\plusfive}% meant for 'none'
+ [\v!height=>\global\c_page_sides_align\plusone ,%
+ \v!line=>\global\c_page_sides_align\plustwo ,% (***)
+ \v!depth=>\global\c_page_sides_align\plusthree,%
+ \v!grid=>\global\c_page_sides_align\plusfour ,%
+ \v!halfline=>\global\c_page_sides_align\plusfive ]%
+ \ifcase\c_page_sides_align\relax % todo: optie v!lokaal => \else
+ \doifinset\v!height \floatlocation{\global\c_page_sides_align\plusone }%
+ \doifinset\v!line \floatlocation{\global\c_page_sides_align\plustwo }%
+ \doifinset\v!depth \floatlocation{\global\c_page_sides_align\plusthree}%
+ \doifinset\v!grid \floatlocation{\global\c_page_sides_align\plusfour }%
+ \doifinset\v!halfline\floatlocation{\global\c_page_sides_align\plusfive }% meant for 'none'
\fi
- \doifinset\v!high\floatlocation{\global\sidefloattopskip \zeropoint}%
- \doifinset\v!low \floatlocation{\global\sidefloatbottomskip\zeropoint}%
+ \doifinset\v!high\floatlocation{\global\d_page_sides_topskip \zeropoint}%
+ \doifinset\v!low \floatlocation{\global\d_page_sides_bottomskip\zeropoint}%
\doifinset\v!fit \floatlocation
- {\global\sidefloattopskip \zeropoint
- \global\sidefloatbottomskip\zeropoint
- \global\floatsideskip \zeropoint}%
+ {\global\d_page_sides_topskip \zeropoint
+ \global\d_page_sides_bottomskip\zeropoint
+ \global\d_strc_floats_margin \zeropoint}%
\else
\processallactionsinset
[\floatlocation]
- [ 90=>\global\floatrotation\commalistelement\relax,%
- 180=>\global\floatrotation\commalistelement\relax,%
- 270=>\global\floatrotation\commalistelement\relax]%
+ [ 90=>\global\c_strc_floats_rotation\commalistelement\relax,%
+ 180=>\global\c_strc_floats_rotation\commalistelement\relax,%
+ 270=>\global\c_strc_floats_rotation\commalistelement\relax]%
\fi
\doifinsetelse\v!nonumber\floatlocation
{\global\nofloatnumbertrue}
@@ -703,19 +720,15 @@
% documenteren in details
\def\strc_floats_analyze_variables_one
- {\doifelse{\floatparameter\c!local}\v!yes % fout keyword
- \globalcenterfloatboxtrue
- \globalcenterfloatboxfalse
- \ifglobalcenterfloatbox
- \localcenterfloatboxtrue
+ {\doifelse{\floatparameter\c!local}\v!yes\settrue\setfalse\c_page_floats_center_box_global % fout keyword
+ \ifconditional\c_page_floats_center_box_global
+ \settrue\c_page_floats_center_box_local
\else
- \doifinsetelse\v!local\floatlocation
- \localcenterfloatboxtrue
- \localcenterfloatboxfalse
+ \doifinsetelse\v!local\floatlocation\settrue\setfalse\c_page_floats_center_box_local
\fi
\doifnotcommon{\v!always,\v!here,\v!force}\floatlocation % ! ! ! ! ! !
- {\globalcenterfloatboxfalse
- \localcenterfloatboxfalse}}
+ {\setfalse\c_page_floats_center_box_global
+ \setfalse\c_page_floats_center_box_local}}
\let\naturalfloatheight\!!zeropoint
\let\naturalfloatwidth \!!zeropoint
@@ -762,6 +775,9 @@
\newconditional\usesamefloatnumber
\def\strc_floats_place_packaged_boxes
+ {\expandafter\strc_floats_place_packaged_boxes_indeed\expandafter{\m_strc_floats_saved_userdata}}
+
+\def\strc_floats_place_packaged_boxes_indeed#userdata%
{\bgroup
\ifconditional\usesamefloatnumber
\globallet\currentfloatnumber \previousfloatnumber
@@ -784,7 +800,7 @@
\s!hascaption=\ifnofloatcaption \v!no\else\v!yes\fi,%
\s!hasnumber=\ifnofloatnumber \v!no\else\v!yes\fi,%
\s!hastitle=\ifemptyfloatcaption\v!no\else\v!yes\fi]%
- []%
+ [#userdata]%
\globallet\previousfloatnumber \m_strc_counters_last_registered_index
\globallet\currentfloatnumber \m_strc_counters_last_registered_index
\globallet\currentfloatattribute \m_strc_counters_last_registered_attribute
@@ -816,21 +832,11 @@
\strc_floats_get_box
\global\insidefloatfalse}
-% \def\strc_floats_set_local_hsize
-% {\iflocalcenterfloatbox
-% \seteffectivehsize
-% \hsize\localhsize
-% \else
-% \doifinset\v!margin\floatlocation % brr, really needed! see wm will be redone
-% {\let\currentmarginblock\empty
-% \hsize\marginblockparameter\c!width}%
-% \fi}
-
\newdimen\availablefloatwidth
\newdimen\availablefloatheight
\def\strc_floats_set_local_hsize
- {\iflocalcenterfloatbox
+ {\ifconditional\c_page_floats_center_box_local
% also available check here?
\seteffectivehsize
\hsize\localhsize
@@ -878,18 +884,18 @@
% watch out: line alone aligns on the line ! ! !
\unexpanded\def\movesidefloat[#settings]% (-)n*line|x=,y=
- {\global\sidefloatdownshift \zeropoint
- \global\sidefloatextrashift\zeropoint
+ {\global\d_page_sides_downshift \zeropoint
+ \global\d_page_sides_extrashift\zeropoint
\doifassignmentelse{#settings}%
{\begingroup
\setupcurrentfloat[\c!x=\zeropoint,\c!y=\zeropoint,#settings]%
\ifgridsnapping
\getnoflines{\floatparameter\c!y}%
- \global\sidefloatdownshift\noflines\lineheight
+ \global\d_page_sides_downshift\noflines\lineheight
\else
- \global\sidefloatdownshift\floatparameter\c!y
+ \global\d_page_sides_downshift\floatparameter\c!y
\fi
- \global\sidefloatextrashift\floatparameter\c!x
+ \global\d_page_sides_extrashift\floatparameter\c!x
\endgroup}
{\movedownsidefloat[#settings]}}
@@ -909,17 +915,17 @@
\def\strc_floats_move_down_line#sign%
{\if!!donea \else
- \global\sidefloatdownshift\zeropoint
+ \global\d_page_sides_downshift\zeropoint
\!!doneatrue
\fi
- \global\advance\sidefloatdownshift#sign\lineheight}
+ \global\advance\d_page_sides_downshift#sign\lineheight}
\def\strc_floats_move_down_hang#lines%
{\if!!doneb \else
- \global\sidefloatsidelines\zerocount
+ \global\c_page_sides_n_of_lines\zerocount
\!!donebtrue
\fi
- \global\advance\sidefloatsidelines#lines\relax}
+ \global\advance\c_page_sides_n_of_lines#lines\relax}
\unexpanded\def\movedownsidefloat[#settings]% already in core
{\doifnotinstring{:}{#settings}
@@ -930,7 +936,7 @@
\endgroup}}
\unexpanded\def\hangsidefloat[#number]%
- {\global\sidefloatsidelines#number\relax}
+ {\global\c_page_sides_n_of_lines#number\relax}
\def\strc_floats_set_extra_action#rightpagelocation#leftpagelocation%
{\rightorleftpageaction
@@ -956,7 +962,7 @@
\def\strc_floats_check_extra_actions % less tracingthis way ...
{\doifnotinset\v!text\floatlocation % fuzzy, text overloads left, since then it's a directive
{\let\extrafloatlocation\empty
- % \sidefloatdownshift will be reset afterwards, and can
+ % \d_page_sides_downshift will be reset afterwards, and can
% already be set at this point
\processcommacommand[\floatlocation]\strc_floats_check_extra_actions_step
\ifx\extrafloatlocation\empty \else
@@ -971,11 +977,11 @@
% pas op, maxbreedte niet instellen als plaats=links/rechts
\def\strc_floats_set_local_dimensions
- {\global\sidefloatshift \zeropoint % duplicate
- \global\sidefloatmaximum\zeropoint\relax % duplicate
- \ifdim\sidefloatdownshift=\zeropoint\else
+ {\global\d_page_sides_shift \zeropoint % duplicate
+ \global\d_page_sides_maximum\zeropoint\relax % duplicate
+ \ifdim\d_page_sides_downshift=\zeropoint\else
\global\setbox\floatbox\vbox
- {\vskip\sidefloatdownshift
+ {\vskip\d_page_sides_downshift
\nointerlineskip
\box\floatbox}%
\fi
@@ -1002,7 +1008,7 @@
\scratchwidth\p_maxwidth\relax
\ifdim\wd\floatbox>\scratchwidth
\doifcommonelse{\v!inright,\v!rightmargin,\v!rightedge,\v!inleft,\v!leftmargin,\v!leftedge}\floatlocation
- {\global\sidefloatmaximum\scratchwidth}
+ {\global\d_page_sides_maximum\scratchwidth}
{\doifcommonelse{\v!right,\v!left}\floatlocation
\strc_floats_realign_floatbox_horizontal_one
\strc_floats_realign_floatbox_horizontal_two}%
@@ -1024,20 +1030,9 @@
\unexpanded\def\placefloats
{\page_otr_command_flush_floats}
-\installinsertion\topins
-\installinsertion\botins
-
-\newdimen\botinserted
-\newdimen\topinserted
-
-\newif\iftestfloatbox
-
-\newdimen\floatsideskip \floatsideskip 12pt
-\newdimen\floattopskip \floattopskip \floattopskip
-\newdimen\floatbottomskip \floatbottomskip \floattopskip
-
-\newcount\noftopfloats \noftopfloats=2
-\newcount\nofbotfloats \nofbotfloats=0
+\newdimen\d_strc_floats_margin
+\newdimen\d_strc_floats_top
+\newdimen\d_strc_floats_bottom
\def\strc_floats_calculate_skip#target#skip%
{\edef\askedfloatskip{#skip}%
@@ -1052,33 +1047,21 @@
\def\strc_floats_calculate_skips
{\begingroup
- \strc_floats_calculate_skip\floattopskip {\rootfloatparameter\c!spacebefore}%
- \strc_floats_calculate_skip\floatbottomskip {\rootfloatparameter\c!spaceafter}%
- \strc_floats_calculate_skip\sidefloattopskip {\rootfloatparameter\c!sidespacebefore}%
- \strc_floats_calculate_skip\sidefloatbottomskip{\rootfloatparameter\c!sidespaceafter}%
- \global\floatsideskip \rootfloatparameter\c!margin
- \global\sidefloatleftshift \floatparameter\c!leftmargindistance
- \global\sidefloatrightshift\floatparameter\c!rightmargindistance
- \global\noftopfloats \rootfloatparameter\c!ntop\relax
- \global\nofbotfloats \rootfloatparameter\c!nbottom\relax
+ \strc_floats_calculate_skip\d_strc_floats_top {\rootfloatparameter\c!spacebefore }%
+ \strc_floats_calculate_skip\d_strc_floats_bottom {\rootfloatparameter\c!spaceafter }%
+ \strc_floats_calculate_skip\d_page_sides_topskip {\rootfloatparameter\c!sidespacebefore}%
+ \strc_floats_calculate_skip\d_page_sides_bottomskip{\rootfloatparameter\c!sidespaceafter }%
+ \global\d_strc_floats_margin \rootfloatparameter\c!margin
+ \global\d_page_sided_leftshift \floatparameter \c!leftmargindistance
+ \global\d_page_sided_rightshift\floatparameter \c!rightmargindistance
+ \global\c_page_floats_n_of_top \rootfloatparameter\c!ntop
+ \global\c_page_floats_n_of_bottom \rootfloatparameter\c!nbottom
\endgroup}
-% beter de laatste skip buiten de \insert uitvoeren,
-% bovendien bij volle flush onder baseline.
-
-% \def\betweenfloatblanko% assumes that spaceafter is present
-% {\bgroup
-% \setbox0\vbox{\strut\blank[\rootfloatparameter\c!spacebefore]\strut}%
-% \setbox2\vbox{\strut\blank[\rootfloatparameter\c!spaceafter]\strut}%
-% \ifdim\ht0>\ht2
-% \blank[-\rootfloatparameter\c!spaceafter,\rootfloatparameter\c!spacebefore]%
-% \fi
-% \egroup}
-
-\unexpanded\def\betweenfloatblanko% assumes that spaceafter is present
+\unexpanded\def\betweenfloatblanko % assumes that spaceafter is present
{\blank[\rootfloatparameter\c!spacebefore]} % or v!back,....
-\def\doplacefloatbox % used elsewhere
+\unexpanded\def\doplacefloatbox % used elsewhere
{%\forgetall % NO
\whitespace
\blank[\rootfloatparameter\c!spacebefore]
@@ -1096,20 +1079,16 @@
\def\page_one_place_float_text % this macro should be defined elsewhere
{%\checkwaitingfloats\floatlocationmethod
% todo: check if #1 is indeed \floatlocation or maybe more
- \global\floattextwidth\hsize
- \global\floatwidth\wd\floatbox
- \global\floatheight\ht\floatbox % forget about the depth
- \global\advance\floattextwidth -\floatwidth
- \global\advance\floattextwidth -\rootfloatparameter\c!margin\relax
+ \global\floatwidth \wd\floatbox
+ \global\floatheight \ht\floatbox % forget about the depth
+ \global\floattextwidth\dimexpr\hsize-\floatwidth-\rootfloatparameter\c!margin\relax
\edef\floatlocation{\floatlocationmethod}% to be sure .. why
\doifinsetelse\v!tall\floatlocationmethod
- {\floattextheight\pagegoal
- \advance\floattextheight -\pagetotal
- \advance\floattextheight -\bigskipamount % lelijk
+ {\floattextheight\dimexpr\pagegoal-\pagetotal-\bigskipamount\relax % ugly, this bigskip
\ifdim\floattextheight>\textheight
\floattextheight\textheight
\fi
- \boxmaxdepth\zeropoint \relax % toegevoegd
+ \boxmaxdepth\zeropoint\relax % toegevoegd
\ifdim\floattextheight<\floatheight
\floattextheight\floatheight
\fi
@@ -1126,11 +1105,7 @@
\def\strc_floats_stop_text_indeed
{\egroup
\doifnotinset\v!tall\floatlocation
- {\ifdim\ht\floattext<\floatheight
- \floattextheight\floatheight
- \else
- \floattextheight\ht\floattext
- \fi}%
+ {\floattextheight\ifdim\ht\floattext<\floatheight\floatheight\else\ht\floattext\fi}%
\setbox\floatbox\vbox to \floattextheight
{\hsize\floatwidth
\doifinsetelse\v!both\floatlocation
@@ -1171,7 +1146,7 @@
\dostoptagged
\blank[\rootfloatparameter\c!spaceafter]%
\strc_floats_end_text_group
- \doinsertfloatinfo}
+ \page_floats_report_total}
\def\borderedfloatbox
{\begingroup
@@ -1197,11 +1172,16 @@
\alignedline{\floatparameter\c!location}\v!middle}
\newdimen\d_strc_floats_content
+\newdimen\d_strc_float_temp_height
+\newdimen\d_strc_float_temp_width
+
+\def\captionminwidth {15\bodyfontsize}
+\def\captionovershoot{2\emwidth}
\def\strc_floats_set_page_variant
{\bgroup
\strc_floats_set_local_hsize
- \ifcase\floatrotation\else
+ \ifcase\c_strc_floats_rotation\else
\swapdimens\hsize\vsize
\fi
\forgetall
@@ -1211,10 +1191,12 @@
\let\strc_floats_align_content\strc_floats_align_content_indeed
\let\strc_floats_align_caption\strc_floats_align_caption_indeed
\strc_floats_check_caption_content
-\d_strc_floats_content\wd\b_strc_floats_content
+ \d_strc_floats_content\wd\b_strc_floats_content
\ifcase\floatparameter\c!method
- \or % automatic
- \ifnofloatcaption
+ % nothing
+ \or
+ % automatic
+ \ifnofloatcaption
\strc_floats_prepare_no_caption
%\page_backgrounds_add_local_to_box\floatbox % was \doglobal but not needed
\else
@@ -1227,21 +1209,20 @@
%\page_backgrounds_add_local_to_box\b_strc_floats_caption
\strc_floats_build_box
\fi
- \or % semi automatic
- \or % manual
+ \or
+ % semi automatic
+ \or
+ % manual
\fi
- \ifcase\floatrotation
+ \ifcase\c_strc_floats_rotation
\doifnotinset\v!margin\floatlocation % brr, really needed! see wm
{\postcenterfloatbox\d_strc_floats_content}%
\else
\global\setbox\floatbox\vbox
- {\rotate[\c!rotation=\number\floatrotation]{\box\floatbox}}%
+ {\rotate[\c!rotation=\number\c_strc_floats_rotation]{\box\floatbox}}%
\fi
\egroup}
-\def\captionminwidth {15\bodyfontsize}
-\def\captionovershoot {2em}
-
\def\strc_floats_prepare_no_caption
{\global\setbox\floatbox\vbox % pas op als wd groter dan hsize
{\ifinsidecolumns\ifdim\wd\b_strc_floats_content>\hsize
@@ -1250,86 +1231,54 @@
\strc_floats_align_content{\copy\b_strc_floats_content}}}
\def\strc_floats_prepare_page_caption
- {\dostarttagged\t!floatcaption\empty
- \doifinsetelse{\floatcaptionparameter\c!location}{\v!top,\v!bottom}
- {\doifinsetelse{\floatcaptionparameter\c!width}{\v!fit,\v!max}
- {\doifelse{\floatcaptionparameter\c!minwidth}\v!fit
- {\doifelse{\floatcaptionparameter\c!width}\v!max
- {\dopreparestackcaptionmax}
- {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content % wider caption
- \doifelse{\floatcaptionparameter\c!width}\v!fit
- {\dopreparestackcaptionaut}
- {\dopreparestackcaptionwid}%
- \else
- \dopreparestackcaptionmin
- \fi}}
- {\dopreparestackcaptionfix}}%
- {\dopreparesidewidthcaption}}% new, special effects (see icare)
- {\doifinsetelse{\floatcaptionparameter\c!width}{\v!fit,\v!max}
- {\dopreparesideautocaption}
- {\dopreparesidewidthcaption}}%
- \dostoptagged}
-
-% makes sense if we preexpand more variables
-
-% \def\strc_floats_prepare_page_caption
-% {\edef\p_caption_location{\floatcaptionparameter\c!location}%
-% \edef\p_caption_width {\floatcaptionparameter\c!width}%
-% \edef\p_caption_minwidth{\floatcaptionparameter\c!minwidth}%
-% \edef\p_caption_align {\floatcaptionparameter\c!align}%
-% \dostarttagged\t!floatcaption\empty
-% \ifx\p_caption_location\v!top
-% \strc_floats_prepare_page_caption_top_bottom
-% \else\ifx\p_caption_location\v!bottom
-% \strc_floats_prepare_page_caption_top_bottom
-% \else\ifx\p_caption_width\v!fit
-% \dopreparesideautocaption
-% \else\ifx\p_caption_width\v!max
-% \dopreparesideautocaption
-% \else
-% \dopreparesidewidthcaption
-% \fi\fi\fi\fi
-% \dostoptagged}
+ {\edef\p_strc_floats_caption_location{\floatcaptionparameter\c!location}%
+ \edef\p_strc_floats_caption_width {\floatcaptionparameter\c!width}%
+ \edef\p_strc_floats_caption_minwidth{\floatcaptionparameter\c!minwidth}%
+ \edef\p_strc_floats_caption_align {\floatcaptionparameter\c!align}%
+ \dostarttagged\t!floatcaption\empty
+ \ifx\p_strc_floats_caption_location\v!top
+ \strc_floats_prepare_page_caption_top_bottom
+ \else\ifx\p_strc_floats_caption_location\v!bottom
+ \strc_floats_prepare_page_caption_top_bottom
+ \else\ifx\p_strc_floats_caption_width\v!fit
+ \strc_floats_prepare_side_auto_caption
+ \else\ifx\p_strc_floats_caption_width\v!max
+ \strc_floats_prepare_side_auto_caption
+ \else
+ \strc_floats_prepare_side_width_caption
+ \fi\fi\fi\fi
+ \dostoptagged}
-% \def\strc_floats_prepare_page_caption_top_bottom
-% {\ifx\p_caption_width\v!fit
-% \strc_floats_prepare_page_caption_top_bottom_fit_max
-% \else\ifx\p_caption_width\v!max
-% \strc_floats_prepare_page_caption_top_bottom_fit_max
-% \else
-% \dopreparesidewidthcaption % new, special effects (see icare)
-% \fi\fi}
-
-% \def\strc_floats_prepare_page_caption_top_bottom_fit_max
-% {\ifx\p_caption_minwidth\v!fit
-% \ifx\p_caption_width\v!max
-% \dopreparestackcaptionmax
-% \else\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content % wider caption
-% \ifx\p_caption_width\v!fit
-% \dopreparestackcaptionaut
-% \else
-% \dopreparestackcaptionwid
-% \fi
-% \else
-% \dopreparestackcaptionmin
-% \fi\fi
-% \else
-% \dopreparestackcaptionfix
-% \fi}
-
-% \def\dopreparestackcaptionmin
-% {\setbox\b_strc_floats_caption\vbox
-% {\strc_floats_caption_set_align
-% \hsize\wd\b_strc_floats_content
-% \ifx\p_caption_align\empty
-% \raggedcenter % on purpose overloads align !
-% \fi
-% \strc_floats_make_complete_caption}}
+\def\strc_floats_prepare_page_caption_top_bottom
+ {\ifx\p_strc_floats_caption_width\v!fit
+ \strc_floats_prepare_page_caption_top_bottom_fit_max
+ \else\ifx\p_strc_floats_caption_width\v!max
+ \strc_floats_prepare_page_caption_top_bottom_fit_max
+ \else
+ \strc_floats_prepare_side_width_caption % new, special effects (see icare)
+ \fi\fi}
+
+\def\strc_floats_prepare_page_caption_top_bottom_fit_max
+ {\ifx\p_strc_floats_caption_minwidth\v!fit
+ \ifx\p_strc_floats_caption_width\v!max
+ \strc_floats_prepare_stack_caption_max
+ \else\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content % wider caption
+ \ifx\p_strc_floats_caption_width\v!fit
+ \strc_floats_prepare_stack_caption_auto
+ \else
+ \strc_floats_prepare_stack_caption_width
+ \fi
+ \else
+ \strc_floats_prepare_stack_caption_min
+ \fi\fi
+ \else
+ \strc_floats_prepare_stack_caption_fixed
+ \fi}
\def\strc_floats_caption_set_align
- {\normalexpanded{\setupalign[\v!reset,\floatcaptionparameter\c!align]}}
+ {\normalexpanded{\setupalign[\v!reset,\p_strc_floats_caption_align]}}
-\def\dopreparesideautocaption
+\def\strc_floats_prepare_side_auto_caption
{\scratchdimen\dimexpr\hsize-\wd\b_strc_floats_content-\floatparameter\c!margin\relax
\ifdim\wd\b_strc_floats_caption>\scratchdimen
\ifdim\wd\b_strc_floats_caption<1.3\scratchdimen
@@ -1341,41 +1290,43 @@
\hsize\scratchdimen
\strc_floats_make_complete_caption}}
-\def\dopreparesidewidthcaption
+\def\strc_floats_prepare_side_width_caption
{\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
\hsize\floatcaptionparameter\c!width
\strc_floats_make_complete_caption}}
-\def\dopreparestackcaptionfix
+\def\strc_floats_prepare_stack_caption_fixed
{\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
\hsize\floatcaptionparameter\c!minwidth % special effects
\strc_floats_make_complete_caption}}
-\def\dopreparestackcaptionmax
+\def\strc_floats_prepare_stack_caption_max
{\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
\hsize\wd\b_strc_floats_content
\strc_floats_make_complete_caption}}
-\def\dopreparestackcaptionwid
+\def\strc_floats_prepare_stack_caption_width
{\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
\hsize\floatcaptionparameter\c!width
\strc_floats_make_complete_caption}}
-\def\dopreparestackcaptionmin
+\def\strc_floats_prepare_stack_caption_min
{\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
\hsize\wd\b_strc_floats_content
- \doifnothing{\floatcaptionparameter\c!align}\raggedcenter % on purpose overloads align !
+ \ifx\p_strc_floats_caption_align\empty
+ \raggedcenter % on purpose overloads align !
+ \fi
\strc_floats_make_complete_caption}}
-\def\dopreparestackcaptionaut
- {\doifsomething{\floatcaptionparameter\c!align}
- {\doifnotinset\v!middle{\floatcaptionparameter\c!align}%
- {\let\captionovershoot\!!zeropoint}}%
+\def\strc_floats_prepare_stack_caption_auto
+ {\ifx\p_strc_floats_caption_align\empty \else
+ \doifnotinset\v!middle\p_strc_floats_caption_align{\let\captionovershoot\!!zeropoint}%
+ \fi
\edef\captionhsize{\the\wd\b_strc_floats_content}%
\ifdim\captionhsize>\hsize
% float is wider than \hsize
@@ -1388,8 +1339,7 @@
\ifdim\ht\scratchbox>\lineheight % more lines
\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
- \hsize\captionhsize
- \advance\hsize -\captionovershoot\relax
+ \hsize\dimexpr\captionhsize-\captionovershoot\relax
\ifdim\hsize<\captionminwidth\relax
\hsize\captionhsize
\fi
@@ -1408,175 +1358,192 @@
\fi
\setbox\scratchbox\vbox % test with overshoot
{\settrialtypesetting
- \scratchdimen\captionhsize
- \advance\scratchdimen \captionovershoot
- \advance\scratchdimen 3em % an average word length
- \ifdim\scratchdimen<\hsize \hsize\scratchdimen \fi
+ \scratchdimen\dimexpr\captionhsize+\captionovershoot+3\emwidth\relax % 3em is an average word length
+ \ifdim\scratchdimen<\hsize
+ \hsize\scratchdimen
+ \fi
\notesenabledfalse
\strc_floats_make_complete_caption}%
\ifdim\ht\scratchbox>\lineheight
% at least an average word longer than a line
\setbox\b_strc_floats_caption\vbox
{\strc_floats_caption_set_align
- \scratchdimen\captionhsize
- \advance\scratchdimen \captionovershoot
- \ifdim\scratchdimen<\hsize \hsize\scratchdimen \fi
+ \scratchdimen\dimexpr\captionhsize+\captionovershoot\relax
+ \ifdim\scratchdimen<\hsize
+ \hsize\scratchdimen
+ \fi
+ \strc_floats_make_complete_caption}%
+ \else\ifx\p_strc_floats_caption_align\empty
+ \setbox\b_strc_floats_caption\vbox
+ {\strc_floats_caption_set_align
+ \hsize\captionhsize
+ \raggedcenter % overloads
\strc_floats_make_complete_caption}%
\else
- % just over a line, don't use an overshoot % % % todo: outer/inner and such
- \doifcommonelse{\floatcaptionparameter\c!align}{\v!left,\v!right,\v!flushleft,\v!flushright}
- {\setbox\b_strc_floats_caption\vbox
- {\strc_floats_caption_set_align
- \hsize\captionhsize
- % strange : \raggedcenter
- \strc_floats_make_complete_caption}}
- {% nicer
- \setbox\b_strc_floats_caption\vbox
- {\strc_floats_caption_set_align
- \hsize\captionhsize
- \doifnothing{\floatcaptionparameter\c!align}\raggedcenter% overloads
- \strc_floats_make_complete_caption}}%
- \fi
+ \setbox\b_strc_floats_caption\vbox
+ {\strc_floats_caption_set_align
+ \hsize\captionhsize
+ \strc_floats_make_complete_caption}%
+ \fi\fi
\fi}
-\newdimen\tempfloatheight
-\newdimen\tempfloatwidth
+\def\strc_floats_between_stack
+ {\endgraf
+ \nointerlineskip
+ \floatcaptionparameter\c!inbetween
+ \endgraf}
-\def\dofloatboxbetweenstack
- {\endgraf\nointerlineskip\floatcaptionparameter\c!inbetween\endgraf}
-
-\def\dofloatboxdefaultbuilder % done
+\def\strc_floats_build_box_default % done
{\strc_floats_align_content{\box\b_strc_floats_content}}
-\def\dofloatboxnextrightbuilder#1%
- {\ifparfloat \hbox \else \expandafter \strc_floats_align_content \fi
- {\tempfloatheight\ht\b_strc_floats_content
+\def\strc_floats_build_box_next_right#1%
+ {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi
+ {\d_strc_float_temp_height\ht\b_strc_floats_content
\box\b_strc_floats_content
- \normalexpanded{\noexpand\doifnotinset{\v!hang}{\floatcaptionparameter\c!location}}{\dotfskip{\floatcaptionparameter\c!distance}}%
- \vbox to\tempfloatheight{#1}}}
-
-\def\dofloatboxnextleftbuilder#1%
- {\ifparfloat \hbox \else \expandafter \strc_floats_align_content \fi
- {\tempfloatheight\ht\b_strc_floats_content
- \vbox to\tempfloatheight{#1}%
- \normalexpanded{\noexpand\doifnotinset{\v!hang}{\floatcaptionparameter\c!location}}{\dotfskip{\floatcaptionparameter\c!distance}}%
+ \doifnotinset\v!hang{\floatcaptionparameter\c!location}
+ {\dotfskip{\floatcaptionparameter\c!distance}}%
+ \vbox to\d_strc_float_temp_height{#1}}}
+
+\def\strc_floats_build_box_next_left#1%
+ {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi
+ {\d_strc_float_temp_height\ht\b_strc_floats_content
+ \vbox to\d_strc_float_temp_height{#1}%
+ \doifnotinset\v!hang{\floatcaptionparameter\c!location}
+ {\dotfskip{\floatcaptionparameter\c!distance}}%
\box\b_strc_floats_content}}
-\def\dofloatboxnextouterbuilder
- {\doifrightpagefloatelse\dofloatboxnextrightbuilder\dofloatboxnextleftbuilder}
+\def\strc_floats_build_box_next_outer
+ {\doifrightpagefloatelse\strc_floats_build_box_next_right\strc_floats_build_box_next_left}
-\def\dofloatboxnextinnerbuilder
- {\doifrightpagefloatelse\dofloatboxnextleftbuilder\dofloatboxnextrightbuilder}
+\def\strc_floats_build_box_next_inner
+ {\doifrightpagefloatelse\strc_floats_build_box_next_left\strc_floats_build_box_next_right}
-\def\dofloatboxnextrighthangbuilder#1%
- {\ifparfloat \hbox \else \expandafter \strc_floats_align_content \fi
- {\tempfloatheight\ht\b_strc_floats_content
+\def\strc_floats_build_box_next_right_hang#1%
+ {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi
+ {\d_strc_float_temp_height\ht\b_strc_floats_content
\box\b_strc_floats_content
- \vbox to\tempfloatheight{#1}}}
+ \vbox to\d_strc_float_temp_height{#1}}}
-\def\dofloatboxnextlefthangbuilder#1%
- {\ifparfloat \hbox \else \expandafter \strc_floats_align_content \fi
- {\tempfloatheight\ht\b_strc_floats_content
- \vbox to\tempfloatheight{#1}%
+\def\strc_floats_build_box_next_left_hang#1%
+ {\ifconditional\c_strc_floats_par_float \hbox \else \expandafter \strc_floats_align_content \fi
+ {\d_strc_float_temp_height\ht\b_strc_floats_content
+ \vbox to\d_strc_float_temp_height{#1}%
\box\b_strc_floats_content}}
-\def\dodofloatboxnextrightmarginbuilder#1#2%
- {\ifparfloat
+\def\strc_floats_build_box_next_right_margin_indeed#1#2%
+ {\ifconditional\c_strc_floats_par_float
\hbox\bgroup
- \tempfloatheight\ht\b_strc_floats_content
+ \d_strc_float_temp_height\ht\b_strc_floats_content
\box\b_strc_floats_content
- \hsmash{\hskip#1\vbox to\tempfloatheight{#2}}%
+ \hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}%
\egroup
\else
\begingroup
- \tempfloatheight\ht\b_strc_floats_content
- \everyrightofalignedline{\hsmash{\hskip#1\vbox to\tempfloatheight{#2}}}%
+ \d_strc_float_temp_height\ht\b_strc_floats_content
+ \everyrightofalignedline{\hsmash{\hskip#1\vbox to\d_strc_float_temp_height{#2}}}%
\strc_floats_align_content{\box\b_strc_floats_content}%
\endgroup
\fi}
-\def\dodofloatboxnextleftmarginbuilder#1#2%
- {\ifparfloat
+\def\strc_floats_build_box_next_left_margin_indeed#1#2%
+ {\ifconditional\c_strc_floats_par_float
\hbox\bgroup
- \tempfloatheight\ht\b_strc_floats_content
- \hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\tempfloatheight{#2}}%
+ \d_strc_float_temp_height\ht\b_strc_floats_content
+ \hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}%
\box\b_strc_floats_content
\egroup
\else
\begingroup
- \tempfloatheight\ht\b_strc_floats_content
- \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\tempfloatheight{#2}}}%
+ \d_strc_float_temp_height\ht\b_strc_floats_content
+ \everyleftofalignedline{\hsmash{\hskip-\dimexpr#1+\wd\b_strc_floats_caption\relax\vbox to\d_strc_float_temp_height{#2}}}%
\strc_floats_align_content{\box\b_strc_floats_content}%
\endgroup
\fi}
-\def\dofloatboxnextrightmarginbuilder{\dodofloatboxnextrightmarginbuilder\rightmargindistance}
-\def\dofloatboxnextleftmarginbuilder {\dodofloatboxnextleftmarginbuilder \leftmargindistance }
+\def\strc_floats_build_box_next_right_margin
+ {\strc_floats_build_box_next_right_margin_indeed\rightmargindistance}
+
+\def\strc_floats_build_box_next_left_margin
+ {\strc_floats_build_box_next_left_margin_indeed \leftmargindistance }
-\def\dofloatboxnextoutermarginbuilder
+\def\strc_floats_build_box_next_outer_margin
{\doifrightpagefloatelse
- {\dodofloatboxnextrightmarginbuilder\rightmargindistance}
- {\dodofloatboxnextleftmarginbuilder \rightmargindistance}}
+ {\strc_floats_build_box_next_right_margin_indeed\rightmargindistance}
+ {\strc_floats_build_box_next_left_margin_indeed \rightmargindistance}}
-\def\dofloatboxnextinnermarginbuilder
+\def\strc_floats_build_box_next_inner_margin
{\doifrightpagefloatelse
- {\dodofloatboxnextleftmarginbuilder \leftmargindistance}
- {\dodofloatboxnextrightmarginbuilder\leftmargindistance}}
-
-\def\dofloatboxnextbuilder % beware, we first check on left/rightmargin because there can be left/right also
- {\let\next\dofloatboxnextleftbuilder
- \normalexpanded{\noexpand\processallactionsinset[\floatcaptionparameter\c!location]}
- [ \v!outermargin=>\let\next\dofloatboxnextoutermarginbuilder,
- \v!innermargin=>\let\next\dofloatboxnextinnermarginbuilder,
- \v!leftmargin=>\let\next\dofloatboxnextleftmarginbuilder,
- \v!rightmargin=>\let\next\dofloatboxnextrightmarginbuilder,
- \v!lefthanging=>\let\next\dofloatboxnextlefthangbuilder,
- \v!righthanging=>\let\next\dofloatboxnextrighthangbuilder,
- \v!outer=>\let\next\dofloatboxnextouterbuilder,
- \v!inner=>\let\next\dofloatboxnextinnerbuilder,
- \v!left=>\let\next\dofloatboxnextleftbuilder,
- \v!right=>\let\next\dofloatboxnextrightbuilder]%
+ {\strc_floats_build_box_next_left_margin_indeed \leftmargindistance}
+ {\strc_floats_build_box_next_right_margin_indeed\leftmargindistance}}
+
+\def\strc_floats_build_box_next % beware, we first check on left/rightmargin because there can be left/right also
+ {\let\next\strc_floats_build_box_next_left
+ \processallactionsinset[\floatcaptionparameter\c!location]
+ [ \v!outermargin=>\let\next\strc_floats_build_box_next_outer_margin,
+ \v!innermargin=>\let\next\strc_floats_build_box_next_inner_margin,
+ \v!leftmargin=>\let\next\strc_floats_build_box_next_left_margin,
+ \v!rightmargin=>\let\next\strc_floats_build_box_next_right_margin,
+ \v!lefthanging=>\let\next\strc_floats_build_box_next_left_hang,
+ \v!righthanging=>\let\next\strc_floats_build_box_next_right_hang,
+ \v!outer=>\let\next\strc_floats_build_box_next_outer,
+ \v!inner=>\let\next\strc_floats_build_box_next_inner,
+ \v!left=>\let\next\strc_floats_build_box_next_left,
+ \v!right=>\let\next\strc_floats_build_box_next_right]%
\next}
-\def\dofloatboxsidebuilder
- {\ifparfloat
- \let\next\dofloatboxhighbuilder
+\def\strc_floats_build_box_side
+ {\ifconditional\c_strc_floats_par_float
+ \let\next\strc_floats_build_box_high
\else
- \let\next\dofloatboxmiddlebuilder
- \expanded{\processallactionsinset[\floatcaptionparameter\c!location]}
- [ \v!low=>\let\next\dofloatboxlowbuilder,
- \v!middle=>\let\next\dofloatboxmiddlebuilder,
- \v!high=>\let\next\dofloatboxhighbuilder]%
+ \let\next\strc_floats_build_box_middle
+ \processallactionsinset[\floatcaptionparameter\c!location]
+ [ \v!low=>\let\next\strc_floats_build_box_low,
+ \v!middle=>\let\next\strc_floats_build_box_middle,
+ \v!high=>\let\next\strc_floats_build_box_high]%
\fi
\next}
-\def\doflushfloatleftcaptionhang
- {\hsmash{\llap{\box\b_strc_floats_caption\dotfskip{\floatcaptionparameter\c!distance}}}}
-
-\def\doflushfloatrightcaptionhang
+\def\strc_floats_flush_right_caption_hang
{\hsmash{\rlap{\dotfskip{\floatcaptionparameter\c!distance}\box\b_strc_floats_caption}}}
-\def\doflushfloatcaptionhang % expanded can go
- {\expanded{\doifinsetelse{\v!righthanging}{\floatcaptionparameter\c!location}}
- {\doflushfloatrightcaptionhang}
- {\expanded{\doifinsetelse{\v!lefthanging}{\floatcaptionparameter\c!location}}
- {\doflushfloatleftcaptionhang}
- {\expanded{\doifinsetelse{\v!hang}{\floatcaptionparameter\c!location}}
- {\expanded{\doifinsetelse{\v!outer}{\floatcaptionparameter\c!location}}
- {\doifrightpagefloatelse{\doflushfloatrightcaptionhang}{\doflushfloatleftcaptionhang}}
- {\expanded{\doifinsetelse{\v!right}{\floatcaptiondirectives}}
- {\doflushfloatrightcaptionhang}
- {\doflushfloatleftcaptionhang}}}
+\def\strc_floats_flush_left_caption_hang
+ {\hsmash{\llap{\box\b_strc_floats_caption\dotfskip{\floatcaptionparameter\c!distance}}}}
+
+% \def\strc_floats_flush_caption_hang % expanded can go
+% {\expanded{\doifinsetelse{\v!righthanging}{\floatcaptionparameter\c!location}}
+% {\strc_floats_flush_right_caption_hang}
+% {\expanded{\doifinsetelse{\v!lefthanging}{\floatcaptionparameter\c!location}}
+% {\strc_floats_flush_left_caption_hang}
+% {\expanded{\doifinsetelse{\v!hang}{\floatcaptionparameter\c!location}}
+% {\expanded{\doifinsetelse{\v!outer}{\floatcaptionparameter\c!location}}
+% {\doifrightpagefloatelse{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}}
+% {\expanded{\doifinsetelse{\v!right}{\floatcaptiondirectives}}
+% {\strc_floats_flush_right_caption_hang}
+% {\strc_floats_flush_left_caption_hang}}}
+% {\box\b_strc_floats_caption}}}}
+
+\def\strc_floats_flush_caption_hang % expanded can go
+ {\edef\p_strc_floats_caption_location{\floatcaptionparameter\c!location}%
+ \doifinsetelse\v!righthanging\p_strc_floats_caption_location
+ {\strc_floats_flush_right_caption_hang}
+ {\doifinsetelse\v!lefthanging\p_strc_floats_caption_location
+ {\strc_floats_flush_left_caption_hang}
+ {\doifinsetelse\v!hang\p_strc_floats_caption_location
+ {\doifinsetelse\v!outer\p_strc_floats_caption_location
+ {\doifrightpagefloatelse{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}}
+ {\doifinsetelse\v!right\floatcaptiondirectives
+ {\strc_floats_flush_right_caption_hang}
+ {\strc_floats_flush_left_caption_hang}}}
{\box\b_strc_floats_caption}}}}
-\def\dofloatboxhighbuilder
- {\dofloatboxnextbuilder{\dofloatboxbetweenstack\doflushfloatcaptionhang\vfill}}
+\def\strc_floats_build_box_high
+ {\strc_floats_build_box_next{\strc_floats_between_stack\strc_floats_flush_caption_hang\vfill}}
-\def\dofloatboxlowbuilder
- {\dofloatboxnextbuilder{\vfill\doflushfloatcaptionhang\dofloatboxbetweenstack}}
+\def\strc_floats_build_box_low
+ {\strc_floats_build_box_next{\vfill\strc_floats_flush_caption_hang\strc_floats_between_stack}}
-\def\dofloatboxmiddlebuilder
- {\dofloatboxnextbuilder{\vfill\box\b_strc_floats_caption\vfill}}
+\def\strc_floats_build_box_middle
+ {\strc_floats_build_box_next{\vfill\box\b_strc_floats_caption\vfill}}
% \definefloat
% [lefty][lefties][figure]
@@ -1594,125 +1561,136 @@
% \placelefty{}{} \input tufte \input tufte
% \stoptext
-\def\bothangfloat#1{\ruledvbox to \ht\b_strc_floats_content{#1\vss}}
-\def\tophangfloat#1{\ruledvbox to \ht\b_strc_floats_content{\vss#1}}
+\def\strc_floats_build_box_top_stack_normal_overlay
+ {\vbox to \ht\b_strc_floats_content{\vss\strc_floats_build_box_top_stack_normal_content}}
-\def\dofloatboxnormaltopstackbuilder
- {\expanded{\doifinset{\v!overlay}{\floatcaptionparameter\c!location}}\tophangfloat
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
- \hbox{\strc_floats_locate_side_float{\box\b_strc_floats_caption}}%
- \dofloatboxbetweenstack
- \hbox{\hbox{\box\b_strc_floats_content}}%
- \else
- \page_otr_command_set_float_hsize
- \hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}
- \dofloatboxbetweenstack
- \hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
- \fi}}
+\def\strc_floats_build_box_top_stack_normal_content
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
+ \hbox{\strc_floats_locate_side_float{\box\b_strc_floats_caption}}%
+ \strc_floats_between_stack
+ \hbox{\hbox{\box\b_strc_floats_content}}%
+ \else
+ \page_otr_command_set_float_hsize
+ \hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}
+ \strc_floats_between_stack
+ \hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
+ \fi}
-\def\dofloatboxnormalbotstackbuilder
- {\expanded{\doifinset{\v!overlay}{\floatcaptionparameter\c!location}}\bothangfloat
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
- \hbox{\hbox{\box\b_strc_floats_content}}%
- \dofloatboxbetweenstack
- \hbox{\strc_floats_locate_side_float{\box\b_strc_floats_caption}}%
- \else
- \page_otr_command_set_float_hsize
- \hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
- \dofloatboxbetweenstack
- \hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}%
- \fi}}
+\def\strc_floats_build_box_bottom_stack_normal_overlay
+ {\vbox to \ht\b_strc_floats_content{\strc_floats_build_box_bottom_stack_normal_content\vss}}
+
+\def\strc_floats_build_box_bottom_stack_normal_content
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
+ \hbox{\hbox{\box\b_strc_floats_content}}%
+ \strc_floats_between_stack
+ \hbox{\strc_floats_locate_side_float{\box\b_strc_floats_caption}}%
+ \else
+ \page_otr_command_set_float_hsize
+ \hbox{\strc_floats_align_content{\box\b_strc_floats_content}}%
+ \strc_floats_between_stack
+ \hbox{\strc_floats_locate_text_float{\box\b_strc_floats_caption}}%
+ \fi}
+
+\def\strc_floats_build_box_top_stack_normal
+ {\doifinsetelse\v!overlay{\floatcaptionparameter\c!location}
+ \strc_floats_build_box_top_stack_normal_overlay
+ \strc_floats_build_box_top_stack_normal_content}
+
+\def\strc_floats_build_box_bottom_stack_normal
+ {\doifinset\v!overlay{\floatcaptionparameter\c!location}
+ \strc_floats_build_box_bottom_stack_normal_overlay
+ \strc_floats_build_box_bottom_stack_normal_content}
-\def\dofloatboxgridtopstackbuilder
+\def\strc_floats_build_box_top_stack_grid
{\dp\b_strc_floats_caption\strutdepth
\setbox\scratchbox\vbox
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
\strc_floats_locate_side_float{\box\b_strc_floats_caption}%
- \vss\dofloatboxbetweenstack
+ \vss\strc_floats_between_stack
\hbox{\box\b_strc_floats_content}%
\else
\page_otr_command_set_float_hsize
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
- \vss\dofloatboxbetweenstack
+ \vss\strc_floats_between_stack
\strc_floats_align_content{\box\b_strc_floats_content}%
\fi}%
\getnoflines{\dimexpr\htdp\scratchbox-10\scaledpoint\relax}% get rid of inaccuracy
\vbox to \noflines\lineheight{\unvbox\scratchbox}}
-\def\dofloatboxgridbotstackbuilder
+\def\strc_floats_build_box_bottom_stack_grid
{\dp\b_strc_floats_caption\strutdepth
\setbox\scratchbox\vbox
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
\hbox{\box\b_strc_floats_content}%
- \vss\dofloatboxbetweenstack
+ \vss\strc_floats_between_stack
\strc_floats_locate_side_float{\box\b_strc_floats_caption}%
\else
\page_otr_command_set_float_hsize
\strc_floats_align_content{\box\b_strc_floats_content}%
- \vss\dofloatboxbetweenstack
+ \vss\strc_floats_between_stack
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
\fi}%
\getnoflines{\dimexpr\htdp\scratchbox-10\scaledpoint\relax}% get rid of inaccuracy
\vbox to \noflines\lineheight{\unvbox\scratchbox}}
-\def\dofloatboxstretchtopstackbuilder
+\def\strc_floats_build_box_top_stack_stretch
{\dp\b_strc_floats_caption\strutdepth
\setbox\scratchbox\vbox
{\strc_floats_align_caption{\copy\b_strc_floats_caption}%
\strc_floats_align_content {\copy\b_strc_floats_content }}%
\getnoflines{\dimexpr\htdp\scratchbox-10\scaledpoint\relax}% get rid of inaccuracy
\vbox to \noflines\lineheight
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
\strc_floats_locate_side_float{\box\b_strc_floats_caption}%
- \vss\dofloatboxbetweenstack\vss
+ \vss\strc_floats_between_stack\vss
\hbox{\box\b_strc_floats_content}%
\else
\page_otr_command_set_float_hsize
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
- \vss\dofloatboxbetweenstack\vss
+ \vss\strc_floats_between_stack\vss
\strc_floats_align_content{\box\b_strc_floats_content}%
\fi}}
-\def\dofloatboxstretchbotstackbuilder
+\def\strc_floats_build_box_bottom_stack_stretch
{\dp\b_strc_floats_caption\strutdepth
\setbox\scratchbox\vbox
{\strc_floats_align_content{\copy\b_strc_floats_content }%
\strc_floats_align_caption{\copy\b_strc_floats_caption}}%
\getnoflines{\dimexpr\htdp\scratchbox-10\scaledpoint\relax}% get rid of inaccuracy
\vbox to \noflines\lineheight
- {\tempfloatwidth\wd\b_strc_floats_content
- \ifparfloat
+ {\d_strc_float_temp_width\wd\b_strc_floats_content
+ \ifconditional\c_strc_floats_par_float
\hbox{\box\b_strc_floats_content}%
- \vss\dofloatboxbetweenstack\vss
+ \vss\strc_floats_between_stack\vss
\strc_floats_locate_side_float{\box\b_strc_floats_caption}
\else
\page_otr_command_set_float_hsize
\strc_floats_align_content{\box\b_strc_floats_content}%
- \vss\dofloatboxbetweenstack\vss
+ \vss\strc_floats_between_stack\vss
\strc_floats_locate_text_float{\box\b_strc_floats_caption}%
\fi}}
-\def\dofloatboxtopbuilder
- {\let\next\dofloatboxnormaltopstackbuilder
- \expanded{\processfirstactioninset[\floatcaptionparameter\c!location]}
- [ \v!grid=>\let\next\dofloatboxgridstackbuilder,
- \v!stretch=>\let\next\dofloatboxstretchstackbuilder]%
+\def\strc_floats_build_box_top
+ {\let\next\strc_floats_build_box_top_stack_normal
+ \processfirstactioninset[\floatcaptionparameter\c!location]
+ [ \v!grid=>\let\next\strc_floats_build_box_top_stack_grid,
+ \v!stretch=>\let\next\strc_floats_build_box_top_stack_stretch]%
\next}
-\def\dofloatboxbottombuilder
- {\let\next\dofloatboxnormalbotstackbuilder
- \expanded{\processfirstactioninset[\floatcaptionparameter\c!location]}
- [ \v!grid=>\let\next\dofloatboxgridstackbuilder,
- \v!stretch=>\let\next\dofloatboxstretchstackbuilder]%
+\def\strc_floats_build_box_bottom
+ {\let\next\strc_floats_build_box_bottom_stack_normal
+ \processfirstactioninset[\floatcaptionparameter\c!location]
+ [ \v!grid=>\let\next\strc_floats_build_box_bottom_stack_grid,
+ \v!stretch=>\let\next\strc_floats_build_box_bottom_stack_stretch]%
\next}
-\def\relocatecaptionright#1{\strc_floats_align_caption{\hbox to \tempfloatwidth{\hss#1}}}
-\def\relocatecaptionleft #1{\strc_floats_align_caption{\hbox to \tempfloatwidth{#1\hss}}}
+\def\strc_floats_relocate_caption_right#1{\strc_floats_align_caption{\hbox to \d_strc_float_temp_width{\hss#1}}}
+\def\strc_floats_relocate_caption_left #1{\strc_floats_align_caption{\hbox to \d_strc_float_temp_width{#1\hss}}}
\unexpanded\def\installfloatboxbuilder#1#2{\setvalue{\??floatbuilder#1}{#2}}
@@ -1721,31 +1699,32 @@
{\strc_floats_set_local_hsize
\forgetall
\let\floatcaptionarrangement\s!default
- \def\docommand##1%
- {\doifdefined{\??floatbuilder##1}{\def\floatcaptionarrangement{##1}\quitcommalist}}%
- \processcommacommand[\floatcaptionparameter\c!location]\docommand
+ \processcommacommand[\floatcaptionparameter\c!location]\strc_floats_build_box_step
\executeifdefined{\??floatbuilder\floatcaptionarrangement}{\getvalue{\??floatbuilder\s!default}}}}
+\def\strc_floats_build_box_step#1%
+ {\doifdefined{\??floatbuilder#1}{\def\floatcaptionarrangement{#1}\quitcommalist}}
+
\def\strc_floats_locate_text_float
{\let\next\strc_floats_align_caption
- \expanded{\processallactionsinset[\floatcaptionparameter\c!location]}
- [ \v!left=>\let\next\relocatecaptionleft,
- \v!right=>\let\next\relocatecaptionright,
- \v!inner=>\doifrightpagefloatelse{\let\next\relocatecaptionleft }{\let\next\relocatecaptionright},
- \v!outer=>\doifrightpagefloatelse{\let\next\relocatecaptionright}{\let\next\relocatecaptionleft }]%
+ \processallactionsinset[\floatcaptionparameter\c!location]
+ [ \v!left=>\let\next\strc_floats_relocate_caption_left,
+ \v!right=>\let\next\strc_floats_relocate_caption_right,
+ \v!inner=>\doifrightpagefloatelse{\let\next\strc_floats_relocate_caption_left }{\let\next\strc_floats_relocate_caption_right},
+ \v!outer=>\doifrightpagefloatelse{\let\next\strc_floats_relocate_caption_right}{\let\next\strc_floats_relocate_caption_left }]%
\next}
-\installfloatboxbuilder \v!none \dofloatboxdefaultbuilder
-\installfloatboxbuilder \s!default \dofloatboxdefaultbuilder
-\installfloatboxbuilder \v!high \dofloatboxhighbuilder
-\installfloatboxbuilder \v!low \dofloatboxlowbuilder
-\installfloatboxbuilder \v!middle \dofloatboxmiddlebuilder
+\installfloatboxbuilder \v!none \strc_floats_build_box_default
+\installfloatboxbuilder \s!default \strc_floats_build_box_default
+\installfloatboxbuilder \v!high \strc_floats_build_box_high
+\installfloatboxbuilder \v!low \strc_floats_build_box_low
+\installfloatboxbuilder \v!middle \strc_floats_build_box_middle
-\installfloatboxbuilder \v!left \dofloatboxsidebuilder
-\installfloatboxbuilder \v!right \dofloatboxsidebuilder
+\installfloatboxbuilder \v!left \strc_floats_build_box_side
+\installfloatboxbuilder \v!right \strc_floats_build_box_side
-\installfloatboxbuilder \v!top \dofloatboxtopbuilder
-\installfloatboxbuilder \v!bottom \dofloatboxbottombuilder
+\installfloatboxbuilder \v!top \strc_floats_build_box_top
+\installfloatboxbuilder \v!bottom \strc_floats_build_box_bottom
% \setuplayout[grid=yes] \showgrid \setupcaptions[style=smallbodyfont,location=grid,inbetween=]
%
@@ -1756,6 +1735,8 @@
% test \placefigure{\input zapf\relax}{\externalfigure[cow.pdf][frame=on,grid=depth]} test \page
% \stoptext
+% This might move to page-flt:
+
\newif\ifpostponecolumnfloats \postponecolumnfloatsfalse % don't change
\setnewconstant\postcenterfloatmethod\plusone
@@ -1774,9 +1755,9 @@
\global\setbox\floatbox\hbox to \scratchdimen
% {\hfill\box\floatbox\hfill}} % geen \hss, gaat mis in kolommen !
% {\hss \box\floatbox\hss }} % wel \hss, anders mis in colset
- {\ifglobalcenterfloatbox
+ {\ifconditional\c_page_floats_center_box_global
\donetrue
- \else\iflocalcenterfloatbox
+ \else\ifconditional\c_page_floats_center_box_local
\donetrue
\else
\donefalse
@@ -1793,7 +1774,6 @@
\forgetall
\postponenotes
\dontcomplain
- %\showcomposition
\setbox\b_strc_floats_content\vbox{\borderedfloatbox}%
%\page_backgrounds_add_local_to_box\b_strc_floats_content
\ifnofloatcaption
@@ -1808,33 +1788,106 @@
\fi
\egroup}
+% \def\strc_floats_prepare_side_caption
+% {\dostarttagged\t!floatcaption\empty
+% \edef\p_strc_floats_caption_align{\floatcaptionparameter\c!align}%
+% \doifelse{\floatcaptionparameter\c!width}\v!max
+% {\setbox\b_strc_floats_caption\vbox
+% {\strc_floats_caption_set_align
+% \hsize\wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}}%
+% {\doifelse{\floatcaptionparameter\c!width}\v!fit
+% {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content\relax
+% \setbox\b_strc_floats_caption\vbox
+% {\forgetall % needed?
+% \hsize\wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}%
+% \else
+% \setbox\b_strc_floats_caption\hbox to \wd\b_strc_floats_content
+% {\hss\hbox{\strc_floats_make_complete_caption}\hss}%
+% \fi}
+% {\setbox\b_strc_floats_caption\vbox
+% {\strc_floats_caption_set_align
+% \hsize\floatcaptionparameter\c!width % \wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}}}%
+% \dostoptagged}
+
\def\strc_floats_prepare_side_caption
{\dostarttagged\t!floatcaption\empty
- \doifelse{\floatcaptionparameter\c!width}\v!max
- {\setbox\b_strc_floats_caption\vbox
- {\strc_floats_caption_set_align
- \hsize\wd\b_strc_floats_content
- \strc_floats_make_complete_caption}}%
- {\doifelse{\floatcaptionparameter\c!width}\v!fit
- {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content\relax
- \setbox\b_strc_floats_caption\vbox
- {\forgetall % needed?
- \hsize\wd\b_strc_floats_content
- \strc_floats_make_complete_caption}%
- \else
- \setbox\b_strc_floats_caption\hbox to \wd\b_strc_floats_content
- {\hss\hbox{\strc_floats_make_complete_caption}\hss}%
- \fi}
- {\setbox\b_strc_floats_caption\vbox
- {\strc_floats_caption_set_align
- \hsize\floatcaptionparameter\c!width % \wd\b_strc_floats_content
- \strc_floats_make_complete_caption}}}%
+ \edef\p_strc_floats_caption_width{\floatcaptionparameter\c!width}%
+ \edef\p_strc_floats_caption_align{\floatcaptionparameter\c!align}%
+ \ifx\p_strc_floats_caption_width\v!max
+ \strc_floats_prepare_side_caption_max
+ \else\ifx\p_strc_floats_caption_width\v!fit
+ \strc_floats_prepare_side_caption_fit
+ \else
+ \strc_floats_prepare_side_caption_width
+ \fi\fi
\dostoptagged}
+% these could be \??floatpreparesidecaption
+
+\def\strc_floats_prepare_side_caption_max
+ {\setbox\b_strc_floats_caption\vbox
+ {\strc_floats_caption_set_align
+ \hsize\wd\b_strc_floats_content
+ \strc_floats_make_complete_caption}}
+
+\def\strc_floats_prepare_side_caption_fit
+ {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content\relax
+ \setbox\b_strc_floats_caption\vbox
+ {\forgetall % needed?
+ \hsize\wd\b_strc_floats_content
+ \strc_floats_make_complete_caption}%
+ \else
+ \setbox\b_strc_floats_caption\hbox to \wd\b_strc_floats_content
+ {\hss\hbox{\strc_floats_make_complete_caption}\hss}%
+ \fi}
+
+\def\strc_floats_prepare_side_caption_width
+ {\setbox\b_strc_floats_caption\vbox
+ {\strc_floats_caption_set_align
+ \hsize\p_strc_floats_caption_width % \wd\b_strc_floats_content
+ \strc_floats_make_complete_caption}}
+
+% % maybe (but then also prepare_page that way):
+%
+% \installcorenamespace{floatpreparesidecaption}
+%
+% \def\strc_floats_prepare_side_caption
+% {\dostarttagged\t!floatcaption\empty
+% \edef\p_strc_floats_caption_width{\floatcaptionparameter\c!width}%
+% \edef\p_strc_floats_caption_align{\floatcaptionparameter\c!align}%
+% \expandcheckedcsname\??floatpreparesidecaption\p_strc_floats_caption_width\s!unknown
+% \dostoptagged}
+%
+% \setvalue{\??floatpreparesidecaption\v!max}%
+% {\setbox\b_strc_floats_caption\vbox
+% {\strc_floats_caption_set_align
+% \hsize\wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}}
+%
+% \setvalue{\??floatpreparesidecaption\v!fit}%
+% {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content\relax
+% \setbox\b_strc_floats_caption\vbox
+% {\forgetall % needed?
+% \hsize\wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}%
+% \else
+% \setbox\b_strc_floats_caption\hbox to \wd\b_strc_floats_content
+% {\hss\hbox{\strc_floats_make_complete_caption}\hss}%
+% \fi}
+%
+% \setvalue{\??floatpreparesidecaption\s!unknown}%
+% {\setbox\b_strc_floats_caption\vbox
+% {\strc_floats_caption_set_align
+% \hsize\p_strc_floats_caption_width % \wd\b_strc_floats_content
+% \strc_floats_make_complete_caption}}
+
\def\strc_floats_locate_side_float#1%
{\begingroup
\alignstrutmode\zerocount
- \hsize\tempfloatwidth \forgetall
+ \hsize\d_strc_float_temp_width \forgetall
\alignedline{\floatparameter\c!location}\v!middle{#1}%
\endgroup}
@@ -1843,13 +1896,11 @@
\let\strc_floats_align_caption\relax
\strc_floats_build_box}
-\newif\ifparfloat
-
\def\strc_floats_set_box % todo : \global\setbox, currently messy
{\ifvisible
\par
\edef\floatcaptiondirectives{\floatparameter\c!location,\floatcaptionparameter\c!location}%
- \ifparfloat
+ \ifconditional\c_strc_floats_par_float
\strc_floats_set_paragraph_variant
\else
\strc_floats_set_page_variant
@@ -1872,9 +1923,7 @@
\fi
\fi}
-\newcounter\noxfloatlocations
-
-% \def\dooutput{\sidefloatoutput} % redefinition of \dooutput
+% \def\dooutput{\sidefloatoutput} % redefinition of \dooutput
\definefloat
[\v!figure]
@@ -1900,17 +1949,17 @@
\installcorenamespace{floatmethods}
-\let\floatmethod \empty
-\let\floatlabel \empty
-\let\floatcolumn \empty
-\let\floatrow \empty
-\let\forcedfloatmethod\empty
+\let\floatmethod \empty % set by lua
+\let\floatlabel \empty % set by lua
+\let\floatcolumn \empty % set by lua
+\let\floatrow \empty % set by lua
+\let\forcedfloatmethod\empty % set by lua
\def\setfloatmethodvariables#1% \floatmethod \floatlabel \floatrow \floatcolumn
{\ctxcommand{analysefloatmethod("#1")}}
\def\somesomewherefloat[#1]%
- {\dofloatssavesomewherefloat\s!somewhere{#1}}
+ {\page_floats_save_somewhere_float\s!somewhere{#1}}
\def\strc_floats_get_box
{\ifvisible
@@ -2073,45 +2122,49 @@
%D Local floats:
-\def\setuplocalfloats
- {\getparameters[\??lf]}
+\installcorenamespace{localfloats}
+\installcorenamespace{localfloatstack}
+
+\installsetuponlycommandhandler \??localfloats {localfloats}
\setuplocalfloats
[%\c!before=\blank,
%\c!after=\blank,
\c!inbetween=\blank]
-\initializeboxstack{localfloats}
+\initializeboxstack\??localfloatstack
-\newcounter\noflocalfloats
+\newcount\c_strc_localfloats_n \let\noflocalfloats\c_strc_localfloats_n
-\def\resetlocalfloats
- {\doglobal\newcounter\noflocalfloats
- \initializeboxstack{localfloats}}
+\unexpanded\def\resetlocalfloats
+ {\global\c_strc_localfloats_n\zerocount
+ \initializeboxstack\??localfloatstack}
-\def\somelocalfloat
- {\doglobal\increment\noflocalfloats
- \savebox{localfloats}{\noflocalfloats}{\box\floatbox}}
+\unexpanded\def\somelocalfloat
+ {\global\advance\c_strc_localfloats_n\plusone
+ \savebox\??localfloatstack{\number\c_strc_localfloats_n}{\box\floatbox}}
-\def\getlocalfloats
- {\dorecurse\noflocalfloats
+\unexpanded\def\getlocalfloats
+ {\dorecurse\c_strc_localfloats_n
{\ifnum\recurselevel=\plusone % 1\relax
- \getvalue{\??lf\c!before}%
+ \directlocalfloatsparameter\c!before
\else
- \getvalue{\??lf\c!inbetween}%
+ \directlocalfloatsparameter\c!inbetween
\fi
- \dontleavehmode\hbox{\foundbox{localfloats}\recurselevel}%
- \ifnum\recurselevel=\noflocalfloats\relax
- \getvalue{\??lf\c!after}%
+ \dontleavehmode\hbox{\foundbox\??localfloatstack\recurselevel}%
+ \ifnum\recurselevel=\c_strc_localfloats_n\relax
+ \directlocalfloatsparameter\c!after
\fi}}
-\def\flushlocalfloats
+\unexpanded\def\flushlocalfloats
{\getlocalfloats
\resetlocalfloats}
-\unexpanded\def\getlocalfloat#1{\expanded{\foundbox{localfloats}{\number#1}}}
+\unexpanded\def\getlocalfloat#1%
+ {\normalexpanded{\foundbox{\??localfloatstack}{\number#1}}}
-\def\forcelocalfloats{\let\forcedfloatmethod\v!local}
+\unexpanded\def\forcelocalfloats
+ {\let\forcedfloatmethod\v!local}
\installfloatmethod \s!singlecolumn \v!local \somelocalfloat
\installfloatmethod \s!multicolumn \v!local \somelocalfloat