summaryrefslogtreecommitdiff
path: root/tex/context/base/strc-flt.mkvi
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2012-07-04 16:20:13 +0300
committerMarius <mariausol@gmail.com>2012-07-04 16:20:13 +0300
commit537aad6efd5c5eb659708f3fc0315042daad0992 (patch)
treed9c789179b860ea724e5c23853da3c026e465b82 /tex/context/base/strc-flt.mkvi
parent895f68ef1727ec31a51ef8799e2bf576ea7642d0 (diff)
downloadcontext-537aad6efd5c5eb659708f3fc0315042daad0992.tar.gz
beta 2012.07.04 14:44
Diffstat (limited to 'tex/context/base/strc-flt.mkvi')
-rw-r--r--tex/context/base/strc-flt.mkvi799
1 files changed, 380 insertions, 419 deletions
diff --git a/tex/context/base/strc-flt.mkvi b/tex/context/base/strc-flt.mkvi
index 06fd02bdc..aaed43b34 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=,
@@ -153,36 +155,36 @@
\let\saveddefinefloat\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_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_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 +256,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]}
@@ -569,15 +571,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
@@ -628,63 +633,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\floatsideskip \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}
@@ -812,16 +812,6 @@
\strc_floats_get_box
\global\insidefloatfalse}
-% \def\strc_floats_set_local_hsize
-% {\ifconditional\c_page_floats_center_box_local
-% \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
@@ -874,18 +864,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]}}
@@ -905,17 +895,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}
@@ -926,7 +916,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
@@ -952,7 +942,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
@@ -967,11 +957,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
@@ -998,7 +988,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}%
@@ -1020,20 +1010,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}%
@@ -1048,29 +1027,17 @@
\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
{\blank[\rootfloatparameter\c!spacebefore]} % or v!back,....
@@ -1092,20 +1059,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
@@ -1122,11 +1085,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
@@ -1193,11 +1152,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
@@ -1207,9 +1171,11 @@
\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
+ % nothing
+ \or
+ % automatic
\ifnofloatcaption
\strc_floats_prepare_no_caption
%\page_backgrounds_add_local_to_box\floatbox % was \doglobal but not needed
@@ -1223,21 +1189,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
@@ -1245,87 +1210,78 @@
\fi\fi
\strc_floats_align_content{\copy\b_strc_floats_content}}}
+% \def\strc_floats_prepare_page_caption
+% {\dostarttagged\t!floatcaption\empty
+% \edef\p_strc_floats_caption_location{\floatcaptionparameter\c!location}%
+% \edef\p_strc_floats_caption_align {\floatcaptionparameter\c!align}%
+% \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
+% {\strc_floats_prepare_stack_caption_max}
+% {\ifdim\wd\b_strc_floats_caption>\wd\b_strc_floats_content % wider caption
+% \doifelse{\floatcaptionparameter\c!width}\v!fit
+% {\strc_floats_prepare_stack_caption_auto}
+% {\strc_floats_prepare_stack_caption_width}%
+% \else
+% \strc_floats_prepare_stack_caption_min
+% \fi}}
+% {\strc_floats_prepare_stack_caption_fixed}}%
+% {\strc_floats_prepare_side_width_caption}}% new, special effects (see icare)
+% {\doifinsetelse{\floatcaptionparameter\c!width}{\v!fit,\v!max}
+% {\strc_floats_prepare_side_auto_caption}
+% {\strc_floats_prepare_side_width_caption}}%
+% \dostoptagged}
+
\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
+ {\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
-% {\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}
-
-% \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
@@ -1337,41 +1293,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
@@ -1384,8 +1342,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
@@ -1404,175 +1361,176 @@
\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}}}
+ \vbox to\d_strc_float_temp_height{#1}}}
-\def\dofloatboxnextleftbuilder#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#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}%
\normalexpanded{\noexpand\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
+ \normalexpanded{\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
+ \normalexpanded{\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\strc_floats_flush_left_caption_hang
+ {\hsmash{\llap{\box\b_strc_floats_caption\dotfskip{\floatcaptionparameter\c!distance}}}}
+
\def\doflushfloatcaptionhang % expanded can go
{\expanded{\doifinsetelse{\v!righthanging}{\floatcaptionparameter\c!location}}
- {\doflushfloatrightcaptionhang}
+ {\strc_floats_flush_right_caption_hang}
{\expanded{\doifinsetelse{\v!lefthanging}{\floatcaptionparameter\c!location}}
- {\doflushfloatleftcaptionhang}
+ {\strc_floats_flush_left_caption_hang}
{\expanded{\doifinsetelse{\v!hang}{\floatcaptionparameter\c!location}}
{\expanded{\doifinsetelse{\v!outer}{\floatcaptionparameter\c!location}}
- {\doifrightpagefloatelse{\doflushfloatrightcaptionhang}{\doflushfloatleftcaptionhang}}
+ {\doifrightpagefloatelse{\strc_floats_flush_right_caption_hang}{\strc_floats_flush_left_caption_hang}}
{\expanded{\doifinsetelse{\v!right}{\floatcaptiondirectives}}
- {\doflushfloatrightcaptionhang}
- {\doflushfloatleftcaptionhang}}}
+ {\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\doflushfloatcaptionhang\vfill}}
-\def\dofloatboxlowbuilder
- {\dofloatboxnextbuilder{\vfill\doflushfloatcaptionhang\dofloatboxbetweenstack}}
+\def\strc_floats_build_box_low
+ {\strc_floats_build_box_next{\vfill\doflushfloatcaptionhang\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]
@@ -1590,125 +1548,132 @@
% \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_indeed
+ {\vbox to \ht\b_strc_floats_content\bgroup
+ \vss
+ \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
+ \egroup}
-\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_bottom_stack_normal_indeed
+ {\vbox to \ht\b_strc_floats_content\bgroup
+ \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
+ \vss
+ \egroup}
-\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_top_stack_normal
+ {\expanded{\doifinset{\v!overlay}{\floatcaptionparameter\c!location}}\strc_floats_build_box_top_stack_normal_indeed}
+
+\def\strc_floats_build_box_bottom_stack_normal
+ {\expanded{\doifinset{\v!overlay}{\floatcaptionparameter\c!location}}\strc_floats_build_box_bottom_stack_normal_indeed}
-\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
+\def\strc_floats_build_box_top
+ {\let\next\strc_floats_build_box_top_stack_normal
\expanded{\processfirstactioninset[\floatcaptionparameter\c!location]}
- [ \v!grid=>\let\next\dofloatboxgridstackbuilder,
- \v!stretch=>\let\next\dofloatboxstretchstackbuilder]%
+ [ \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
+\def\strc_floats_build_box_bottom
+ {\let\next\strc_floats_build_box_bottom_stack_normal
\expanded{\processfirstactioninset[\floatcaptionparameter\c!location]}
- [ \v!grid=>\let\next\dofloatboxgridstackbuilder,
- \v!stretch=>\let\next\dofloatboxstretchstackbuilder]%
+ [ \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}}
@@ -1725,23 +1690,23 @@
\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 }]%
+ [ \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=]
%
@@ -1831,7 +1796,7 @@
\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}
@@ -1840,13 +1805,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
@@ -1869,9 +1832,7 @@
\fi
\fi}
-\newcounter\noxfloatlocations
-
-% \def\dooutput{\sidefloatoutput} % redefinition of \dooutput
+% \def\dooutput{\sidefloatoutput} % redefinition of \dooutput
\definefloat
[\v!figure]
@@ -2104,7 +2065,7 @@
\directlocalfloatsparameter\c!after
\fi}}
-\def\flushlocalfloats
+\unexpanded\def\flushlocalfloats
{\getlocalfloats
\resetlocalfloats}