texlive[63981] Master/texmf-dist: wrapstuff (26jul22)
commits+karl at tug.org
commits+karl at tug.org
Tue Jul 26 21:41:09 CEST 2022
Revision: 63981
http://tug.org/svn/texlive?view=revision&revision=63981
Author: karl
Date: 2022-07-26 21:41:08 +0200 (Tue, 26 Jul 2022)
Log Message:
-----------
wrapstuff (26jul22)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/wrapstuff/wrapstuff.pdf
trunk/Master/texmf-dist/source/latex/wrapstuff/wrapstuff.dtx
trunk/Master/texmf-dist/tex/latex/wrapstuff/wrapstuff.sty
Modified: trunk/Master/texmf-dist/doc/latex/wrapstuff/wrapstuff.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/wrapstuff/wrapstuff.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/wrapstuff/wrapstuff.dtx 2022-07-25 23:49:35 UTC (rev 63980)
+++ trunk/Master/texmf-dist/source/latex/wrapstuff/wrapstuff.dtx 2022-07-26 19:41:08 UTC (rev 63981)
@@ -119,12 +119,12 @@
%<*internal>
\fi
%</internal>
-%<package>\NeedsTeXFormat{LaTeX2e}
+%<package>\NeedsTeXFormat{LaTeX2e}[2021-06-01]
%<package>\@ifundefined{ExplLoaderFileDate}{\RequirePackage{expl3}}{}
-%<+package>\GetIdInfo$Id: wrapstuff.dtx 564fe9d 2022-07-20 19:55:58 +0800 Qing Lee <sobenlee at gmail.com> $
+%<+package>\GetIdInfo$Id: wrapstuff.dtx e891159 2022-07-26 19:00:31 +0800 Qing Lee <sobenlee at gmail.com> $
%<package> {Wrapping text around stuff}
%<package>\ProvidesExplPackage{\ExplFileName}
-%<package> {\ExplFileDate}{0.1}{\ExplFileDescription}
+%<package> {\ExplFileDate}{0.2}{\ExplFileDescription}
%<*driver>
\documentclass{ctxdoc}
\usepackage{wrapstuff}
@@ -173,10 +173,11 @@
%</driver>
% \fi
%
-% \CheckSum{2923}
+% \CheckSum{3127}
%
% \changes{v0.1}{2022/07/05}{初始版本。}
% \changes{v0.1}{2022/07/20}{首次提交到 CTAN 发布。}
+% \changes{v0.2}{2022/07/21}{改进放置方式。}
%
% \GetFileId{wrapstuff.sty}
%
@@ -190,6 +191,11 @@
% \section{基本用法}
%
% \pkg{wrapstuff} 宏包提供了图文绕排的另一种实现。
+% \pkg{wrapstuff} 尝试整合和扩展 \pkg{picinpar}、\pkg{floatflt}、\pkg{wrapfig}、
+% \pkg{cutwin} 和 \pkg{wrapfig2} 等同类宏包的功能。
+% 本宏包兼容 \pkg{caption}、\pkg{float} 和 \pkg{floatrow} 等宏包,
+% 并试图兼容显示(display)数学公式和各种 \LaTeX\ 列表环境,可以让他们正确绕排。
+%
% \pkg{wrapstuff} 的实现依赖 \LaTeX\ 2021-06-01 开始提供的段落钩子,
% 并依赖 \LaTeXiii\ 2022-04-10 之后的版本。
%
@@ -242,24 +248,19 @@
% 设置绕排内容的高度,初始值为 \qty{0}{pt},代表自然高度。
% \end{function}
%
-% \begin{function}{leftsep,rightsep,hsep}
+% \begin{function}{lines}
% \begin{syntax}
-% leftsep = <长度>
-% rightsep = <长度>
-% hsep = <长度>
+% lines = <正整数>
% \end{syntax}
-% 设置绕排内容与正文的左/右间距,选项 \opt{hsep} 同时设置 \opt{leftsep} 和 \opt{rightsep}。
-% 初始值是 \qty{1}{em}。
+% 设置绕排内容占据正文的行数,可以设置正整数。
+% 初始值为空,根据绕排内容的高度自动计算行数。
% \end{function}
%
-% \begin{function}{abovesep,belowsep,vsep}
+% \begin{function}{linewidth}
% \begin{syntax}
-% abovesep = <长度>
-% belowsep = <长度>
-% vsep = <长度>
+% linewidth = <宽度>
% \end{syntax}
-% 设置绕排内容与正文的上/下间距,选项 \opt{vsep} 同时设置 \opt{abovesep} 和 \opt{belowsep}。
-% 初始值是 \qty{0}{pt}。
+% 设置正文段落的行宽,初始设置为 |\linewidth|,一般不需要调整。
% \end{function}
%
% \begin{function}{l,r,c,i,o,ratio}
@@ -298,6 +299,26 @@
% \end{SideBySideExample}
% \end{function}
%
+% \begin{function}{leftsep,rightsep,hsep}
+% \begin{syntax}
+% leftsep = <长度>
+% rightsep = <长度>
+% hsep = <长度>
+% \end{syntax}
+% 设置绕排内容与正文的左/右间距,选项 \opt{hsep} 同时设置 \opt{leftsep} 和 \opt{rightsep}。
+% 初始值是 \qty{1}{em}。
+% \end{function}
+%
+% \begin{function}{abovesep,belowsep,vsep}
+% \begin{syntax}
+% abovesep = <长度>
+% belowsep = <长度>
+% vsep = <长度>
+% \end{syntax}
+% 设置绕排内容与正文的上/下间距,选项 \opt{vsep} 同时设置 \opt{abovesep} 和 \opt{belowsep}。
+% 初始值是 \qty{0}{pt}。
+% \end{function}
+%
% \begin{function}{hoffset}
% \begin{syntax}
% hoffset = <长度>
@@ -334,21 +355,6 @@
% \end{SideBySideExample}
% \end{function}
%
-% \begin{function}{lines}
-% \begin{syntax}
-% lines = <正整数>
-% \end{syntax}
-% 设置绕排内容占据正文的行数,可以设置正整数。
-% 初始值为空,根据绕排内容的高度自动计算行数。
-% \end{function}
-%
-% \begin{function}{linewidth}
-% \begin{syntax}
-% linewidth = <宽度>
-% \end{syntax}
-% 设置正文段落的行宽,初始设置为 |\linewidth|,一般不需要调整。
-% \end{function}
-%
% \begin{function}{\wrapstuffclear}
% 如果当前正文段落的行数不够,\pkg{wrapstuff} 的作用会延续到下一段。
% 这可能会导致某些意外结果,可以在下一段之前启用命令 \tn{wrapstuffclear} 消除影响。
@@ -405,6 +411,270 @@
\prop_gput:Nnn \g_msg_module_name_prop { wstf } { wrapstuff }
% \end{macrocode}
%
+% \begin{macro}[var]{
+% \c_@@_global_tl_tl,
+% \c_@@_global_dim_tl,
+% \c_@@_global_int_tl,
+% \c_@@_global_bool_tl}
+% 一些需要全局设置的变量。
+% \begin{macrocode}
+\tl_const:Nn \c_@@_global_tl_tl
+ { \g_@@_main_setting_tl }
+\tl_const:Nn \c_@@_global_dim_tl
+ {
+ \g_@@_hang_ht_dim
+ \g_@@_total_ht_dim
+ \g_@@_stuff_ht_dim
+ \g_@@_stuff_wd_dim
+ \g_@@_first_dp_dim
+ \g_@@_first_sep_dim
+ \g_@@_prevdepth_dim
+ \g_@@_column_ht_dim
+ \g_@@_window_ht_dim
+ \g_@@_remaining_dim
+ \g_@@_column_room_dim
+ \g_@@_parshape_indent_dim
+ \g_@@_parshape_length_dim
+ }
+\tl_const:Nn \c_@@_global_int_tl
+ {
+ \g_@@_top_int
+ \g_@@_column_int
+ \g_@@_window_int
+ }
+\tl_const:Nn \c_@@_global_bool_tl
+ {
+ \g_@@_next_bool
+ \g_@@_leqno_bool
+ \g_@@_column_bool
+ \g_@@_entire_bool
+ \g_@@_display_bool
+ \g_@@_move_hang_bool
+ \g_@@_next_hang_bool
+ \g_@@_first_set_bool
+ \g_@@_first_save_bool
+ \g_@@_right_move_bool
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_tl_init:N,
+% \@@_dim_init:N,
+% \@@_int_init:N,
+% \@@_bool_init:N}
+% 全局变量的初始化,注意保存好清除和恢复的设置。
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_tl_init:N #1
+ {
+ \tl_new:N #1
+ \tl_gput_right:Nn \g_@@_var_clear_tl
+ { \tl_gclear:N #1 }
+ \tl_gput_right:Nn \g_@@_var_push_tl
+ { \tl_gset:Nn \exp_not:N #1 { \exp_not:o {#1} } }
+ }
+\cs_new_protected:Npn \@@_dim_init:N #1
+ {
+ \dim_new:N #1
+ \tl_gput_right:Nn \g_@@_var_clear_tl
+ { \dim_gzero:N #1 }
+ \tl_gput_right:Nn \g_@@_var_push_tl
+ { \dim_gset:Nn #1 { \dim_use:N #1 } }
+ }
+\cs_new_protected:Npn \@@_int_init:N #1
+ {
+ \int_new:N #1
+ \tl_gput_right:Nn \g_@@_var_clear_tl
+ { \int_gzero:N #1 }
+ \tl_gput_right:Nn \g_@@_var_push_tl
+ { \int_gset:Nn #1 { \int_use:N #1 } }
+ }
+\cs_new_protected:Npn \@@_bool_init:N #1
+ {
+ \bool_new:N #1
+ \tl_gput_right:Nn \g_@@_var_clear_tl
+ { \bool_gset_false:N #1 }
+ \tl_gput_right:Nn \g_@@_var_push_tl
+ {
+ \bool_if:NTF #1
+ { \bool_gset_true:N #1 }
+ { \bool_gset_false:N #1 }
+ }
+ }
+\tl_new:N \g_@@_var_clear_tl
+\tl_new:N \g_@@_var_push_tl
+\tl_map_function:NN \c_@@_global_tl_tl \@@_tl_init:N
+\tl_map_function:NN \c_@@_global_dim_tl \@@_dim_init:N
+\tl_map_function:NN \c_@@_global_int_tl \@@_int_init:N
+\tl_map_function:NN \c_@@_global_bool_tl \@@_bool_init:N
+% \end{macrocode}
+% \cs{g_@@_top_int} 的初始值是 $-1$。
+% \begin{macrocode}
+\int_gdecr:N \g_@@_top_int
+\tl_gput_right:Nn \g_@@_var_clear_tl
+ { \int_gdecr:N \g_@@_top_int }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_clear:,
+% \@@_clear_variable:,
+% \@@_clear_kludge:,
+% \@@_clear_stuff_box:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_clear:
+ {
+ \@@_clear_para_hook:
+ \@@_clear_kludge:
+ \@@_clear_variable:
+ }
+\cs_new_protected_nopar:Npn \@@_clear_variable:
+ {
+ \tl_use:N \g_@@_var_clear_tl
+ \box_gclear:N \g_@@_stuff_box
+ }
+\cs_new_protected_nopar:Npn \@@_clear_kludge:
+ {
+ \bool_if:NTF \g_@@_next_bool
+ {
+ \skip_vertical:n
+ { \tex_baselineskip:D * \g_@@_window_int }
+ }
+ {
+ \box_if_empty:NF \g_@@_stuff_box
+ { \@@_clear_stuff_box: }
+ }
+ }
+\cs_new_protected_nopar:Npn \@@_clear_stuff_box:
+ {
+ \@@_ignore_depth:
+ \skip_set:Nn \l_@@_last_skip
+ { \box_dp:N \strutbox }
+ \skip_vertical:N \l_@@_last_skip
+ \box_use_drop:N \g_@@_stuff_box
+ \skip_vertical:N \l_@@_last_skip
+ \@@_ignore_depth:
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{
+% \@@_status_push:,
+% \@@_status_pop:,
+% \@@_status_restore:,
+% \@@_status_clear:}
+% 全局变量的保存与恢复。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_status_push:
+ {
+ \tl_clear:N \l_@@_status_tl
+ \int_gincr:N \g_@@_status_int
+ \exp_args:Ne \@@_status_push_aux:n
+ { \int_use:N \g_@@_status_int }
+ \seq_gpush:No \g_@@_status_seq { \l_@@_status_tl }
+ }
+\cs_new_protected:Npn \@@_status_push_aux:n #1
+ {
+ \@@_push_cs:nN {#1} \@@_para_before:
+ \@@_push_cs:nN {#1} \@@_para_begin:
+ \@@_push_cs:nN {#1} \@@_para_end:
+ \@@_push_cs:nN {#1} \@@_display_hook:
+ \@@_push_box:N \g_@@_stuff_box
+ \@@_push_var:
+ }
+\cs_new_protected:Npn \@@_push_cs:nN #1#2
+ {
+ \exp_args:NNc \@@_push_cs_aux:NN #2
+ { @@_ #1 _ \token_to_str:N #2 }
+ }
+\cs_new_protected:Npn \@@_push_cs_aux:NN #1#2
+ {
+ \cs_gset_eq:NN #2#1
+ \tl_put_right:Nn \l_@@_status_tl
+ {
+ \cs_gset_eq:NN #1#2
+ \cs_undefine:N #2
+ }
+ }
+\cs_new_protected:Npn \@@_push_box:N #1
+ {
+ \hbox_gset:Nn \g_@@_stauts_box
+ {
+ \hbox_unpack_drop:N \g_@@_stauts_box
+ \box_use:N #1
+ }
+ \tl_put_right:Nn \l_@@_status_tl
+ { \@@_pop_box:N #1 }
+ }
+\cs_new_protected:Npn \@@_pop_box:N #1
+ {
+ \hbox_gset:Nw \g_@@_stauts_box
+ \hbox_unpack_drop:N \g_@@_stauts_box
+ \box_gset_to_last:N #1
+ \@@_if_last_hlist:TF
+ { \hbox_gset_end: }
+ {
+ \hbox_gset_end:
+ \box_gclear:N \g_@@_stauts_box
+ }
+ }
+\cs_new_protected_nopar:Npn \@@_push_var:
+ {
+ \tl_put_right:Nx \l_@@_status_tl
+ { \g_@@_var_push_tl }
+ }
+\cs_new_protected_nopar:Npn \@@_status_pop:
+ {
+ \seq_gpop:NNT \g_@@_status_seq \l_@@_status_tl
+ {
+ \int_gdecr:N \g_@@_status_int
+ \tl_use:N \l_@@_status_tl
+ }
+ }
+\cs_new_protected_nopar:Npn \@@_status_restore:
+ {
+ \@@_status_push:
+ \@@_clear_para_hook:
+ \@@_clear_display_hook:
+ \@@_clear_variable:
+ \group_insert_after:N \@@_status_pop:
+ }
+\cs_new_protected_nopar:Npn \@@_status_clear:
+ {
+ \bool_if:NT \g_@@_next_bool
+ {
+ \@@_clear_para_hook:
+ \@@_clear_variable:
+ }
+ }
+\tl_new:N \l_@@_status_tl
+\box_new:N \g_@@_stauts_box
+\int_new:N \g_@@_status_int
+\seq_new:N \g_@@_status_seq
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.2}{2022/07/21}{兼容 \tn{parbox} 与 \env{minipage} 等使用环境。}
+%
+% \begin{macro}{\wrapstuff at parboxrestore,\@arrayparboxrestore}
+% 在 \LaTeX\ 的 \cs{parbox} 和 \env{minipage} 等环境中恢复正常的段落状态。
+% \tn{wrapstuff at parboxrestore} 的初始值是在分组后清除活动的段落钩子和相关全局变量,
+% 只有在 \env{wrapstuff at par} 环境内部才等于 \cs{@@_status_restore:},
+% 保存和恢复相关状态。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \wrapstuff at parboxrestore
+ { \group_insert_after:N \@@_status_clear: }
+\cs_new_protected_nopar:Npn \@@_parbox_restore:
+ {
+ \cs_set_eq:NN
+ \wrapstuff at parboxrestore
+ \@@_status_restore:
+ }
+\g at addto@macro \@arrayparboxrestore
+ { \wrapstuff at parboxrestore }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}[TF]{
% \@@_if_last_none:,
% \@@_if_last_hlist:,
@@ -451,6 +721,21 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_para_raw_end:}
+% 将 \cs{para_raw_end:} 放在分组中是为了保持 \tn{parshape}。
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_para_raw_end:
+ { \group_begin: \para_raw_end: \group_end: }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@@_gadd_ht:Nn}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_gadd_ht:Nn #1#2
+ { \box_gset_ht:Nn #1 { \box_ht:N #1 + \dim_eval:n {#2} } }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{wrapstuff}
% 主要功能环境接口。
% \begin{macrocode}
@@ -551,19 +836,16 @@
\box_gset_dp:Nn \g_@@_stuff_box { \c_zero_dim }
}
\tl_new:N \l_@@_main_kv_tl
-\tl_new:N \g_@@_main_setting_tl
\box_new:N \g_@@_stuff_box
-\dim_new:N \g_@@_stuff_ht_dim
-\dim_new:N \g_@@_stuff_wd_dim
\dim_new:N \l_@@_shift_dim
\dim_new:N \l_@@_width_dim
\dim_new:N \l_@@_height_dim
-\dim_new:N \g_@@_prevdepth_dim
-\dim_new:N \g_@@_remaining_dim
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_attach_label:, \@@_write_label:}
+% \changes{v0.2}{2022/07/26}{优化重新编译警告。}
+%
+% \begin{macro}{\@@_attach_label:, \@@_write_label:,\@@_rerun_check:}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_attach_label:
{
@@ -576,20 +858,26 @@
}
\cs_new_protected_nopar:Npn \@@_write_label:
{
- \iow_shipout_x:Nx \@auxout
+ \exp_args:Nee \@@_write_label_aux:nn
+ { \@@_counter:n { wrapstuff } }
+ { \@@_counter:n { page } }
+ }
+\cs_new_protected:Npx \@@_write_label_aux:nn #1#2
+ {
+ \prop_gput_if_new:Nnn \exp_not:N \g_@@_page_prop {#1} {#2}
+ \iow_shipout_x:Nn \exp_not:N \@auxout
{
\c_backslash_str wrapstuff at label
- { \@@_counter:n { wrapstuff } }
+ {#1}
{ \exp_not:N \wrapstuff at counter { page } }
}
}
+\newcounter { wrapstuff }
\cs_new:Npn \@@_counter:n #1
{ \int_value:w \value {#1} }
\cs_new_eq:NN \wrapstuff at counter \@@_counter:n
\cs_new_protected_nopar:Npn \wrapstuff at label
- { \@newl at bel { wrapstuff at label } }
-\tl_const:Nn \c_@@_label_tl
- { wrapstuff at label@ \int_value:w \value { wrapstuff } }
+ { \prop_gput:Nnn \g_@@_page_prop }
\@@_gadd_hook:nn { begindocument }
{
\legacy_if:nTF { @filesw }
@@ -602,7 +890,35 @@
}
{ \cs_gset_eq:NN \@@_write_label: \@@_empty: }
}
-\newcounter { wrapstuff }
+\@@_gadd_hook:nn { enddocument/afterlastpage }
+ {
+ \legacy_if:nT { @filesw }
+ { \prop_gclear:N \g_@@_page_prop }
+ }
+\@@_gadd_hook:nn { enddocument/info }
+ {
+ \prop_if_empty:NF \g_@@_rerun_prop
+ { \@@_rerun_check: }
+ }
+\cs_new_protected_nopar:Npn \@@_rerun_check:
+ {
+ \prop_map_inline:Nn \g_@@_rerun_prop
+ {
+ \prop_get:NnN \g_@@_page_prop { ##1 } \l_@@_page_tl
+ \int_if_even:nF { \l_@@_page_tl - ##2 }
+ { \prop_map_break:n { \@@_rerun_warning: } }
+ }
+ }
+\cs_new_protected_nopar:Npn \@@_rerun_warning:
+ { \msg_warning:nn { wstf } { rerun-required } }
+\msg_new:nnn { wstf } { rerun-required }
+ {
+ Page(s)~may~have~changed.\\
+ Rerun~to~get~i/o~setting~right.
+ }
+\tl_new:N \l_@@_page_tl
+\prop_new:N \g_@@_page_prop
+\prop_new:N \g_@@_rerun_prop
% \end{macrocode}
% \end{macro}
%
@@ -636,8 +952,10 @@
\keys_precompile:nnN
{ wrapstuff }
{ \l_@@_main_kv_tl } \l_@@_main_kv_tl
- \tl_gconcat:NNN \g_@@_main_setting_tl
- \g_@@_main_setting_tl \l_@@_main_kv_tl
+ \tl_gconcat:NNN
+ \g_@@_main_setting_tl
+ \g_@@_main_setting_tl
+ \l_@@_main_kv_tl
}
% \end{macrocode}
% \end{macro}
@@ -662,19 +980,22 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_swap_ratio:
{
+ \exp_args:Ne \@@_swap_ratio_aux:n
+ { \@@_counter:n { wrapstuff } }
+ }
+\cs_new_protected:Npn \@@_swap_ratio_aux:n #1
+ {
\fp_compare:nF
{ \c_zero_fp < \l_@@_ratio_fp < \c_one_fp }
{ \fp_zero:N \l_@@_ratio_fp }
- \int_if_odd:nTF
- {
- \exp_args:Ne \cs_if_exist_use:cF
- { \c_@@_label_tl }
- { \@@_counter:n { page } }
- }
+ \prop_get:NnNF \g_@@_page_prop {#1} \l_@@_page_tl
+ { \tl_set:Nx \l_@@_page_tl { \@@_counter:n { page } } }
+ \int_if_odd:nTF { \l_@@_page_tl }
{ \bool_if:NTF \l_@@_inner_bool }
{ \bool_if:NTF \l_@@_outer_bool }
{ \@@_set_ratio:N \l_@@_ratio_fp }
{ \@@_set_ratio:n { \c_one_fp - \l_@@_ratio_fp } }
+ \prop_gput:Nno \g_@@_rerun_prop {#1} { \l_@@_page_tl }
}
\bool_new:N \l_@@_swap_bool
\bool_new:N \l_@@_inner_bool
@@ -682,63 +1003,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_gadd_ht:Nn,\@@_gsub_ht:Nn}
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_gadd_ht:Nn #1#2
- { \box_gset_ht:Nn #1 { \box_ht:N #1 + \dim_eval:n {#2} } }
-\cs_new_protected:Npn \@@_gsub_ht:Nn #1#2
- { \box_gset_ht:Nn #1 { \box_ht:N #1 - \dim_eval:n {#2} } }
-% \end{macrocode}
-% \end{macro}
-%
-% \begin{macro}{\@@_clear:}
-% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_clear:
- {
- \@@_clear_para_hook:
- \@@_clear_kludge:
- \@@_clear_variable:
- }
-\cs_new_protected_nopar:Npn \@@_clear_variable:
- {
- \int_gset:Nn \g_@@_top_int { -1 }
- \int_gzero:N \g_@@_window_int
- \dim_gzero:N \g_@@_total_ht_dim
- \dim_gzero:N \g_@@_column_left_dim
- \tl_gclear:N \g_@@_main_setting_tl
- \bool_gset_false:N \g_@@_next_bool
- \bool_gset_false:N \g_@@_hoffset_bool
- \bool_gset_false:N \g_@@_next_hang_bool
- \bool_gset_false:N \g_@@_first_save_bool
- \bool_gset_false:N \g_@@_right_move_bool
- \bool_gset_false:N \g_@@_column_right_bool
- }
-\cs_new_protected_nopar:Npn \@@_clear_kludge:
- {
- \bool_if:NTF \g_@@_next_bool
- {
- \box_gclear:N \g_@@_stuff_box
- \skip_vertical:n
- { \tex_baselineskip:D * \g_@@_window_int }
- }
- {
- \box_if_empty:NF \g_@@_stuff_box
- { \@@_clear_stuff_box: }
- }
- }
-\cs_new_protected_nopar:Npn \@@_clear_stuff_box:
- {
- \@@_ignore_depth:
- \skip_set:Nn \l_@@_last_skip
- { \box_dp:N \strutbox }
- \skip_vertical:N \l_@@_last_skip
- \box_use_drop:N \g_@@_stuff_box
- \skip_vertical:N \l_@@_last_skip
- \@@_ignore_depth:
- }
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\@@_next_para:}
% 将 \env{wrapstuff} 环境之后的段落放入内部环境 \env{wrapstuff at par} 中。
% 为了控制钩子执行顺序,需要使用 |wrapstuff| 标签,
@@ -745,6 +1009,7 @@
% 而不用更为方便的 \cs{hook_gput_next_code:nn} 实现。
% \begin{macrocode}
\@@_gadd_hook:nn { para/before } { \@@_para_before: }
+\@@_gadd_hook:nn { para/after } { \@@_para_after: }
\@@_gadd_hook:nn { para/begin } { \@@_para_begin: }
\@@_gadd_hook:nn { para/end } { \@@_para_end: }
\cs_new_protected_nopar:Npn \@@_next_para:
@@ -762,6 +1027,7 @@
\cs_new_protected_nopar:Npn \@@_clear_para_hook:
{
\cs_gset_eq:NN \@@_para_before: \@@_empty:
+ \cs_gset_eq:NN \@@_para_after: \@@_empty:
\cs_gset_eq:NN \@@_para_begin: \@@_empty:
\cs_gset_eq:NN \@@_para_end: \@@_empty:
}
@@ -768,6 +1034,7 @@
\cs_new_protected_nopar:Npn \@@_empty:
{ }
\cs_new_eq:NN \@@_para_before: \@@_empty:
+\cs_new_eq:NN \@@_para_after: \@@_empty:
\cs_new_eq:NN \@@_para_begin: \@@_empty:
\cs_new_eq:NN \@@_para_end: \@@_empty:
% \end{macrocode}
@@ -812,8 +1079,8 @@
\int_set:Nn \l_@@_window_int { \l_@@_window_int * 2 }
\int_set:Nn \l_@@_window_line_int
{
- \bool_if:NTF \g_@@_column_right_bool
- { \l_@@_window_int / 2 + \g_@@_column_window_int }
+ \bool_if:NTF \g_@@_column_bool
+ { \l_@@_window_int / 2 + \g_@@_column_int }
{ \l_@@_window_int }
}
}
@@ -820,6 +1087,7 @@
\cs_gset_eq:NN \@@_para_before: \@@_empty:
\cs_gset_eq:NN \@@_para_begin: \@@_empty:
\@@_save_parshape:
+ \@@_parbox_restore:
\vbox_set:Nw \l_@@_body_box
\@@_set_prevdepth:N \g_@@_prevdepth_dim
\@@_save_tex_skip:
@@ -839,7 +1107,8 @@
\int_gset_eq:NN \g_@@_line_int \tex_prevgraf:D
\vbox_set_end:
\@@_adjust_tex_skip:
- \cs_gset_eq:NN \@@_para_end: \@@_empty:
+ \cs_gset_eq:NN \@@_para_end: \@@_empty:
+ \cs_gset_eq:NN \@@_para_after: \@@_empty:
\int_compare:nNnTF \g_@@_line_int > \l_@@_top_int
{ \@@_build_par: }
{ \@@_put_par: }
@@ -847,10 +1116,8 @@
\box_new:N \l_@@_body_box
\box_new:N \l_@@_window_box
\int_new:N \l_@@_window_int
-\int_new:N \g_@@_window_int
\int_new:N \g_@@_line_int
\int_new:N \l_@@_window_line_int
-\int_new:N \g_@@_column_window_int
\dim_new:N \l_@@_l_dim
\dim_new:N \l_@@_r_dim
\dim_new:N \l_@@_min_dim
@@ -860,10 +1127,7 @@
\dim_new:N \l_@@_voffset_dim
\dim_new:N \l_@@_leftsep_dim
\dim_new:N \l_@@_rightsep_dim
-\dim_new:N \g_@@_window_ht_dim
\dim_new:N \l_@@_main_width_dim
-\int_new:N \g_@@_top_int
-\int_gdecr:N \g_@@_top_int
\bool_new:N \l_@@_hang_bool
% \end{macrocode}
% \end{macro}
@@ -873,9 +1137,7 @@
\cs_new_protected_nopar:Npn \@@_set_hang_left:
{
\bool_set_true:N \l_@@_hang_bool
- \bool_if:NF \g_@@_hoffset_bool
- { \@@_set_hoffset:NN \l_@@_rightsep_dim \use:nn }
- \dim_sub:Nn \l_@@_window_dim { \l_@@_rightsep_dim }
+ \@@_set_hoffset:N \l_@@_rightsep_dim
\dim_zero:N \l_@@_l_dim
\dim_set_eq:NN \l_@@_r_dim \l_@@_window_dim
\cs_set_eq:NN \@@_build_box: \@@_build_hang:
@@ -883,9 +1145,7 @@
\cs_new_protected_nopar:Npn \@@_set_hang_right:
{
\bool_set_true:N \l_@@_hang_bool
- \bool_if:NF \g_@@_hoffset_bool
- { \@@_set_hoffset:NN \l_@@_leftsep_dim \use_ii_i:nn }
- \dim_sub:Nn \l_@@_window_dim { \l_@@_leftsep_dim }
+ \@@_set_hoffset:N \l_@@_leftsep_dim
\dim_zero:N \l_@@_r_dim
\dim_set_eq:NN \l_@@_l_dim \l_@@_window_dim
\cs_set_eq:NN \@@_build_box: \@@_build_hang:
@@ -903,28 +1163,23 @@
{ \cs_set_eq:NN \@@_build_box: \@@_build_column: }
{ \cs_set_eq:NN \@@_build_box: \@@_build_block: }
}
-\cs_new_protected:Npn \@@_set_hoffset:NN #1#2
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.2}{2022/07/24}{修复 \opt{hoffset} 选项。}
+%
+% \begin{macro}{\@@_set_hoffset:N}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_set_hoffset:N #1
{
- \bool_gset_true:N \g_@@_hoffset_bool
- \dim_set:Nn \l_@@_hoffset_width_dim
- { #1 + \g_@@_stuff_wd_dim }
+ \dim_sub:Nn \l_@@_window_dim {#1}
\group_begin:
- \cs_set_eq:NN \width \l_@@_hoffset_width_dim
- \dim_gset:Nn \g_@@_hoffset_dim { \l_@@_hoffset_tl }
- \group_end:
- \int_compare:nNnF \g_@@_hoffset_dim = \c_zero_dim
- {
- \hbox_gset:Nn \g_@@_stuff_box
- {
- #2 { \tex_kern:D - \g_@@_hoffset_dim }
- { \box_use_drop:N \g_@@_stuff_box }
- }
- \dim_add:Nn \l_@@_window_dim { \g_@@_hoffset_dim }
- }
+ \dim_set:Nn \l_@@_width_dim { #1 + \g_@@_stuff_wd_dim }
+ \cs_set_eq:NN \width \l_@@_width_dim
+ \exp_args:NNNx \group_end:
+ \dim_add:Nn \l_@@_window_dim
+ { \dim_eval:n { \l_@@_hoffset_tl } }
}
-\dim_new:N \g_@@_hoffset_dim
-\dim_new:N \l_@@_hoffset_width_dim
-\bool_new:N \g_@@_hoffset_bool
% \end{macrocode}
% \end{macro}
%
@@ -952,9 +1207,9 @@
}
\cs_new_protected_nopar:Npn \@@_window_init:
{
- \int_gset_eq:NN \g_@@_column_window_int \l_@@_window_int
+ \int_gset_eq:NN \g_@@_column_int \l_@@_window_int
\dim_gset:Nn \g_@@_window_ht_dim
- { \tex_baselineskip:D * \g_@@_column_window_int }
+ { \tex_baselineskip:D * \g_@@_column_int }
\tl_if_empty:NF \l_@@_lines_tl
{
\dim_gset:Nn \g_@@_remaining_dim
@@ -1011,7 +1266,8 @@
\int_compare:nNnTF \g_@@_parshape_int = \c_one_int
{
\tex_parshape:D \g_@@_parshape_int
- \g_@@_parshape_indent_dim \g_@@_parshape_length_dim
+ \g_@@_parshape_indent_dim
+ \g_@@_parshape_length_dim
}
{ \@@_restore_hangfrom: }
}
@@ -1050,8 +1306,6 @@
\int_new:N \g_@@_parshape_int
\int_new:N \g_@@_hangafter_int
\dim_new:N \g_@@_hangindent_dim
-\dim_new:N \g_@@_parshape_indent_dim
-\dim_new:N \g_@@_parshape_length_dim
% \end{macrocode}
% \end{macro}
%
@@ -1087,16 +1341,15 @@
{ \fp_to_dim:n { #1 \dim_to_fp:n {#2} } }
\cs_new:Npn \@@_unit:n #1
{
- \fp_eval:n
+ \int_eval:n
{
- ceil
- (
- \dim_to_decimal_in_unit:nn
- {#1}
- { \tex_baselineskip:D }
- )
+ \exp_last_unbraced:Ne \@@_unit_aux:w
+ { \dim_to_decimal_in_unit:nn {#1} { \tex_baselineskip:D } }
+ \s_stop
}
}
+\cs_new:Npn \@@_unit_aux:w #1 . #2 \s_stop
+ { #1 + 1 }
% \end{macrocode}
% \end{macro}
%
@@ -1131,6 +1384,7 @@
\skip_set_eq:NN \tex_leftskip:D \g_@@_left_skip
\skip_set_eq:NN \tex_rightskip:D \g_@@_right_skip
\skip_set_eq:NN \tex_parfillskip:D \g_@@_parfill_skip
+ \skip_set_eq:NN \tex_baselineskip:D \g_@@_baseline_skip
}
\skip_new:N \g_@@_left_skip
\skip_new:N \g_@@_right_skip
@@ -1148,19 +1402,35 @@
\tex_everydisplay:D \exp_after:wN
{
\tex_the:D \tex_everydisplay:D
- \@@_test_leqno:
- \dim_compare:nNnF \tex_displaywidth:D < \c_max_dim
- {
- \bool_gset_true:N \g_@@_display_bool
- \dim_set_eq:NN \tex_displaywidth:D \l_@@_display_dim
- }
+ \@@_display_hook:
}
}
+\cs_new_protected_nopar:Npn \@@_display_hook:
+ {
+ \@@_test_leqno:
+ \dim_compare:nNnF \tex_displaywidth:D < \c_max_dim
+ {
+ \bool_gset_true:N \g_@@_display_bool
+ \dim_set_eq:NN \tex_displaywidth:D \l_@@_display_dim
+ }
+ }
\cs_new_eq:NN \@@_test_leqno: \@@_empty:
-\bool_new:N \g_@@_display_bool
+\cs_new_protected_nopar:Npn \@@_clear_display_hook:
+ { \cs_gset_eq:NN \@@_display_hook: \@@_empty: }
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_split_parameter:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_split_parameter:
+ {
+ \skip_zero:N \tex_splittopskip:D
+ \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
+ \int_set_eq:NN \tex_vbadness:D \c_max_int
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_build_par:}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_build_par:
@@ -1207,7 +1477,7 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_put_body_box:
{
- \para_raw_end:
+ \@@_para_raw_end:
\dim_compare:nNnTF { \box_wd:N \l_@@_body_box } < \c_max_dim
{ \@@_put_body_aux:N \l_@@_body_box }
{
@@ -1215,14 +1485,34 @@
\@@_put_body_aux:N \l_@@_body_box
\box_set_eq_drop:NN \l_@@_body_box \l_@@_bottom_box
}
- \para_raw_end:
+ \@@_para_raw_end:
}
\cs_new_protected_nopar:Npn \@@_put_body_aux:N #1
{
\dim_gset:Nn \g_@@_prevdepth_dim { \box_dp:N #1 }
+ \dim_compare:nNnT \g_@@_prevdepth_dim = \c_zero_dim
+ { \@@_extract_depth:N #1 }
\vbox_unpack_drop:N #1
\@@_set_prevdepth:N \g_@@_prevdepth_dim
}
+\cs_new_protected_nopar:Npn \@@_extract_depth:N #1
+ {
+ \vbox_set:Nn \l_@@_last_box
+ {
+ \vbox_unpack:N #1
+ \@@_if_last_hlist:F
+ {
+ \tex_unskip:D \tex_unpenalty:D
+ \tex_unskip:D \tex_unpenalty:D
+ }
+ \@@_if_last_hlist:T
+ {
+ \box_set_to_last:N \l_@@_last_box
+ \dim_gset:Nn \g_@@_prevdepth_dim
+ { \box_dp:N \l_@@_last_box }
+ }
+ }
+ }
% \end{macrocode}
% \end{macro}
%
@@ -1253,20 +1543,24 @@
}
\cs_new_protected_nopar:Npn \@@_build_display_amsmath:
{
- \vbox_gset:Nn \g_@@_equation_box
- {
- \skip_vertical:n { - \g_@@_display_pre_skip }
- \vbox_unpack_drop:N \g_@@_display_box
- \skip_gset_eq:NN \g_@@_pos_skip \tex_lastskip:D
- \tex_unskip:D
- \int_gset_eq:NN \g_@@_pos_int \tex_lastpenalty:D
- \tex_unpenalty:D
- \skip_gadd:Nn \g_@@_pos_skip { \tex_lastskip:D }
- \tex_unskip:D
- \tex_unpenalty:D
- }
- \box_gset_wd:Nn \g_@@_equation_box
- { \l_@@_display_dim }
+ \group_begin:
+ \vbox_gset:Nn \g_@@_equation_box
+ {
+ \@@_break:
+ \vbox_unpack_drop:N \g_@@_display_box
+ \skip_gset_eq:NN \g_@@_pos_skip \tex_lastskip:D
+ \tex_unskip:D
+ \int_gset_eq:NN \g_@@_pos_int \tex_lastpenalty:D
+ \tex_unpenalty:D
+ \skip_gadd:Nn \g_@@_pos_skip { \tex_lastskip:D }
+ \tex_unskip:D
+ \tex_unpenalty:D
+ }
+ \@@_split_parameter:
+ \vbox_set_split_to_ht:NNn \l_@@_last_box \g_@@_equation_box
+ { \c_zero_dim }
+ \group_end:
+ \box_gset_wd:Nn \g_@@_equation_box { \l_@@_display_dim }
\vbox_gset:Nn \g_@@_display_box
{
\tex_penalty:D \g_@@_display_pre_int
@@ -1344,35 +1638,64 @@
\cs_new_protected_nopar:Npn \@@_build_display_auxiii:
{
\bool_set_true:N \l_@@_attach_equation_bool
- \bool_if:NTF \g_@@_amsmath_bool
- { \box_set_eq_drop:NN \l_@@_display_box \g_@@_display_box }
+ \box_gclear:N \g_@@_display_box
+ \bool_if:NF \g_@@_amsmath_bool
+ { \@@_adjust_equation: }
+ \@@_build_body_box:
+ }
+\bool_new:N \l_@@_display_bool
+\bool_new:N \l_@@_attach_equation_bool
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.2}{2022/07/23}{改进对显示数学公式的处理。}
+%
+% \begin{macro}{\@@_attach_left:N,\@@_attach_right:N}
+% \begin{macrocode}
+\cs_new_protected:Npn \@@_attach_left:N #1
+ {
+ \@@_attach_equation:Nn #1
+ { \g_@@_parshape_indent_dim }
+ }
+\cs_new_protected:Npn \@@_attach_right:N #1
+ {
+ \@@_attach_equation:Nn #1
{
- \box_gclear:N \g_@@_display_box
- \@@_adjust_equation:
+ \l_@@_line_dim
+ - \l_@@_display_dim
+ + \g_@@_parshape_indent_dim
}
- \@@_build_body_box:
}
-\cs_new_protected_nopar:Npn \@@_attach_equation:N
+\cs_new_protected:Npn \@@_attach_equation:Nn #1#2
{
- \bool_if:NTF \g_@@_amsmath_bool
- { \@@_attach_equation_amsmath:N }
- { \@@_attach_equation_normal:N }
+ \vbox_set:Nn \l_@@_last_box
+ {
+ \vbox_unpack:N #1
+ \box_set_to_last:N \l_@@_last_box
+ \bool_if:NTF \g_@@_amsmath_bool
+ { \@@_attach_equation_amsmath:Nn }
+ { \@@_attach_equation_normal:Nn }
+ \l_@@_last_box {#2}
+ }
}
-\cs_new_protected:Npn \@@_attach_equation_amsmath:N #1
+\cs_new_protected:Npn \@@_attach_equation_amsmath:Nn #1#2
{
- \vbox_set:Nn #1
+ \vbox_gset:Nn \g_@@_equation_box
{
- \box_use:N #1
- \@@_ignore_depth:
- \vbox_unpack_drop:N \l_@@_display_box
+ \@@_nobreak:
\skip_vertical:n
- { \g_@@_display_pre_dim - \box_dp:N #1 }
- \box_use_drop:N \g_@@_equation_box
+ {
+ \g_@@_display_pre_skip
+ + \g_@@_display_pre_dim
+ - \box_dp:N #1
+ }
+ \box_move_right:nn {#2}
+ { \box_use_drop:N \g_@@_equation_box }
}
}
-\cs_new_protected:Npn \@@_attach_equation_normal:N #1
+\cs_new_protected:Npn \@@_attach_equation_normal:Nn #1#2
{
- \vbox_set:Nn #1
+ \vbox_set:Nn \l_@@_last_box
{
\@@_tex_parameter:
\dim_set_eq:NN \tex_hsize:D \l_@@_display_dim
@@ -1384,6 +1707,25 @@
\tex_unskip:D
\int_gset_eq:NN \g_@@_pos_int \tex_lastpenalty:D
\tex_unpenalty:D
+ \box_set_to_last:N \l_@@_last_box
+ \skip_set_eq:NN \l_@@_last_skip \tex_lastskip:D
+ \tex_unskip:D
+ \skip_add:Nn \l_@@_last_skip { \tex_lastskip:D }
+ \vbox_gset:Nn \g_@@_equation_box
+ {
+ \@@_nobreak:
+ \skip_vertical:N \l_@@_last_skip
+ \box_move_right:nn {#2}
+ {
+ \hbox_to_wd:nn
+ { \l_@@_display_dim }
+ {
+ \tex_hss:D
+ \box_use_drop:N \l_@@_last_box
+ \tex_hss:D
+ }
+ }
+ }
}
}
\cs_new_protected_nopar:Npn \@@_insert_equation:
@@ -1419,15 +1761,15 @@
{
\bool_gset_false:N \g_@@_eqnum_bool
\hbox_unpack:N \g_@@_equation_box
- \@@_if_last_hlist:F { \use_none_delimit_by_q_stop:w }
+ \@@_if_last_hlist:F { \use_none_delimit_by_s_stop:w }
\box_gset_to_last:N \g_@@_eqnum_box
- \@@_if_last_kern:F { \use_none_delimit_by_q_stop:w }
+ \@@_if_last_kern:F { \use_none_delimit_by_s_stop:w }
\tex_unkern:D
- \@@_if_last_hlist:F { \use_none_delimit_by_q_stop:w }
+ \@@_if_last_hlist:F { \use_none_delimit_by_s_stop:w }
\box_gset_to_last:N \g_@@_eqbody_box
- \@@_if_last_none:F { \use_none_delimit_by_q_stop:w }
+ \@@_if_last_none:F { \use_none_delimit_by_s_stop:w }
\bool_gset_true:N \g_@@_eqnum_bool
- \use_none_delimit_by_q_stop:w \q_stop
+ \use_none_delimit_by_s_stop:w \s_stop
}
}
\cs_new_protected_nopar:Npn \@@_adjust_equation_width:
@@ -1457,27 +1799,26 @@
\box_new:N \g_@@_eqbody_box
\box_new:N \g_@@_eqnum_box
\box_new:N \g_@@_equation_box
-\box_new:N \l_@@_display_box
\int_new:N \g_@@_pos_int
\skip_new:N \g_@@_pos_skip
\bool_new:N \g_@@_eqnum_bool
-\bool_new:N \g_@@_leqno_bool
-\bool_new:N \l_@@_display_bool
-\bool_new:N \l_@@_attach_equation_bool
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_add_pos_skip:}
+% \begin{macro}{\@@_add_pos_kludge:}
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_add_pos_skip:
+\cs_new_protected_nopar:Npn \@@_add_pos_kludge:
{
- \bool_lazy_or:nnTF
- { \g_@@_right_move_bool }
- { \int_compare_p:nNn \g_@@_window_int > \c_zero_int }
+ \dim_gset:Nn \g_@@_prevdepth_dim
+ { \box_dp:N \l_@@_window_box }
+ \bool_gset_false:N \g_@@_equation_dp_bool
+ \bool_if:NTF \g_@@_next_bool
{
\tex_vadjust:D
{
- \tex_penalty:D \c_@@_nobreak_int
+ \box_if_empty:NF \g_@@_equation_box
+ { \@@_output_equation_box: }
+ \@@_nobreak:
\bool_if:NT \l_@@_display_bool
{ \skip_vertical:N \g_@@_pos_skip }
}
@@ -1487,6 +1828,8 @@
{
\tex_vadjust:D
{
+ \box_if_empty:NF \g_@@_equation_box
+ { \@@_output_equation_box: }
\tex_penalty:D \g_@@_pos_int
\skip_vertical:N \g_@@_pos_skip
}
@@ -1495,6 +1838,23 @@
\int_gzero:N \g_@@_pos_int
\skip_gzero:N \g_@@_pos_skip
}
+\cs_new_protected_nopar:Npn \@@_output_equation_box:
+ {
+ \cs_gset_eq:NN
+ \@@_para_after:
+ \@@_set_equation_depth:
+ \bool_gset_true:N \g_@@_equation_dp_bool
+ \dim_gset:Nn \g_@@_prevdepth_dim
+ { \box_dp:N \g_@@_equation_box }
+ \vbox_unpack_drop:N \g_@@_equation_box
+ }
+\cs_new_protected_nopar:Npn \@@_set_equation_depth:
+ {
+ \cs_gset_eq:NN \@@_para_after: \@@_empty:
+ \bool_gset_false:N \g_@@_equation_dp_bool
+ \@@_set_prevdepth:N \g_@@_prevdepth_dim
+ }
+\bool_new:N \g_@@_equation_dp_bool
% \end{macrocode}
% \end{macro}
%
@@ -1522,9 +1882,6 @@
{
\vbox_set:Nn \l_@@_body_box
{
- \@@_tex_parameter:
- \@@_make_parshape:
- \@@_column_penalties:
\dim_zero:N \tex_emergencystretch:D
\dim_set_eq:NN \tex_hfuzz:D \c_max_dim
\dim_set_eq:NN \tex_vfuzz:D \c_max_dim
@@ -1533,6 +1890,9 @@
\int_set:Nn \tex_tolerance:D { 1000 }
\para_raw_noindent:
\hbox_unpack_drop:N \l_@@_bottom_box
+ \@@_tex_parameter:
+ \@@_make_parshape:
+ \@@_interline_penalties:
\para_raw_end:
\int_gset_eq:NN \g_@@_line_int \tex_prevgraf:D
}
@@ -1560,8 +1920,8 @@
{ \c_zero_dim \l_@@_l_dim }
\prg_replicate:nn
{
- \bool_if:NTF \g_@@_column_right_bool
- { \g_@@_column_window_int }
+ \bool_if:NTF \g_@@_column_bool
+ { \g_@@_column_int }
{ \l_@@_window_int / 2 }
}
{ \c_zero_dim \l_@@_r_dim }
@@ -1580,17 +1940,18 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_column_penalties:}
+% \begin{macro}{\@@_interline_penalties:}
% \begin{macrocode}
-\cs_new_protected_nopar:Npn \@@_column_penalties:
+\cs_new_protected_nopar:Npn \@@_interline_penalties:
{
\bool_if:NF \l_@@_hang_bool
{
- \bool_if:NT \l_@@_column_bool
- { \@@_column_penalties_aux: }
+ \bool_if:NTF \l_@@_column_bool
+ { \@@_column_penalties: }
+ { \@@_block_penalties: }
}
}
-\cs_new_protected_nopar:Npn \@@_column_penalties_aux:
+\cs_new_protected_nopar:Npn \@@_column_penalties:
{
\tex_interlinepenalties:D
\int_eval:n { \l_@@_window_int / 2 + \c_one_int } ~
@@ -1600,95 +1961,82 @@
\c_@@_break_int
\c_zero_int
}
+\cs_new_protected_nopar:Npn \@@_block_penalties:
+ {
+ \tex_interlinepenalties:D \l_@@_window_int
+ \prg_replicate:nn
+ { \l_@@_window_int - \c_one_int }
+ { \c_@@_break_int }
+ \c_zero_int
+ }
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_break:,\@@_nobreak:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_break:
+ { \tex_penalty:D \c_@@_break_int }
+\cs_new_protected_nopar:Npn \@@_nobreak:
+ { \tex_penalty:D \c_@@_nobreak_int }
+\int_const:Nn \c_@@_break_int { -10000 }
+\int_const:Nn \c_@@_nobreak_int { 10000 }
+% \end{macrocode}
+% \end{macro}
+%
+% \changes{v0.2}{2022/07/22}{提高稳定性。}
+%
% \begin{macro}{\@@_build_box:, \@@_build_block:}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_build_block:
{
- \@@_build_block_auxi:
\vbox_set:Nn \l_@@_window_box
{
- \@@_tex_parameter:
- \dim_set_eq:NN \tex_hsize:D \l_@@_line_dim
- \para_raw_noindent:
- \hbox_unpack_drop:N \g_@@_line_box
- \para_raw_end:
+ \@@_split_parameter:
+ \skip_set_eq:NN \tex_baselineskip:D \g_@@_baseline_skip
+ \@@_build_line:
}
- \bool_if:NT \l_@@_attach_equation_bool
- {
- \box_set_ht:Nn \l_@@_window_box
- { \box_ht_plus_dp:N \l_@@_window_box - \g_@@_dp_dim }
- \box_set_dp:Nn \l_@@_window_box { \g_@@_dp_dim }
- }
}
-\cs_new_protected_nopar:Npn \@@_build_block_auxi:
+\cs_new_protected_nopar:Npn \@@_build_line:
{
- \vbox_set:Nn \l_@@_body_box
+ \vbox_set_split_to_ht:NNn \l_@@_l_box \l_@@_body_box
+ { \g_@@_baseline_skip }
+ \vbox_set_split_to_ht:NNn \l_@@_r_box \l_@@_body_box
+ { \g_@@_baseline_skip }
+ \@@_build_line_repack:
+ \box_if_empty:NTF \l_@@_body_box
+ { \@@_put_last_line: }
{
- \vbox_unpack_drop:N \l_@@_body_box
- \bool_lazy_and:nnTF
- { \box_if_empty_p:N \l_@@_bottom_box }
- { \int_if_odd_p:n { \g_@@_line_int } }
- { \box_set_eq:NN \l_@@_r_box \l_@@_empty_box }
- {
- \box_set_to_last:N \l_@@_r_box
- \tex_unskip:D \tex_unpenalty:D
- }
- \box_set_to_last:N \l_@@_l_box
- \tex_unskip:D \tex_unpenalty:D
- \hbox_gset:Nn \g_@@_line_box
- {
- \bool_if:NT \l_@@_attach_equation_bool
- { \@@_build_block_attach: }
- \box_use:N \l_@@_l_box
- \tex_hfill:D
- \box_use:N \l_@@_r_box
- }
- \@@_build_block_auxii:
+ \@@_put_line_box:
+ \@@_build_line:
}
}
-\cs_new_protected_nopar:Npn \@@_build_block_auxii:
+\cs_new_protected_nopar:Npn \@@_build_line_repack:
{
- \int_case:nnTF
- { \tex_lastnodetype:D }
+ \vbox_set:Nn \l_@@_l_box
+ { \vbox_unpack_drop:N \l_@@_l_box }
+ \box_if_empty:NF \l_@@_r_box
{
- { \c_@@_none_node } { }
- { \c_@@_whatsit_node } { }
+ \vbox_set:Nn \l_@@_r_box
+ { \vbox_unpack_drop:N \l_@@_r_box }
}
- { \@@_build_block_finalise: }
- { \@@_build_block_auxiii: }
+ \@@_save_first_ht:
}
-\cs_new_protected_nopar:Npn \@@_build_block_auxiii:
+\cs_new_protected_nopar:Npn \@@_put_last_line:
{
- \box_set_to_last:N \l_@@_r_box
- \tex_unskip:D \tex_unpenalty:D
- \box_set_to_last:N \l_@@_l_box
- \tex_unskip:D \tex_unpenalty:D
- \hbox_gset:Nn \g_@@_line_box
- {
- \box_use:N \l_@@_l_box
- \tex_hfill:D
- \box_use:N \l_@@_r_box
- \tex_penalty:D \c_@@_break_int
- \hbox_unpack_drop:N \g_@@_line_box
- }
- \@@_build_block_auxii:
+ \bool_if:NT \l_@@_attach_equation_bool
+ { \@@_attach_left:N \l_@@_l_box }
+ \@@_put_line_box:
}
-\cs_new_protected_nopar:Npn \@@_build_block_attach:
+\cs_new_protected_nopar:Npn \@@_put_line_box:
{
- \box_set_eq:NN \l_@@_last_box \l_@@_l_box
- \@@_attach_equation:N \l_@@_last_box
- \dim_gset:Nn \g_@@_dp_dim { \box_dp:N \l_@@_last_box }
- \hbox_set:Nn \l_@@_l_box
+ \hbox_to_wd:nn { \l_@@_line_dim }
{
- \box_move_down:nn
- { \box_ht:N \l_@@_last_box - \box_ht:N \l_@@_l_box }
- { \box_use_drop:N \l_@@_last_box }
+ \box_use_drop:N \l_@@_l_box
+ \tex_hfil:D
+ \box_use_drop:N \l_@@_r_box
}
}
-\cs_new_protected_nopar:Npn \@@_build_block_finalise:
+\cs_new_protected_nopar:Npn \@@_save_first_ht:
{
\dim_gset:Nn \g_@@_ht_dim
{
@@ -1696,16 +2044,11 @@
{ \box_ht:N \l_@@_l_box }
{ \box_ht:N \l_@@_r_box }
}
+ \cs_set_eq:NN \@@_save_first_ht: \@@_empty:
}
-\dim_new:N \g_@@_dp_dim
\dim_new:N \g_@@_ht_dim
\box_new:N \l_@@_l_box
\box_new:N \l_@@_r_box
-\box_new:N \g_@@_line_box
-\box_new:N \l_@@_empty_box
-\hbox_set:Nn \l_@@_empty_box { }
-\int_const:Nn \c_@@_break_int { -10000 }
-\int_const:Nn \c_@@_nobreak_int { 10000 }
% \end{macrocode}
% \end{macro}
%
@@ -1716,23 +2059,13 @@
\hbox_set_to_wd:Nnn \l_@@_window_box
{ \l_@@_line_dim }
{
- \skip_zero:N \tex_splittopskip:D
- \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
- \int_set_eq:NN \tex_vbadness:D \c_max_int
+ \@@_split_parameter:
\@@_build_column_aux:
\box_if_empty:NT \l_@@_bottom_box
{ \@@_build_column_fuzzy_aux: }
- \dim_gset:Nn \g_@@_ht_dim { \box_ht:N \l_@@_l_box }
- \vbox_set:Nn \l_@@_l_box
- {
- \vbox_unpack_drop:N \l_@@_l_box
- \bool_if:NT \l_@@_attach_equation_bool
- {
- \box_set_to_last:N \l_@@_last_box
- \@@_attach_equation:N \l_@@_last_box
- \vbox_unpack_drop:N \l_@@_last_box
- }
- }
+ \@@_repack_left_box:
+ \bool_if:NT \l_@@_attach_equation_bool
+ { \@@_attach_left:N \l_@@_l_box }
\box_use:N \l_@@_l_box
\tex_hfil:D
\box_move_up:nn
@@ -1743,7 +2076,7 @@
\cs_new_protected_nopar:Npn \@@_build_column_aux:
{
\vbox_set_split_to_ht:NNn \l_@@_l_box \l_@@_body_box
- { \c_zero_dim }
+ { \box_ht:N \l_@@_body_box / 2 }
\vbox_set_top:Nn \l_@@_l_box
{ \vbox_unpack_drop:N \l_@@_l_box }
\box_set_eq_drop:NN \l_@@_r_box \l_@@_body_box
@@ -1769,17 +2102,21 @@
\cs_new_protected_nopar:Npn \@@_rebuild_window:
{
\int_compare:nNnT \l_@@_window_int > { 2 }
- {
- \int_sub:Nn \l_@@_window_int { 2 }
- \box_set_eq_drop:NN \l_@@_last_l_box \l_@@_l_box
- \box_set_eq_drop:NN \l_@@_last_r_box \l_@@_r_box
- \box_set_eq:NN \l_@@_bottom_box \l_@@_save_body_box
- \int_set_eq:NN \l_@@_window_line_int \l_@@_window_int
- \@@_build_window:
- \@@_build_column_aux:
- \@@_build_column_fuzzy_aux:
- }
+ { \@@_rebuild_window_aux: }
}
+\cs_new_protected_nopar:Npn \@@_rebuild_window_aux:
+ {
+ \int_sub:Nn \l_@@_window_int { 2 }
+ \box_set_eq_drop:NN \l_@@_last_l_box \l_@@_l_box
+ \box_set_eq_drop:NN \l_@@_last_r_box \l_@@_r_box
+ \box_set_eq:NN \l_@@_bottom_box \l_@@_save_body_box
+ \int_set_eq:NN \l_@@_window_line_int \l_@@_window_int
+ \@@_build_window:
+ \@@_build_column_aux:
+ \@@_build_column_fuzzy_aux:
+ }
+\box_new:N \l_@@_last_l_box
+\box_new:N \l_@@_last_r_box
% \end{macrocode}
% \end{macro}
%
@@ -1788,9 +2125,7 @@
\cs_new_protected_nopar:Npn \@@_build_column_strict:
{
\group_begin:
- \skip_zero:N \tex_splittopskip:D
- \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
- \int_set_eq:NN \tex_vbadness:D \c_max_int
+ \@@_split_parameter:
\@@_build_column_aux:
\box_if_empty:NTF \l_@@_r_box
{ \@@_build_column_strict_auxi: }
@@ -1798,7 +2133,7 @@
\box_if_empty:NTF \l_@@_bottom_box
{ \@@_build_column_strict_auxii: }
{
- \bool_if:NTF \g_@@_column_right_bool
+ \bool_if:NTF \g_@@_column_bool
{ \@@_build_column_strict_auxiii: }
{ \@@_build_column_strict_auxiv: }
}
@@ -1810,9 +2145,9 @@
{
\@@_repack_left_box:
\bool_if:NT \l_@@_attach_equation_bool
- { \@@_column_attach:N \l_@@_l_box }
+ { \@@_attach_left:N \l_@@_l_box }
\box_gset_eq_drop:NN \g_@@_window_box \l_@@_l_box
- \bool_gset_true:N \g_@@_column_right_bool
+ \bool_gset_true:N \g_@@_column_bool
\bool_if:NF \g_@@_first_save_bool
{
\bool_gset_true:N \g_@@_first_save_bool
@@ -1837,12 +2172,12 @@
\dim_gsub:Nn \g_@@_first_sep_dim
{ \box_dp:N \l_@@_window_box }
\bool_gset_false:N \g_@@_entire_bool
- \dim_gzero:N \g_@@_column_right_ht_dim
+ \dim_gzero:N \g_@@_column_ht_dim
\dim_gset_eq:NN \g_@@_prevdepth_dim \g_@@_first_dp_dim
\@@_column_right_move_set:nn
{ \g_@@_stuff_ht_dim }
{ \g_@@_window_ht_dim }
- \int_gset_eq:NN \g_@@_window_int \g_@@_column_window_int
+ \int_gset_eq:NN \g_@@_window_int \g_@@_column_int
}
\cs_new_protected:Npn \@@_column_right_move_set:nn #1#2
{
@@ -1861,7 +2196,7 @@
\@@_make_next_stuff:nn
{ \l_@@_line_dim - \l_@@_r_dim - \l_@@_rightsep_dim }
{#1}
- \dim_gset:Nn \g_@@_column_left_dim {#2}
+ \dim_gset:Nn \g_@@_column_room_dim {#2}
\int_gzero:N \g_@@_top_int
}
\cs_new_protected_nopar:Npn \@@_build_column_strict_auxii:
@@ -1869,11 +2204,12 @@
\bool_gset_false:N \g_@@_entire_bool
\@@_repack_left_box:
\bool_if:NT \l_@@_attach_equation_bool
- { \@@_column_attach:N \l_@@_r_box }
+ { \@@_attach_right:N \l_@@_r_box }
\dim_gset:Nn \g_@@_hang_ht_dim
{
\g_@@_stuff_ht_dim - \tex_baselineskip:D *
\@@_unit:n { \box_ht_plus_dp:N \l_@@_r_box }
+ - \box_ht_plus_dp:N \g_@@_equation_box
- \g_@@_pos_skip
}
\dim_compare:nNnTF \g_@@_hang_ht_dim > \c_zero_dim
@@ -1886,19 +2222,21 @@
{
\int_compare:nNnTF \g_@@_window_int > \c_zero_int
{
- \dim_gset:Nn \g_@@_column_left_dim
+ \dim_gset:Nn \g_@@_column_room_dim
{
\g_@@_window_ht_dim
- \g_@@_first_sep_dim
- - \box_ht:N \l_@@_r_box
+ - \box_ht_plus_dp:N \l_@@_r_box
+ - \box_ht_plus_dp:N \g_@@_equation_box
}
\@@_next_hang_para:
}
{
- \dim_gset:Nn \g_@@_column_left_dim
+ \dim_gset:Nn \g_@@_column_room_dim
{
\box_ht:N \l_@@_l_box
- - \box_ht:N \l_@@_r_box
+ - \box_ht_plus_dp:N \l_@@_r_box
+ - \box_ht_plus_dp:N \g_@@_equation_box
}
\dim_gset:Nn \g_@@_first_sep_dim
{ \tex_baselineskip:D - \g_@@_ht_dim }
@@ -1911,11 +2249,15 @@
\box_use:N \l_@@_l_box
\tex_hfil:D
\box_move_up:nn
- { \g_@@_column_left_dim }
+ { \g_@@_column_room_dim }
{ \box_use:N \l_@@_r_box }
}
- \dim_gset:Nn \g_@@_column_right_ht_dim
- { \box_ht:N \l_@@_r_box + \g_@@_pos_skip }
+ \dim_gset:Nn \g_@@_column_ht_dim
+ {
+ \box_ht_plus_dp:N \l_@@_r_box
+ + \box_ht_plus_dp:N \g_@@_equation_box
+ + \g_@@_pos_skip
+ }
}
\cs_new_protected_nopar:Npn \@@_column_put_right:
{
@@ -1942,7 +2284,7 @@
{
\@@_column_right_move_set:nn
{ \g_@@_hang_ht_dim }
- { \g_@@_column_left_dim }
+ { \g_@@_column_room_dim }
\int_gzero:N \g_@@_window_int
}
\bool_gset_false:N \g_@@_next_hang_bool
@@ -1949,7 +2291,7 @@
}
\cs_new_protected_nopar:Npn \@@_build_column_strict_auxiii:
{
- \bool_gset_false:N \g_@@_column_right_bool
+ \bool_gset_false:N \g_@@_column_bool
\@@_repack_left_box:
\hbox_gset_to_wd:Nnn \g_@@_window_box
{ \l_@@_line_dim }
@@ -1980,32 +2322,8 @@
\vbox_set:Nn \l_@@_l_box
{ \vbox_unpack_drop:N \l_@@_l_box }
}
-\cs_new_protected_nopar:Npn \@@_column_attach:N #1
- {
- \vbox_set:Nn #1
- {
- \vbox_unpack_drop:N #1
- \box_set_to_last:N \l_@@_last_box
- \@@_attach_equation:N \l_@@_last_box
- \vbox_unpack_drop:N \l_@@_last_box
- }
- }
-\box_new:N \l_@@_last_l_box
-\box_new:N \l_@@_last_r_box
\box_new:N \g_@@_window_box
-\dim_new:N \g_@@_fake_wd_dim
-\dim_new:N \g_@@_first_dp_dim
-\dim_new:N \g_@@_first_sep_dim
-\dim_new:N \g_@@_column_left_dim
-\dim_new:N \g_@@_column_right_ht_dim
-\bool_new:N \g_@@_entire_bool
-\bool_new:N \g_@@_next_hang_bool
-\bool_new:N \g_@@_first_save_bool
-\bool_new:N \g_@@_column_right_bool
-\bool_new:N \l_@@_column_strict_bool
-\bool_new:N \g_@@_first_set_bool
\bool_new:N \l_@@_first_move_bool
-\bool_new:N \g_@@_right_move_bool
% \end{macrocode}
% \end{macro}
%
@@ -2028,38 +2346,39 @@
{ \vbox_unpack:N \l_@@_body_box }
\dim_gset:Nn \g_@@_ht_dim { \box_ht:N \l_@@_window_box }
}
- \bool_if:NTF \l_@@_attach_equation_bool
- {
- \vbox_set:Nn \l_@@_window_box
- {
- \vbox_unpack_drop:N \l_@@_window_box
- \box_set_to_last:N \l_@@_last_box
- \@@_attach_equation:N \l_@@_last_box
- \vbox_unpack_drop:N \l_@@_last_box
- }
- }
- { \box_set_eq_drop:NN \l_@@_window_box \l_@@_body_box }
- \dim_compare:nNnTF \g_@@_column_left_dim > \c_zero_dim
- { \@@_build_hang_aux: }
- { \bool_gset_false:N \g_@@_move_hang_bool }
+ \box_set_eq_drop:NN \l_@@_window_box \l_@@_body_box
+ \bool_if:NT \l_@@_attach_equation_bool
+ { \@@_build_hang_attach: }
+ \dim_compare:nNnT \g_@@_column_room_dim > \c_zero_dim
+ { \@@_build_hang_move: }
}
-\cs_new_protected_nopar:Npn \@@_build_hang_aux:
+\cs_new_protected_nopar:Npn \@@_build_hang_attach:
{
+ \dim_compare:nNnTF \l_@@_r_dim = \c_zero_dim
+ { \@@_attach_left:N \l_@@_window_box }
+ { \@@_attach_right:N \l_@@_window_box }
+ }
+\cs_new_protected_nopar:Npn \@@_build_hang_move:
+ {
\dim_set:Nn \l_@@_shift_dim
{
\dim_max:nn
{ \box_ht:N \l_@@_window_box }
{ \tex_baselineskip:D * \g_@@_line_int }
+ + \box_ht_plus_dp:N \g_@@_equation_box
+ \tex_parskip:D
}
- \dim_gsub:Nn \g_@@_column_left_dim { \l_@@_shift_dim }
- \dim_compare:nNnTF \g_@@_column_left_dim > \c_zero_dim
+ \dim_gsub:Nn \g_@@_column_room_dim { \l_@@_shift_dim }
+ \dim_compare:nNnTF \g_@@_column_room_dim > \c_zero_dim
{
\box_if_empty:NTF \l_@@_bottom_box
{ \bool_if:NT \g_@@_right_move_bool { \@@_set_next_hang: } }
- { \bool_gset_false:N \g_@@_move_hang_bool }
}
- { \bool_gset_false:N \g_@@_move_hang_bool }
+ { \use:n }
+ {
+ \bool_gset_false:N \g_@@_move_hang_bool
+ \bool_gset_false:N \g_@@_right_move_bool
+ }
}
\cs_new_protected_nopar:Npn \@@_set_next_hang:
{
@@ -2069,14 +2388,11 @@
\dim_gset_eq:NN \g_@@_hang_ht_dim \g_@@_remaining_dim
}
\dim_gsub:Nn \g_@@_hang_ht_dim { \l_@@_shift_dim }
- \dim_gset:Nn \g_@@_dp_dim { \box_dp:N \l_@@_window_box }
\@@_column_right_move_set:nn
{ \g_@@_hang_ht_dim }
- { \g_@@_column_left_dim }
+ { \g_@@_column_room_dim }
\int_gzero:N \g_@@_window_int
}
-\dim_new:N \g_@@_hang_ht_dim
-\bool_new:N \g_@@_move_hang_bool
% \end{macrocode}
% \end{macro}
%
@@ -2084,31 +2400,24 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_build_hangfrom:
{
- \dim_compare:nNnTF \g_@@_prevdepth_dim > \c_@@_ignore_depth_dim
- { \@@_build_hangfrom_aux: }
- { \dim_gzero:N \g_@@_ht_dim }
- }
-\cs_new_protected_nopar:Npn \@@_build_hangfrom_aux:
- {
\group_begin:
- \skip_zero:N \tex_splittopskip:D
- \vbox_gset:Nn \g_@@_line_box
+ \vbox_gset:Nn \g_@@_window_box
{
- \tex_penalty:D \c_@@_break_int
+ \@@_break:
\vbox_unpack:N \l_@@_body_box
}
- \vbox_set_split_to_ht:NNn \l_@@_last_box \g_@@_line_box
+ \@@_split_parameter:
+ \vbox_set_split_to_ht:NNn \l_@@_last_box \g_@@_window_box
{ \c_zero_dim }
\dim_gset:Nn \g_@@_ht_dim
{
\g_@@_baseline_skip
- \g_@@_prevdepth_dim
- - \l_@@_shift_dim
- \box_ht:N \l_@@_body_box
- + \box_ht:N \g_@@_line_box
+ + \box_ht:N \g_@@_window_box
}
\group_end:
- \box_set_eq_drop:NN \l_@@_body_box \g_@@_line_box
+ \box_set_eq_drop:NN \l_@@_body_box \g_@@_window_box
}
% \end{macrocode}
% \end{macro}
@@ -2117,37 +2426,39 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_put_box:
{
- \para_raw_end:
+ \@@_para_raw_end:
\dim_compare:nNnTF \g_@@_prevdepth_dim > \c_@@_ignore_depth_dim
{ \@@_add_vskip: }
- { \skip_gzero:N \g_@@_pre_skip }
+ { \@@_set_vskip: }
\skip_set_eq:NN \l_@@_par_skip \tex_parskip:D
\skip_zero:N \tex_parskip:D
+ \dim_set:Nn \l_@@_window_ht_dim
+ { \box_ht_plus_dp:N \l_@@_window_box }
\bool_if:NTF \g_@@_right_move_bool
{ \@@_put_box_aux: }
{
\box_if_empty:NTF \l_@@_bottom_box
- {
- \dim_compare:nNnTF
- { \g_@@_remaining_dim }
- >
- { \box_ht_plus_dp:N \l_@@_window_box }
- { \@@_set_next: }
- { \@@_put_box_aux: }
- }
+ { \@@_put_next_test: }
{ \@@_put_box_aux: }
}
}
+\dim_new:N \l_@@_window_ht_dim
\skip_new:N \l_@@_par_skip
-\cs_new_protected_nopar:Npn \@@_put_box_aux:
+\cs_new_protected_nopar:Npn \@@_put_next_test:
{
- \int_gzero:N \g_@@_window_int
- \@@_hbox:n
+ \box_if_empty:NF \g_@@_equation_box
{
- \@@_put_window_box:
- \bool_if:NF \g_@@_next_bool
- { \@@_put_stuff_box: }
+ \dim_add:Nn \l_@@_window_ht_dim
+ { \box_ht_plus_dp:N \g_@@_equation_box + \g_@@_pos_skip }
}
+ \dim_compare:nNnTF
+ { \g_@@_remaining_dim + \g_@@_pos_skip } > \l_@@_window_ht_dim
+ { \@@_set_next: }
+ { \@@_put_box_aux: }
+ }
+\cs_new_protected_nopar:Npn \@@_put_box_aux:
+ {
+ \@@_output_window_box:
\box_if_empty:NTF \l_@@_bottom_box
{ \@@_put_trailer_box: }
{ \@@_put_bottom_box: }
@@ -2163,32 +2474,49 @@
\bool_if:NTF \g_@@_right_move_bool
{ \@@_next_para_trailer: }
{
- \@@_add_pos_skip:
- \box_if_empty:NF \g_@@_pos_box
- {
- \@@_newline:
- \hbox_unpack_drop:N \g_@@_pos_box
- }
+ \@@_add_pos_kludge:
+ \@@_put_pos_box:
+ \@@_clear_variable:
}
}
}
\cs_new_protected_nopar:Npn \@@_put_bottom_box:
{
- \@@_newline:
+ \@@_para_raw_end:
+ \para_raw_noindent:
\hbox_unpack_drop:N \l_@@_bottom_box
\box_if_empty:NF \g_@@_equation_box
{ \@@_insert_equation: }
+ \@@_put_pos_box:
+ \@@_clear_variable:
+ }
+\cs_new_protected_nopar:Npn \@@_output_window_box:
+ {
+ \@@_hbox:n
+ {
+ \@@_put_window_box:
+ \bool_if:NF \g_@@_next_bool
+ { \@@_output_stuff_box: }
+ }
+ }
+\cs_new_protected_nopar:Npn \@@_put_pos_box:
+ {
\box_if_empty:NF \g_@@_pos_box
- { \hbox_unpack_drop:N \g_@@_pos_box }
- \bool_gset_false:N \g_@@_right_move_bool
- \bool_gset_false:N \g_@@_first_save_bool
+ { \@@_output_pos_box: }
}
-\cs_new_protected_nopar:Npn \@@_newline:
+\cs_new_protected_nopar:Npn \@@_output_pos_box:
{
- \tex_penalty:D \c_@@_nobreak_int
- \tex_hfil:D
- \tex_penalty:D \c_@@_break_int
+ \@@_if_last_none:F
+ { \@@_output_pos_box_aux: }
+ \hbox_unpack_drop:N \g_@@_pos_box
}
+\cs_new_protected_nopar:Npn \@@_output_pos_box_aux:
+ {
+ \@@_para_raw_end:
+ \bool_if:NT \g_@@_equation_dp_bool
+ { \@@_set_equation_depth: }
+ \para_raw_noindent:
+ }
\cs_new_protected:Npn \@@_hbox:n #1
{
\para_raw_noindent:
@@ -2202,22 +2530,22 @@
{ \skip_horizontal:n { \l_@@_line_dim - \l_@@_r_dim } }
\box_use:N \l_@@_window_box
}
-\cs_new_protected_nopar:Npn \@@_put_stuff_box:
+\cs_new_protected_nopar:Npn \@@_output_stuff_box:
{
- \@@_move_stuff_box:nn { up }
+ \hbox_gset:Nn \g_@@_stuff_box
{
- \l_@@_voffset_dim
- + ( \box_dp:N \g_@@_stuff_box -
- \box_dp:N \l_@@_window_box )
- + ( \box_ht_plus_dp:N \l_@@_window_box -
- \g_@@_stuff_ht_dim ) / 2
- \box_if_empty:NT \l_@@_bottom_box
- { - \g_@@_pos_skip / 2 }
+ \@@_parshape_kern:
+ \box_move_up:nn
+ {
+ + \box_ht:N \l_@@_window_box
+ - ( \l_@@_window_ht_dim
+ + \box_ht_plus_dp:N \g_@@_stuff_box ) / 2
+ + \l_@@_voffset_dim
+ }
+ { \box_use_drop:N \g_@@_stuff_box }
}
- \@@_output_stuff_box:
- }
-\cs_new_protected_nopar:Npn \@@_output_stuff_box:
- {
+ \box_gset_ht:Nn \g_@@_stuff_box { \c_zero_dim }
+ \box_gset_dp:Nn \g_@@_stuff_box { \c_zero_dim }
\skip_horizontal:n
{
\dim_compare:nNnTF \l_@@_r_dim > \c_zero_dim
@@ -2240,23 +2568,6 @@
% \end{macrocode}
% \end{macro}
%
-% \begin{macro}{\@@_move_stuff_box:n}
-% \begin{macrocode}
-\cs_new_protected:Npn \@@_move_stuff_box:nn #1#2
- {
- \hbox_gset:Nn \g_@@_stuff_box
- {
- \@@_parshape_kern:
- \use:c { box_move_ #1 :nn }
- {#2}
- { \box_use_drop:N \g_@@_stuff_box }
- }
- \box_gset_ht:Nn \g_@@_stuff_box { \c_zero_dim }
- \box_gset_dp:Nn \g_@@_stuff_box { \c_zero_dim }
- }
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\@@_add_vskip:}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_add_vskip:
@@ -2267,6 +2578,7 @@
}
\cs_new_protected_nopar:Npn \@@_add_vskip_display:
{
+ \bool_set_true:N \l_@@_display_pre_bool
\vbox_unpack_drop:N \g_@@_display_box
\@@_ignore_depth:
}
@@ -2274,18 +2586,15 @@
{
\dim_compare:nNnTF \tex_pagegoal:D < \c_max_dim
{ \@@_add_vskip_auxii: }
- { \@@_add_vskip_auxiii: }
+ {
+ \bool_if:NTF \g_@@_next_bool
+ { \@@_add_vskip_auxii: }
+ { \@@_add_vskip_auxiii: }
+ }
}
\cs_new_protected_nopar:Npn \@@_add_vskip_auxii:
{
- \skip_gset:Nn \g_@@_pre_skip
- {
- \g_@@_baseline_skip
- - \g_@@_prevdepth_dim
- - \g_@@_ht_dim
- }
- \dim_compare:nNnT \g_@@_pre_skip < \tex_lineskiplimit:D
- { \skip_gset_eq:NN \g_@@_pre_skip \tex_lineskip:D }
+ \@@_add_vskip_auxiv:
\bool_if:NTF \l_@@_first_move_bool
{ \@@_first_move_skip: }
{ \skip_vertical:N \g_@@_pre_skip }
@@ -2293,15 +2602,26 @@
}
\cs_new_protected_nopar:Npn \@@_add_vskip_auxiii:
{
+ \@@_add_vskip_auxiv:
+ \skip_vertical:N \g_@@_pre_skip
\dim_compare:nNnTF \tex_topskip:D > \g_@@_ht_dim
{
+ \skip_sub:Nn \tex_topskip:D { \g_@@_ht_dim }
\tex_hrule:D height \c_zero_dim \scan_stop:
- \skip_gset:Nn \g_@@_pre_skip
- { \tex_topskip:D - \g_@@_ht_dim }
- \skip_vertical:n { \g_@@_pre_skip - \tex_topskip:D }
}
- { \skip_gzero:N \g_@@_pre_skip }
+ { \@@_ignore_depth: }
}
+\cs_new_protected_nopar:Npn \@@_add_vskip_auxiv:
+ {
+ \skip_gset:Nn \g_@@_pre_skip
+ {
+ \g_@@_baseline_skip
+ - \g_@@_prevdepth_dim
+ - \g_@@_ht_dim
+ }
+ \dim_compare:nNnT \g_@@_pre_skip < \tex_lineskiplimit:D
+ { \skip_gset_eq:NN \g_@@_pre_skip \tex_lineskip:D }
+ }
\cs_new_protected_nopar:Npn \@@_first_move_skip:
{
\skip_vertical:n
@@ -2309,14 +2629,29 @@
\g_@@_first_sep_dim
- \g_@@_window_ht_dim
- \tex_parskip:D
- \dim_compare:nNnT \g_@@_column_right_ht_dim > \c_zero_dim
- { + \g_@@_column_right_ht_dim + \g_@@_pre_skip }
+ \dim_compare:nNnT \g_@@_column_ht_dim > \c_zero_dim
+ { + \g_@@_column_ht_dim + \g_@@_pre_skip }
}
}
\skip_new:N \g_@@_pre_skip
+\bool_new:N \l_@@_display_pre_bool
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\@@_set_vskip:}
+% \begin{macrocode}
+\cs_new_protected_nopar:Npn \@@_set_vskip:
+ {
+ \box_if_empty:NTF \g_@@_display_box
+ {
+ \skip_gset:Nn \g_@@_pre_skip
+ { \g_@@_baseline_skip - \g_@@_ht_dim }
+ }
+ { \@@_add_vskip_display: }
+ }
+% \end{macrocode}
+% \end{macro}
+%
% \begin{macro}{\@@_ignore_depth:,\@@_set_prevdepth:N}
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_ignore_depth:
@@ -2333,24 +2668,19 @@
{
\dim_set:Nn \l_@@_height_dim
{
- \g_@@_pre_skip
- + \g_@@_pos_skip
- + \box_ht_plus_dp:N \l_@@_window_box
+ \bool_if:NT \g_@@_next_bool { \l_@@_par_skip }
+ + \g_@@_pre_skip
+ + \l_@@_window_ht_dim
}
\dim_gadd:Nn \g_@@_total_ht_dim { \l_@@_height_dim }
\dim_set:Nn \l_@@_shift_dim
{ \g_@@_remaining_dim - \l_@@_height_dim }
- \dim_compare:nNnTF \l_@@_shift_dim > \c_zero_dim
- { \@@_set_next_auxi: }
- {
- \dim_compare:nNnTF
- { - \l_@@_shift_dim } > \l_@@_min_dim
- { \@@_set_next_auxii: }
- { \@@_set_next_auxi: }
- }
+ \dim_compare:nNnTF
+ { - \l_@@_shift_dim } < \l_@@_min_dim
+ { \@@_set_next_para: }
+ { \@@_set_next_output: }
}
-\dim_new:N \g_@@_total_ht_dim
-\cs_new_protected_nopar:Npn \@@_set_next_auxi:
+\cs_new_protected_nopar:Npn \@@_set_next_para:
{
\int_gset:Nn \g_@@_window_int
{
@@ -2359,9 +2689,7 @@
{ \c_one_int }
}
\@@_set_next_verify:
- \bool_if:NF \g_@@_next_bool
- { \@@_move_next_stuff_box: }
- \@@_set_next_output:
+ \@@_output_window_box:
\@@_make_next_stuff:nn
{ \g_@@_stuff_wd_dim }
{ \l_@@_shift_dim }
@@ -2368,55 +2696,27 @@
\int_gzero:N \g_@@_top_int
\@@_next_para_trailer:
}
-\cs_new_protected_nopar:Npn \@@_move_next_stuff_box:
- {
- \@@_move_stuff_box:nn { down }
- {
- \box_ht:N \g_@@_stuff_box
- - \box_ht:N \l_@@_window_box
- + ( \g_@@_window_ht_dim
- - \g_@@_stuff_ht_dim
- - \g_@@_pre_skip
- + \g_@@_pos_skip
- + \l_@@_par_skip ) / 2
- - \l_@@_voffset_dim
- }
- }
-\cs_new_protected_nopar:Npn \@@_set_next_auxii:
- {
- \int_gzero:N \g_@@_window_int
- \bool_if:NF \g_@@_next_bool
- {
- \@@_move_stuff_box:nn { down }
- {
- \box_ht:N \g_@@_stuff_box
- - \box_ht:N \l_@@_window_box
- - \l_@@_voffset_dim
- }
- }
- \@@_set_next_output:
- \@@_add_pos_skip:
- }
\cs_new_protected_nopar:Npn \@@_set_next_output:
{
- \@@_hbox:n
- {
- \@@_put_window_box:
- \bool_if:NF \g_@@_next_bool
- { \@@_output_stuff_box: }
- }
+ \@@_output_window_box:
+ \@@_add_pos_kludge:
+ \@@_put_pos_box:
+ \@@_clear_variable:
}
\cs_new_protected_nopar:Npn \@@_set_next_verify:
{
\dim_set:Nn \l_@@_height_dim
- { \g_@@_window_ht_dim - \g_@@_total_ht_dim }
- \dim_until_do:nNnn
+ { \g_@@_window_ht_dim - \g_@@_total_ht_dim - \l_@@_min_dim }
+ \dim_while_do:nNnn
{ \tex_baselineskip:D * \g_@@_window_int + \l_@@_par_skip }
- >
+ <
{ \l_@@_height_dim }
{ \int_gincr:N \g_@@_window_int }
- \dim_gadd:Nn \g_@@_total_ht_dim
- { \tex_baselineskip:D * \g_@@_window_int + \l_@@_par_skip }
+ \bool_if:NF \g_@@_next_bool
+ {
+ \dim_add:Nn \l_@@_window_ht_dim
+ { \tex_baselineskip:D * \g_@@_window_int + \l_@@_par_skip }
+ }
}
% \end{macrocode}
% \end{macro}
@@ -2425,7 +2725,7 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_next_para_trailer:
{
- \@@_add_pos_skip:
+ \@@_add_pos_kludge:
\box_if_empty:NTF \g_@@_pos_box
{ \@@_next_para: }
{
@@ -2445,7 +2745,6 @@
\dim_gset:Nn \g_@@_stuff_wd_dim {#1}
\dim_gset:Nn \g_@@_remaining_dim {#2}
}
-\bool_new:N \g_@@_next_bool
% \end{macrocode}
% \end{macro}
%
@@ -2516,11 +2815,7 @@
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_test_display_math:
{
- \@@_if_last_hlist:T
- {
- \box_gset_to_last:N \g_@@_pos_box
- \tex_unskip:D
- }
+ \@@_if_last_hlist:T { \@@_extract_pos_hbox: }
\box_clear:N \l_@@_add_box
\box_gclear:N \g_@@_display_box
\skip_gzero:N \g_@@_last_skip
@@ -2532,8 +2827,15 @@
\@@_add_last_skip:w
\@@_add_last_skip:w
\@@_add_last_penalty:w
- \@@_add_last_finalise:w \q_stop
+ \@@_add_last_finalise:w \s_stop
}
+\cs_new_protected_nopar:Npn \@@_extract_pos_hbox:
+ {
+ \box_gset_to_last:N \g_@@_last_box
+ \@@_repack_hbox:N \l_@@_last_box
+ \box_gset_eq_drop:NN \g_@@_pos_box \l_@@_last_box
+ \tex_unskip:D
+ }
\box_new:N \l_@@_add_box
\box_new:N \g_@@_pos_box
% \end{macrocode}
@@ -2544,7 +2846,7 @@
\cs_new_protected_nopar:Npn \@@_add_last_stop:w
{
\vbox_unpack_drop:N \l_@@_add_box
- \use_none_delimit_by_q_stop:w
+ \use_none_delimit_by_s_stop:w
}
% \end{macrocode}
% \end{macro}
@@ -2630,7 +2932,7 @@
}
{ \box_gset_eq_drop:NN \g_@@_display_box \l_@@_add_box }
{ \vbox_unpack_drop:N \l_@@_add_box }
- \use_none_delimit_by_q_stop:w
+ \use_none_delimit_by_s_stop:w
}
\int_new:N \g_@@_display_pre_int
\skip_new:N \g_@@_display_pre_skip
@@ -2690,7 +2992,8 @@
% \env{align} 等环境的开头 \tn{ifdt at p} 为真,会插入两个 \tn{vskip},
% 但是 \env{multline} 定义中的 \tn{mmeasure@} 没有重定义 \tn{everycr},
% 上述定义中的 \tn{dt at pfalse} 被执行,导致环境开头被加入了 \tn{penalty},
-% 不确定是有意为之还是疏忽。
+% 不确定是有意为之还是疏忽^^A
+% \footnote{\url{https://github.com/latex3/latex2e/issues/793}}。
% \begin{macrocode}
\cs_new_protected_nopar:Npn \@@_amsmath_multline:w
{
@@ -2963,11 +3266,11 @@
}
\regex_const:Nn \c_@@_integer_regex { \A \d+ \Z }
\cs_new_protected_nopar:Npn \@@_unknown_key_error:n
- { \msg_error:nnn { wrapstuff } { unknown-key } }
-\msg_new:nnnn { wrapstuff } { unknown-key }
- { The~key~'#1'~is~unknown~and~is~being~ignored. }
+ { \msg_error:nnn { wstf } { unknown-key } }
+\msg_new:nnnn { wstf } { unknown-key }
+ { The~key~"#1"~is~unknown~and~is~being~ignored. }
{
- The~package~wrapstuff~does~not~have~a~key~called~'#1'.\\
+ The~package~wrapstuff~does~not~have~a~key~called~"#1".\\
Check~that~you~have~spelled~the~key~name~correctly.
}
% \end{macrocode}
Modified: trunk/Master/texmf-dist/tex/latex/wrapstuff/wrapstuff.sty
===================================================================
--- trunk/Master/texmf-dist/tex/latex/wrapstuff/wrapstuff.sty 2022-07-25 23:49:35 UTC (rev 63980)
+++ trunk/Master/texmf-dist/tex/latex/wrapstuff/wrapstuff.sty 2022-07-26 19:41:08 UTC (rev 63981)
@@ -25,12 +25,12 @@
%%
%% -----------------------------------------------------------------
%%
-\NeedsTeXFormat{LaTeX2e}
+\NeedsTeXFormat{LaTeX2e}[2021-06-01]
\@ifundefined{ExplLoaderFileDate}{\RequirePackage{expl3}}{}
-\GetIdInfo$Id: wrapstuff.dtx 564fe9d 2022-07-20 19:55:58 +0800 Qing Lee <sobenlee at gmail.com> $
+\GetIdInfo$Id: wrapstuff.dtx e891159 2022-07-26 19:00:31 +0800 Qing Lee <sobenlee at gmail.com> $
{Wrapping text around stuff}
\ProvidesExplPackage{\ExplFileName}
- {\ExplFileDate}{0.1}{\ExplFileDescription}
+ {\ExplFileDate}{0.2}{\ExplFileDescription}
\@ifl at t@r \fmtversion { 2021-06-01 }
{ }
{
@@ -53,6 +53,217 @@
\msg_critical:nn { wrapstuff } { latex3-too-old }
}
\prop_gput:Nnn \g_msg_module_name_prop { wstf } { wrapstuff }
+\tl_const:Nn \c__wstf_global_tl_tl
+ { \g__wstf_main_setting_tl }
+\tl_const:Nn \c__wstf_global_dim_tl
+ {
+ \g__wstf_hang_ht_dim
+ \g__wstf_total_ht_dim
+ \g__wstf_stuff_ht_dim
+ \g__wstf_stuff_wd_dim
+ \g__wstf_first_dp_dim
+ \g__wstf_first_sep_dim
+ \g__wstf_prevdepth_dim
+ \g__wstf_column_ht_dim
+ \g__wstf_window_ht_dim
+ \g__wstf_remaining_dim
+ \g__wstf_column_room_dim
+ \g__wstf_parshape_indent_dim
+ \g__wstf_parshape_length_dim
+ }
+\tl_const:Nn \c__wstf_global_int_tl
+ {
+ \g__wstf_top_int
+ \g__wstf_column_int
+ \g__wstf_window_int
+ }
+\tl_const:Nn \c__wstf_global_bool_tl
+ {
+ \g__wstf_next_bool
+ \g__wstf_leqno_bool
+ \g__wstf_column_bool
+ \g__wstf_entire_bool
+ \g__wstf_display_bool
+ \g__wstf_move_hang_bool
+ \g__wstf_next_hang_bool
+ \g__wstf_first_set_bool
+ \g__wstf_first_save_bool
+ \g__wstf_right_move_bool
+ }
+\cs_new_protected:Npn \__wstf_tl_init:N #1
+ {
+ \tl_new:N #1
+ \tl_gput_right:Nn \g__wstf_var_clear_tl
+ { \tl_gclear:N #1 }
+ \tl_gput_right:Nn \g__wstf_var_push_tl
+ { \tl_gset:Nn \exp_not:N #1 { \exp_not:o {#1} } }
+ }
+\cs_new_protected:Npn \__wstf_dim_init:N #1
+ {
+ \dim_new:N #1
+ \tl_gput_right:Nn \g__wstf_var_clear_tl
+ { \dim_gzero:N #1 }
+ \tl_gput_right:Nn \g__wstf_var_push_tl
+ { \dim_gset:Nn #1 { \dim_use:N #1 } }
+ }
+\cs_new_protected:Npn \__wstf_int_init:N #1
+ {
+ \int_new:N #1
+ \tl_gput_right:Nn \g__wstf_var_clear_tl
+ { \int_gzero:N #1 }
+ \tl_gput_right:Nn \g__wstf_var_push_tl
+ { \int_gset:Nn #1 { \int_use:N #1 } }
+ }
+\cs_new_protected:Npn \__wstf_bool_init:N #1
+ {
+ \bool_new:N #1
+ \tl_gput_right:Nn \g__wstf_var_clear_tl
+ { \bool_gset_false:N #1 }
+ \tl_gput_right:Nn \g__wstf_var_push_tl
+ {
+ \bool_if:NTF #1
+ { \bool_gset_true:N #1 }
+ { \bool_gset_false:N #1 }
+ }
+ }
+\tl_new:N \g__wstf_var_clear_tl
+\tl_new:N \g__wstf_var_push_tl
+\tl_map_function:NN \c__wstf_global_tl_tl \__wstf_tl_init:N
+\tl_map_function:NN \c__wstf_global_dim_tl \__wstf_dim_init:N
+\tl_map_function:NN \c__wstf_global_int_tl \__wstf_int_init:N
+\tl_map_function:NN \c__wstf_global_bool_tl \__wstf_bool_init:N
+\int_gdecr:N \g__wstf_top_int
+\tl_gput_right:Nn \g__wstf_var_clear_tl
+ { \int_gdecr:N \g__wstf_top_int }
+\cs_new_protected_nopar:Npn \__wstf_clear:
+ {
+ \__wstf_clear_para_hook:
+ \__wstf_clear_kludge:
+ \__wstf_clear_variable:
+ }
+\cs_new_protected_nopar:Npn \__wstf_clear_variable:
+ {
+ \tl_use:N \g__wstf_var_clear_tl
+ \box_gclear:N \g__wstf_stuff_box
+ }
+\cs_new_protected_nopar:Npn \__wstf_clear_kludge:
+ {
+ \bool_if:NTF \g__wstf_next_bool
+ {
+ \skip_vertical:n
+ { \tex_baselineskip:D * \g__wstf_window_int }
+ }
+ {
+ \box_if_empty:NF \g__wstf_stuff_box
+ { \__wstf_clear_stuff_box: }
+ }
+ }
+\cs_new_protected_nopar:Npn \__wstf_clear_stuff_box:
+ {
+ \__wstf_ignore_depth:
+ \skip_set:Nn \l__wstf_last_skip
+ { \box_dp:N \strutbox }
+ \skip_vertical:N \l__wstf_last_skip
+ \box_use_drop:N \g__wstf_stuff_box
+ \skip_vertical:N \l__wstf_last_skip
+ \__wstf_ignore_depth:
+ }
+\cs_new_protected_nopar:Npn \__wstf_status_push:
+ {
+ \tl_clear:N \l__wstf_status_tl
+ \int_gincr:N \g__wstf_status_int
+ \exp_args:Ne \__wstf_status_push_aux:n
+ { \int_use:N \g__wstf_status_int }
+ \seq_gpush:No \g__wstf_status_seq { \l__wstf_status_tl }
+ }
+\cs_new_protected:Npn \__wstf_status_push_aux:n #1
+ {
+ \__wstf_push_cs:nN {#1} \__wstf_para_before:
+ \__wstf_push_cs:nN {#1} \__wstf_para_begin:
+ \__wstf_push_cs:nN {#1} \__wstf_para_end:
+ \__wstf_push_cs:nN {#1} \__wstf_display_hook:
+ \__wstf_push_box:N \g__wstf_stuff_box
+ \__wstf_push_var:
+ }
+\cs_new_protected:Npn \__wstf_push_cs:nN #1#2
+ {
+ \exp_args:NNc \__wstf_push_cs_aux:NN #2
+ { __wstf_ #1 _ \token_to_str:N #2 }
+ }
+\cs_new_protected:Npn \__wstf_push_cs_aux:NN #1#2
+ {
+ \cs_gset_eq:NN #2#1
+ \tl_put_right:Nn \l__wstf_status_tl
+ {
+ \cs_gset_eq:NN #1#2
+ \cs_undefine:N #2
+ }
+ }
+\cs_new_protected:Npn \__wstf_push_box:N #1
+ {
+ \hbox_gset:Nn \g__wstf_stauts_box
+ {
+ \hbox_unpack_drop:N \g__wstf_stauts_box
+ \box_use:N #1
+ }
+ \tl_put_right:Nn \l__wstf_status_tl
+ { \__wstf_pop_box:N #1 }
+ }
+\cs_new_protected:Npn \__wstf_pop_box:N #1
+ {
+ \hbox_gset:Nw \g__wstf_stauts_box
+ \hbox_unpack_drop:N \g__wstf_stauts_box
+ \box_gset_to_last:N #1
+ \__wstf_if_last_hlist:TF
+ { \hbox_gset_end: }
+ {
+ \hbox_gset_end:
+ \box_gclear:N \g__wstf_stauts_box
+ }
+ }
+\cs_new_protected_nopar:Npn \__wstf_push_var:
+ {
+ \tl_put_right:Nx \l__wstf_status_tl
+ { \g__wstf_var_push_tl }
+ }
+\cs_new_protected_nopar:Npn \__wstf_status_pop:
+ {
+ \seq_gpop:NNT \g__wstf_status_seq \l__wstf_status_tl
+ {
+ \int_gdecr:N \g__wstf_status_int
+ \tl_use:N \l__wstf_status_tl
+ }
+ }
+\cs_new_protected_nopar:Npn \__wstf_status_restore:
+ {
+ \__wstf_status_push:
+ \__wstf_clear_para_hook:
+ \__wstf_clear_display_hook:
+ \__wstf_clear_variable:
+ \group_insert_after:N \__wstf_status_pop:
+ }
+\cs_new_protected_nopar:Npn \__wstf_status_clear:
+ {
+ \bool_if:NT \g__wstf_next_bool
+ {
+ \__wstf_clear_para_hook:
+ \__wstf_clear_variable:
+ }
+ }
+\tl_new:N \l__wstf_status_tl
+\box_new:N \g__wstf_stauts_box
+\int_new:N \g__wstf_status_int
+\seq_new:N \g__wstf_status_seq
+\cs_new_protected_nopar:Npn \wrapstuff at parboxrestore
+ { \group_insert_after:N \__wstf_status_clear: }
+\cs_new_protected_nopar:Npn \__wstf_parbox_restore:
+ {
+ \cs_set_eq:NN
+ \wrapstuff at parboxrestore
+ \__wstf_status_restore:
+ }
+\g at addto@macro \@arrayparboxrestore
+ { \wrapstuff at parboxrestore }
\group_begin:
\cs_set:Npn \__wstf_tmp:nn #1
{
@@ -82,6 +293,10 @@
{ \hook_gput_code:nnn {#1} { wrapstuff } }
\cs_new_protected:Npn \__wstf_package_hook:nn #1
{ \hook_gput_code:nnn { package/#1/after } { wrapstuff } }
+\cs_new_protected_nopar:Npn \__wstf_para_raw_end:
+ { \group_begin: \para_raw_end: \group_end: }
+\cs_new_protected:Npn \__wstf_gadd_ht:Nn #1#2
+ { \box_gset_ht:Nn #1 { \box_ht:N #1 + \dim_eval:n {#2} } }
\NewDocumentEnvironment { wrapstuff } { O { } }
{
\__wstf_clear:
@@ -179,15 +394,10 @@
\box_gset_dp:Nn \g__wstf_stuff_box { \c_zero_dim }
}
\tl_new:N \l__wstf_main_kv_tl
-\tl_new:N \g__wstf_main_setting_tl
\box_new:N \g__wstf_stuff_box
-\dim_new:N \g__wstf_stuff_ht_dim
-\dim_new:N \g__wstf_stuff_wd_dim
\dim_new:N \l__wstf_shift_dim
\dim_new:N \l__wstf_width_dim
\dim_new:N \l__wstf_height_dim
-\dim_new:N \g__wstf_prevdepth_dim
-\dim_new:N \g__wstf_remaining_dim
\cs_new_protected_nopar:Npn \__wstf_attach_label:
{
\stepcounter { wrapstuff }
@@ -199,20 +409,26 @@
}
\cs_new_protected_nopar:Npn \__wstf_write_label:
{
- \iow_shipout_x:Nx \@auxout
+ \exp_args:Nee \__wstf_write_label_aux:nn
+ { \__wstf_counter:n { wrapstuff } }
+ { \__wstf_counter:n { page } }
+ }
+\cs_new_protected:Npx \__wstf_write_label_aux:nn #1#2
+ {
+ \prop_gput_if_new:Nnn \exp_not:N \g__wstf_page_prop {#1} {#2}
+ \iow_shipout_x:Nn \exp_not:N \@auxout
{
\c_backslash_str wrapstuff at label
- { \__wstf_counter:n { wrapstuff } }
+ {#1}
{ \exp_not:N \wrapstuff at counter { page } }
}
}
+\newcounter { wrapstuff }
\cs_new:Npn \__wstf_counter:n #1
{ \int_value:w \value {#1} }
\cs_new_eq:NN \wrapstuff at counter \__wstf_counter:n
\cs_new_protected_nopar:Npn \wrapstuff at label
- { \@newl at bel { wrapstuff at label } }
-\tl_const:Nn \c__wstf_label_tl
- { wrapstuff at label@ \int_value:w \value { wrapstuff } }
+ { \prop_gput:Nnn \g__wstf_page_prop }
\__wstf_gadd_hook:nn { begindocument }
{
\legacy_if:nTF { @filesw }
@@ -225,7 +441,35 @@
}
{ \cs_gset_eq:NN \__wstf_write_label: \__wstf_empty: }
}
-\newcounter { wrapstuff }
+\__wstf_gadd_hook:nn { enddocument/afterlastpage }
+ {
+ \legacy_if:nT { @filesw }
+ { \prop_gclear:N \g__wstf_page_prop }
+ }
+\__wstf_gadd_hook:nn { enddocument/info }
+ {
+ \prop_if_empty:NF \g__wstf_rerun_prop
+ { \__wstf_rerun_check: }
+ }
+\cs_new_protected_nopar:Npn \__wstf_rerun_check:
+ {
+ \prop_map_inline:Nn \g__wstf_rerun_prop
+ {
+ \prop_get:NnN \g__wstf_page_prop { ##1 } \l__wstf_page_tl
+ \int_if_even:nF { \l__wstf_page_tl - ##2 }
+ { \prop_map_break:n { \__wstf_rerun_warning: } }
+ }
+ }
+\cs_new_protected_nopar:Npn \__wstf_rerun_warning:
+ { \msg_warning:nn { wstf } { rerun-required } }
+\msg_new:nnn { wstf } { rerun-required }
+ {
+ Page(s)~may~have~changed.\\
+ Rerun~to~get~i/o~setting~right.
+ }
+\tl_new:N \l__wstf_page_tl
+\prop_new:N \g__wstf_page_prop
+\prop_new:N \g__wstf_rerun_prop
\cs_new_protected_nopar:Npn \__wstf_save_main_setting:
{
\exp_args:Nnno
@@ -254,8 +498,10 @@
\keys_precompile:nnN
{ wrapstuff }
{ \l__wstf_main_kv_tl } \l__wstf_main_kv_tl
- \tl_gconcat:NNN \g__wstf_main_setting_tl
- \g__wstf_main_setting_tl \l__wstf_main_kv_tl
+ \tl_gconcat:NNN
+ \g__wstf_main_setting_tl
+ \g__wstf_main_setting_tl
+ \l__wstf_main_kv_tl
}
\cs_new_protected_nopar:Npn \__wstf_set_top_line:
{
@@ -270,71 +516,28 @@
}
\cs_new_protected_nopar:Npn \__wstf_swap_ratio:
{
+ \exp_args:Ne \__wstf_swap_ratio_aux:n
+ { \__wstf_counter:n { wrapstuff } }
+ }
+\cs_new_protected:Npn \__wstf_swap_ratio_aux:n #1
+ {
\fp_compare:nF
{ \c_zero_fp < \l__wstf_ratio_fp < \c_one_fp }
{ \fp_zero:N \l__wstf_ratio_fp }
- \int_if_odd:nTF
- {
- \exp_args:Ne \cs_if_exist_use:cF
- { \c__wstf_label_tl }
- { \__wstf_counter:n { page } }
- }
+ \prop_get:NnNF \g__wstf_page_prop {#1} \l__wstf_page_tl
+ { \tl_set:Nx \l__wstf_page_tl { \__wstf_counter:n { page } } }
+ \int_if_odd:nTF { \l__wstf_page_tl }
{ \bool_if:NTF \l__wstf_inner_bool }
{ \bool_if:NTF \l__wstf_outer_bool }
{ \__wstf_set_ratio:N \l__wstf_ratio_fp }
{ \__wstf_set_ratio:n { \c_one_fp - \l__wstf_ratio_fp } }
+ \prop_gput:Nno \g__wstf_rerun_prop {#1} { \l__wstf_page_tl }
}
\bool_new:N \l__wstf_swap_bool
\bool_new:N \l__wstf_inner_bool
\bool_new:N \l__wstf_outer_bool
-\cs_new_protected:Npn \__wstf_gadd_ht:Nn #1#2
- { \box_gset_ht:Nn #1 { \box_ht:N #1 + \dim_eval:n {#2} } }
-\cs_new_protected:Npn \__wstf_gsub_ht:Nn #1#2
- { \box_gset_ht:Nn #1 { \box_ht:N #1 - \dim_eval:n {#2} } }
-\cs_new_protected_nopar:Npn \__wstf_clear:
- {
- \__wstf_clear_para_hook:
- \__wstf_clear_kludge:
- \__wstf_clear_variable:
- }
-\cs_new_protected_nopar:Npn \__wstf_clear_variable:
- {
- \int_gset:Nn \g__wstf_top_int { -1 }
- \int_gzero:N \g__wstf_window_int
- \dim_gzero:N \g__wstf_total_ht_dim
- \dim_gzero:N \g__wstf_column_left_dim
- \tl_gclear:N \g__wstf_main_setting_tl
- \bool_gset_false:N \g__wstf_next_bool
- \bool_gset_false:N \g__wstf_hoffset_bool
- \bool_gset_false:N \g__wstf_next_hang_bool
- \bool_gset_false:N \g__wstf_first_save_bool
- \bool_gset_false:N \g__wstf_right_move_bool
- \bool_gset_false:N \g__wstf_column_right_bool
- }
-\cs_new_protected_nopar:Npn \__wstf_clear_kludge:
- {
- \bool_if:NTF \g__wstf_next_bool
- {
- \box_gclear:N \g__wstf_stuff_box
- \skip_vertical:n
- { \tex_baselineskip:D * \g__wstf_window_int }
- }
- {
- \box_if_empty:NF \g__wstf_stuff_box
- { \__wstf_clear_stuff_box: }
- }
- }
-\cs_new_protected_nopar:Npn \__wstf_clear_stuff_box:
- {
- \__wstf_ignore_depth:
- \skip_set:Nn \l__wstf_last_skip
- { \box_dp:N \strutbox }
- \skip_vertical:N \l__wstf_last_skip
- \box_use_drop:N \g__wstf_stuff_box
- \skip_vertical:N \l__wstf_last_skip
- \__wstf_ignore_depth:
- }
\__wstf_gadd_hook:nn { para/before } { \__wstf_para_before: }
+\__wstf_gadd_hook:nn { para/after } { \__wstf_para_after: }
\__wstf_gadd_hook:nn { para/begin } { \__wstf_para_begin: }
\__wstf_gadd_hook:nn { para/end } { \__wstf_para_end: }
\cs_new_protected_nopar:Npn \__wstf_next_para:
@@ -352,6 +555,7 @@
\cs_new_protected_nopar:Npn \__wstf_clear_para_hook:
{
\cs_gset_eq:NN \__wstf_para_before: \__wstf_empty:
+ \cs_gset_eq:NN \__wstf_para_after: \__wstf_empty:
\cs_gset_eq:NN \__wstf_para_begin: \__wstf_empty:
\cs_gset_eq:NN \__wstf_para_end: \__wstf_empty:
}
@@ -358,6 +562,7 @@
\cs_new_protected_nopar:Npn \__wstf_empty:
{ }
\cs_new_eq:NN \__wstf_para_before: \__wstf_empty:
+\cs_new_eq:NN \__wstf_para_after: \__wstf_empty:
\cs_new_eq:NN \__wstf_para_begin: \__wstf_empty:
\cs_new_eq:NN \__wstf_para_end: \__wstf_empty:
\NewDocumentEnvironment { wrapstuff at par } { }
@@ -396,8 +601,8 @@
\int_set:Nn \l__wstf_window_int { \l__wstf_window_int * 2 }
\int_set:Nn \l__wstf_window_line_int
{
- \bool_if:NTF \g__wstf_column_right_bool
- { \l__wstf_window_int / 2 + \g__wstf_column_window_int }
+ \bool_if:NTF \g__wstf_column_bool
+ { \l__wstf_window_int / 2 + \g__wstf_column_int }
{ \l__wstf_window_int }
}
}
@@ -404,6 +609,7 @@
\cs_gset_eq:NN \__wstf_para_before: \__wstf_empty:
\cs_gset_eq:NN \__wstf_para_begin: \__wstf_empty:
\__wstf_save_parshape:
+ \__wstf_parbox_restore:
\vbox_set:Nw \l__wstf_body_box
\__wstf_set_prevdepth:N \g__wstf_prevdepth_dim
\__wstf_save_tex_skip:
@@ -423,7 +629,8 @@
\int_gset_eq:NN \g__wstf_line_int \tex_prevgraf:D
\vbox_set_end:
\__wstf_adjust_tex_skip:
- \cs_gset_eq:NN \__wstf_para_end: \__wstf_empty:
+ \cs_gset_eq:NN \__wstf_para_end: \__wstf_empty:
+ \cs_gset_eq:NN \__wstf_para_after: \__wstf_empty:
\int_compare:nNnTF \g__wstf_line_int > \l__wstf_top_int
{ \__wstf_build_par: }
{ \__wstf_put_par: }
@@ -431,10 +638,8 @@
\box_new:N \l__wstf_body_box
\box_new:N \l__wstf_window_box
\int_new:N \l__wstf_window_int
-\int_new:N \g__wstf_window_int
\int_new:N \g__wstf_line_int
\int_new:N \l__wstf_window_line_int
-\int_new:N \g__wstf_column_window_int
\dim_new:N \l__wstf_l_dim
\dim_new:N \l__wstf_r_dim
\dim_new:N \l__wstf_min_dim
@@ -444,17 +649,12 @@
\dim_new:N \l__wstf_voffset_dim
\dim_new:N \l__wstf_leftsep_dim
\dim_new:N \l__wstf_rightsep_dim
-\dim_new:N \g__wstf_window_ht_dim
\dim_new:N \l__wstf_main_width_dim
-\int_new:N \g__wstf_top_int
-\int_gdecr:N \g__wstf_top_int
\bool_new:N \l__wstf_hang_bool
\cs_new_protected_nopar:Npn \__wstf_set_hang_left:
{
\bool_set_true:N \l__wstf_hang_bool
- \bool_if:NF \g__wstf_hoffset_bool
- { \__wstf_set_hoffset:NN \l__wstf_rightsep_dim \use:nn }
- \dim_sub:Nn \l__wstf_window_dim { \l__wstf_rightsep_dim }
+ \__wstf_set_hoffset:N \l__wstf_rightsep_dim
\dim_zero:N \l__wstf_l_dim
\dim_set_eq:NN \l__wstf_r_dim \l__wstf_window_dim
\cs_set_eq:NN \__wstf_build_box: \__wstf_build_hang:
@@ -462,9 +662,7 @@
\cs_new_protected_nopar:Npn \__wstf_set_hang_right:
{
\bool_set_true:N \l__wstf_hang_bool
- \bool_if:NF \g__wstf_hoffset_bool
- { \__wstf_set_hoffset:NN \l__wstf_leftsep_dim \use_ii_i:nn }
- \dim_sub:Nn \l__wstf_window_dim { \l__wstf_leftsep_dim }
+ \__wstf_set_hoffset:N \l__wstf_leftsep_dim
\dim_zero:N \l__wstf_r_dim
\dim_set_eq:NN \l__wstf_l_dim \l__wstf_window_dim
\cs_set_eq:NN \__wstf_build_box: \__wstf_build_hang:
@@ -482,28 +680,16 @@
{ \cs_set_eq:NN \__wstf_build_box: \__wstf_build_column: }
{ \cs_set_eq:NN \__wstf_build_box: \__wstf_build_block: }
}
-\cs_new_protected:Npn \__wstf_set_hoffset:NN #1#2
+\cs_new_protected:Npn \__wstf_set_hoffset:N #1
{
- \bool_gset_true:N \g__wstf_hoffset_bool
- \dim_set:Nn \l__wstf_hoffset_width_dim
- { #1 + \g__wstf_stuff_wd_dim }
+ \dim_sub:Nn \l__wstf_window_dim {#1}
\group_begin:
- \cs_set_eq:NN \width \l__wstf_hoffset_width_dim
- \dim_gset:Nn \g__wstf_hoffset_dim { \l__wstf_hoffset_tl }
- \group_end:
- \int_compare:nNnF \g__wstf_hoffset_dim = \c_zero_dim
- {
- \hbox_gset:Nn \g__wstf_stuff_box
- {
- #2 { \tex_kern:D - \g__wstf_hoffset_dim }
- { \box_use_drop:N \g__wstf_stuff_box }
- }
- \dim_add:Nn \l__wstf_window_dim { \g__wstf_hoffset_dim }
- }
+ \dim_set:Nn \l__wstf_width_dim { #1 + \g__wstf_stuff_wd_dim }
+ \cs_set_eq:NN \width \l__wstf_width_dim
+ \exp_args:NNNx \group_end:
+ \dim_add:Nn \l__wstf_window_dim
+ { \dim_eval:n { \l__wstf_hoffset_tl } }
}
-\dim_new:N \g__wstf_hoffset_dim
-\dim_new:N \l__wstf_hoffset_width_dim
-\bool_new:N \g__wstf_hoffset_bool
\cs_new_protected_nopar:Npn \__wstf_set_lines:
{
\bool_if:NTF \g__wstf_next_bool
@@ -526,9 +712,9 @@
}
\cs_new_protected_nopar:Npn \__wstf_window_init:
{
- \int_gset_eq:NN \g__wstf_column_window_int \l__wstf_window_int
+ \int_gset_eq:NN \g__wstf_column_int \l__wstf_window_int
\dim_gset:Nn \g__wstf_window_ht_dim
- { \tex_baselineskip:D * \g__wstf_column_window_int }
+ { \tex_baselineskip:D * \g__wstf_column_int }
\tl_if_empty:NF \l__wstf_lines_tl
{
\dim_gset:Nn \g__wstf_remaining_dim
@@ -579,7 +765,8 @@
\int_compare:nNnTF \g__wstf_parshape_int = \c_one_int
{
\tex_parshape:D \g__wstf_parshape_int
- \g__wstf_parshape_indent_dim \g__wstf_parshape_length_dim
+ \g__wstf_parshape_indent_dim
+ \g__wstf_parshape_length_dim
}
{ \__wstf_restore_hangfrom: }
}
@@ -618,8 +805,6 @@
\int_new:N \g__wstf_parshape_int
\int_new:N \g__wstf_hangafter_int
\dim_new:N \g__wstf_hangindent_dim
-\dim_new:N \g__wstf_parshape_indent_dim
-\dim_new:N \g__wstf_parshape_length_dim
\cs_new_protected_nopar:Npn \__wstf_group_kludge:
{
\scan_stop:
@@ -644,16 +829,15 @@
{ \fp_to_dim:n { #1 \dim_to_fp:n {#2} } }
\cs_new:Npn \__wstf_unit:n #1
{
- \fp_eval:n
+ \int_eval:n
{
- ceil
- (
- \dim_to_decimal_in_unit:nn
- {#1}
- { \tex_baselineskip:D }
- )
+ \exp_last_unbraced:Ne \__wstf_unit_aux:w
+ { \dim_to_decimal_in_unit:nn {#1} { \tex_baselineskip:D } }
+ \s_stop
}
}
+\cs_new:Npn \__wstf_unit_aux:w #1 . #2 \s_stop
+ { #1 + 1 }
\cs_new_protected_nopar:Npn \__wstf_save_tex_skip:
{
\skip_gset_eq:NN \g__wstf_left_skip \tex_leftskip:D
@@ -683,6 +867,7 @@
\skip_set_eq:NN \tex_leftskip:D \g__wstf_left_skip
\skip_set_eq:NN \tex_rightskip:D \g__wstf_right_skip
\skip_set_eq:NN \tex_parfillskip:D \g__wstf_parfill_skip
+ \skip_set_eq:NN \tex_baselineskip:D \g__wstf_baseline_skip
}
\skip_new:N \g__wstf_left_skip
\skip_new:N \g__wstf_right_skip
@@ -695,16 +880,27 @@
\tex_everydisplay:D \exp_after:wN
{
\tex_the:D \tex_everydisplay:D
- \__wstf_test_leqno:
- \dim_compare:nNnF \tex_displaywidth:D < \c_max_dim
- {
- \bool_gset_true:N \g__wstf_display_bool
- \dim_set_eq:NN \tex_displaywidth:D \l__wstf_display_dim
- }
+ \__wstf_display_hook:
}
}
+\cs_new_protected_nopar:Npn \__wstf_display_hook:
+ {
+ \__wstf_test_leqno:
+ \dim_compare:nNnF \tex_displaywidth:D < \c_max_dim
+ {
+ \bool_gset_true:N \g__wstf_display_bool
+ \dim_set_eq:NN \tex_displaywidth:D \l__wstf_display_dim
+ }
+ }
\cs_new_eq:NN \__wstf_test_leqno: \__wstf_empty:
-\bool_new:N \g__wstf_display_bool
+\cs_new_protected_nopar:Npn \__wstf_clear_display_hook:
+ { \cs_gset_eq:NN \__wstf_display_hook: \__wstf_empty: }
+\cs_new_protected_nopar:Npn \__wstf_split_parameter:
+ {
+ \skip_zero:N \tex_splittopskip:D
+ \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
+ \int_set_eq:NN \tex_vbadness:D \c_max_int
+ }
\cs_new_protected_nopar:Npn \__wstf_build_par:
{
\bool_if:NTF \g__wstf_hangfrom_bool
@@ -739,7 +935,7 @@
}
\cs_new_protected_nopar:Npn \__wstf_put_body_box:
{
- \para_raw_end:
+ \__wstf_para_raw_end:
\dim_compare:nNnTF { \box_wd:N \l__wstf_body_box } < \c_max_dim
{ \__wstf_put_body_aux:N \l__wstf_body_box }
{
@@ -747,14 +943,34 @@
\__wstf_put_body_aux:N \l__wstf_body_box
\box_set_eq_drop:NN \l__wstf_body_box \l__wstf_bottom_box
}
- \para_raw_end:
+ \__wstf_para_raw_end:
}
\cs_new_protected_nopar:Npn \__wstf_put_body_aux:N #1
{
\dim_gset:Nn \g__wstf_prevdepth_dim { \box_dp:N #1 }
+ \dim_compare:nNnT \g__wstf_prevdepth_dim = \c_zero_dim
+ { \__wstf_extract_depth:N #1 }
\vbox_unpack_drop:N #1
\__wstf_set_prevdepth:N \g__wstf_prevdepth_dim
}
+\cs_new_protected_nopar:Npn \__wstf_extract_depth:N #1
+ {
+ \vbox_set:Nn \l__wstf_last_box
+ {
+ \vbox_unpack:N #1
+ \__wstf_if_last_hlist:F
+ {
+ \tex_unskip:D \tex_unpenalty:D
+ \tex_unskip:D \tex_unpenalty:D
+ }
+ \__wstf_if_last_hlist:T
+ {
+ \box_set_to_last:N \l__wstf_last_box
+ \dim_gset:Nn \g__wstf_prevdepth_dim
+ { \box_dp:N \l__wstf_last_box }
+ }
+ }
+ }
\cs_new_protected_nopar:Npn \__wstf_put_next_par:
{
\int_gzero:N \g__wstf_top_int
@@ -775,20 +991,24 @@
}
\cs_new_protected_nopar:Npn \__wstf_build_display_amsmath:
{
- \vbox_gset:Nn \g__wstf_equation_box
- {
- \skip_vertical:n { - \g__wstf_display_pre_skip }
- \vbox_unpack_drop:N \g__wstf_display_box
- \skip_gset_eq:NN \g__wstf_pos_skip \tex_lastskip:D
- \tex_unskip:D
- \int_gset_eq:NN \g__wstf_pos_int \tex_lastpenalty:D
- \tex_unpenalty:D
- \skip_gadd:Nn \g__wstf_pos_skip { \tex_lastskip:D }
- \tex_unskip:D
- \tex_unpenalty:D
- }
- \box_gset_wd:Nn \g__wstf_equation_box
- { \l__wstf_display_dim }
+ \group_begin:
+ \vbox_gset:Nn \g__wstf_equation_box
+ {
+ \__wstf_break:
+ \vbox_unpack_drop:N \g__wstf_display_box
+ \skip_gset_eq:NN \g__wstf_pos_skip \tex_lastskip:D
+ \tex_unskip:D
+ \int_gset_eq:NN \g__wstf_pos_int \tex_lastpenalty:D
+ \tex_unpenalty:D
+ \skip_gadd:Nn \g__wstf_pos_skip { \tex_lastskip:D }
+ \tex_unskip:D
+ \tex_unpenalty:D
+ }
+ \__wstf_split_parameter:
+ \vbox_set_split_to_ht:NNn \l__wstf_last_box \g__wstf_equation_box
+ { \c_zero_dim }
+ \group_end:
+ \box_gset_wd:Nn \g__wstf_equation_box { \l__wstf_display_dim }
\vbox_gset:Nn \g__wstf_display_box
{
\tex_penalty:D \g__wstf_display_pre_int
@@ -866,35 +1086,57 @@
\cs_new_protected_nopar:Npn \__wstf_build_display_auxiii:
{
\bool_set_true:N \l__wstf_attach_equation_bool
- \bool_if:NTF \g__wstf_amsmath_bool
- { \box_set_eq_drop:NN \l__wstf_display_box \g__wstf_display_box }
+ \box_gclear:N \g__wstf_display_box
+ \bool_if:NF \g__wstf_amsmath_bool
+ { \__wstf_adjust_equation: }
+ \__wstf_build_body_box:
+ }
+\bool_new:N \l__wstf_display_bool
+\bool_new:N \l__wstf_attach_equation_bool
+\cs_new_protected:Npn \__wstf_attach_left:N #1
+ {
+ \__wstf_attach_equation:Nn #1
+ { \g__wstf_parshape_indent_dim }
+ }
+\cs_new_protected:Npn \__wstf_attach_right:N #1
+ {
+ \__wstf_attach_equation:Nn #1
{
- \box_gclear:N \g__wstf_display_box
- \__wstf_adjust_equation:
+ \l__wstf_line_dim
+ - \l__wstf_display_dim
+ + \g__wstf_parshape_indent_dim
}
- \__wstf_build_body_box:
}
-\cs_new_protected_nopar:Npn \__wstf_attach_equation:N
+\cs_new_protected:Npn \__wstf_attach_equation:Nn #1#2
{
- \bool_if:NTF \g__wstf_amsmath_bool
- { \__wstf_attach_equation_amsmath:N }
- { \__wstf_attach_equation_normal:N }
+ \vbox_set:Nn \l__wstf_last_box
+ {
+ \vbox_unpack:N #1
+ \box_set_to_last:N \l__wstf_last_box
+ \bool_if:NTF \g__wstf_amsmath_bool
+ { \__wstf_attach_equation_amsmath:Nn }
+ { \__wstf_attach_equation_normal:Nn }
+ \l__wstf_last_box {#2}
+ }
}
-\cs_new_protected:Npn \__wstf_attach_equation_amsmath:N #1
+\cs_new_protected:Npn \__wstf_attach_equation_amsmath:Nn #1#2
{
- \vbox_set:Nn #1
+ \vbox_gset:Nn \g__wstf_equation_box
{
- \box_use:N #1
- \__wstf_ignore_depth:
- \vbox_unpack_drop:N \l__wstf_display_box
+ \__wstf_nobreak:
\skip_vertical:n
- { \g__wstf_display_pre_dim - \box_dp:N #1 }
- \box_use_drop:N \g__wstf_equation_box
+ {
+ \g__wstf_display_pre_skip
+ + \g__wstf_display_pre_dim
+ - \box_dp:N #1
+ }
+ \box_move_right:nn {#2}
+ { \box_use_drop:N \g__wstf_equation_box }
}
}
-\cs_new_protected:Npn \__wstf_attach_equation_normal:N #1
+\cs_new_protected:Npn \__wstf_attach_equation_normal:Nn #1#2
{
- \vbox_set:Nn #1
+ \vbox_set:Nn \l__wstf_last_box
{
\__wstf_tex_parameter:
\dim_set_eq:NN \tex_hsize:D \l__wstf_display_dim
@@ -906,6 +1148,25 @@
\tex_unskip:D
\int_gset_eq:NN \g__wstf_pos_int \tex_lastpenalty:D
\tex_unpenalty:D
+ \box_set_to_last:N \l__wstf_last_box
+ \skip_set_eq:NN \l__wstf_last_skip \tex_lastskip:D
+ \tex_unskip:D
+ \skip_add:Nn \l__wstf_last_skip { \tex_lastskip:D }
+ \vbox_gset:Nn \g__wstf_equation_box
+ {
+ \__wstf_nobreak:
+ \skip_vertical:N \l__wstf_last_skip
+ \box_move_right:nn {#2}
+ {
+ \hbox_to_wd:nn
+ { \l__wstf_display_dim }
+ {
+ \tex_hss:D
+ \box_use_drop:N \l__wstf_last_box
+ \tex_hss:D
+ }
+ }
+ }
}
}
\cs_new_protected_nopar:Npn \__wstf_insert_equation:
@@ -941,15 +1202,15 @@
{
\bool_gset_false:N \g__wstf_eqnum_bool
\hbox_unpack:N \g__wstf_equation_box
- \__wstf_if_last_hlist:F { \use_none_delimit_by_q_stop:w }
+ \__wstf_if_last_hlist:F { \use_none_delimit_by_s_stop:w }
\box_gset_to_last:N \g__wstf_eqnum_box
- \__wstf_if_last_kern:F { \use_none_delimit_by_q_stop:w }
+ \__wstf_if_last_kern:F { \use_none_delimit_by_s_stop:w }
\tex_unkern:D
- \__wstf_if_last_hlist:F { \use_none_delimit_by_q_stop:w }
+ \__wstf_if_last_hlist:F { \use_none_delimit_by_s_stop:w }
\box_gset_to_last:N \g__wstf_eqbody_box
- \__wstf_if_last_none:F { \use_none_delimit_by_q_stop:w }
+ \__wstf_if_last_none:F { \use_none_delimit_by_s_stop:w }
\bool_gset_true:N \g__wstf_eqnum_bool
- \use_none_delimit_by_q_stop:w \q_stop
+ \use_none_delimit_by_s_stop:w \s_stop
}
}
\cs_new_protected_nopar:Npn \__wstf_adjust_equation_width:
@@ -979,22 +1240,21 @@
\box_new:N \g__wstf_eqbody_box
\box_new:N \g__wstf_eqnum_box
\box_new:N \g__wstf_equation_box
-\box_new:N \l__wstf_display_box
\int_new:N \g__wstf_pos_int
\skip_new:N \g__wstf_pos_skip
\bool_new:N \g__wstf_eqnum_bool
-\bool_new:N \g__wstf_leqno_bool
-\bool_new:N \l__wstf_display_bool
-\bool_new:N \l__wstf_attach_equation_bool
-\cs_new_protected_nopar:Npn \__wstf_add_pos_skip:
+\cs_new_protected_nopar:Npn \__wstf_add_pos_kludge:
{
- \bool_lazy_or:nnTF
- { \g__wstf_right_move_bool }
- { \int_compare_p:nNn \g__wstf_window_int > \c_zero_int }
+ \dim_gset:Nn \g__wstf_prevdepth_dim
+ { \box_dp:N \l__wstf_window_box }
+ \bool_gset_false:N \g__wstf_equation_dp_bool
+ \bool_if:NTF \g__wstf_next_bool
{
\tex_vadjust:D
{
- \tex_penalty:D \c__wstf_nobreak_int
+ \box_if_empty:NF \g__wstf_equation_box
+ { \__wstf_output_equation_box: }
+ \__wstf_nobreak:
\bool_if:NT \l__wstf_display_bool
{ \skip_vertical:N \g__wstf_pos_skip }
}
@@ -1004,6 +1264,8 @@
{
\tex_vadjust:D
{
+ \box_if_empty:NF \g__wstf_equation_box
+ { \__wstf_output_equation_box: }
\tex_penalty:D \g__wstf_pos_int
\skip_vertical:N \g__wstf_pos_skip
}
@@ -1012,6 +1274,23 @@
\int_gzero:N \g__wstf_pos_int
\skip_gzero:N \g__wstf_pos_skip
}
+\cs_new_protected_nopar:Npn \__wstf_output_equation_box:
+ {
+ \cs_gset_eq:NN
+ \__wstf_para_after:
+ \__wstf_set_equation_depth:
+ \bool_gset_true:N \g__wstf_equation_dp_bool
+ \dim_gset:Nn \g__wstf_prevdepth_dim
+ { \box_dp:N \g__wstf_equation_box }
+ \vbox_unpack_drop:N \g__wstf_equation_box
+ }
+\cs_new_protected_nopar:Npn \__wstf_set_equation_depth:
+ {
+ \cs_gset_eq:NN \__wstf_para_after: \__wstf_empty:
+ \bool_gset_false:N \g__wstf_equation_dp_bool
+ \__wstf_set_prevdepth:N \g__wstf_prevdepth_dim
+ }
+\bool_new:N \g__wstf_equation_dp_bool
\cs_new_protected_nopar:Npn \__wstf_build_body_box:
{
\box_set_eq:NN \l__wstf_save_body_box \l__wstf_bottom_box
@@ -1029,9 +1308,6 @@
{
\vbox_set:Nn \l__wstf_body_box
{
- \__wstf_tex_parameter:
- \__wstf_make_parshape:
- \__wstf_column_penalties:
\dim_zero:N \tex_emergencystretch:D
\dim_set_eq:NN \tex_hfuzz:D \c_max_dim
\dim_set_eq:NN \tex_vfuzz:D \c_max_dim
@@ -1040,6 +1316,9 @@
\int_set:Nn \tex_tolerance:D { 1000 }
\para_raw_noindent:
\hbox_unpack_drop:N \l__wstf_bottom_box
+ \__wstf_tex_parameter:
+ \__wstf_make_parshape:
+ \__wstf_interline_penalties:
\para_raw_end:
\int_gset_eq:NN \g__wstf_line_int \tex_prevgraf:D
}
@@ -1062,8 +1341,8 @@
{ \c_zero_dim \l__wstf_l_dim }
\prg_replicate:nn
{
- \bool_if:NTF \g__wstf_column_right_bool
- { \g__wstf_column_window_int }
+ \bool_if:NTF \g__wstf_column_bool
+ { \g__wstf_column_int }
{ \l__wstf_window_int / 2 }
}
{ \c_zero_dim \l__wstf_r_dim }
@@ -1079,15 +1358,16 @@
}
\c_zero_dim \c_max_dim
}
-\cs_new_protected_nopar:Npn \__wstf_column_penalties:
+\cs_new_protected_nopar:Npn \__wstf_interline_penalties:
{
\bool_if:NF \l__wstf_hang_bool
{
- \bool_if:NT \l__wstf_column_bool
- { \__wstf_column_penalties_aux: }
+ \bool_if:NTF \l__wstf_column_bool
+ { \__wstf_column_penalties: }
+ { \__wstf_block_penalties: }
}
}
-\cs_new_protected_nopar:Npn \__wstf_column_penalties_aux:
+\cs_new_protected_nopar:Npn \__wstf_column_penalties:
{
\tex_interlinepenalties:D
\int_eval:n { \l__wstf_window_int / 2 + \c_one_int } ~
@@ -1097,90 +1377,70 @@
\c__wstf_break_int
\c_zero_int
}
+\cs_new_protected_nopar:Npn \__wstf_block_penalties:
+ {
+ \tex_interlinepenalties:D \l__wstf_window_int
+ \prg_replicate:nn
+ { \l__wstf_window_int - \c_one_int }
+ { \c__wstf_break_int }
+ \c_zero_int
+ }
+\cs_new_protected_nopar:Npn \__wstf_break:
+ { \tex_penalty:D \c__wstf_break_int }
+\cs_new_protected_nopar:Npn \__wstf_nobreak:
+ { \tex_penalty:D \c__wstf_nobreak_int }
+\int_const:Nn \c__wstf_break_int { -10000 }
+\int_const:Nn \c__wstf_nobreak_int { 10000 }
\cs_new_protected_nopar:Npn \__wstf_build_block:
{
- \__wstf_build_block_auxi:
\vbox_set:Nn \l__wstf_window_box
{
- \__wstf_tex_parameter:
- \dim_set_eq:NN \tex_hsize:D \l__wstf_line_dim
- \para_raw_noindent:
- \hbox_unpack_drop:N \g__wstf_line_box
- \para_raw_end:
+ \__wstf_split_parameter:
+ \skip_set_eq:NN \tex_baselineskip:D \g__wstf_baseline_skip
+ \__wstf_build_line:
}
- \bool_if:NT \l__wstf_attach_equation_bool
- {
- \box_set_ht:Nn \l__wstf_window_box
- { \box_ht_plus_dp:N \l__wstf_window_box - \g__wstf_dp_dim }
- \box_set_dp:Nn \l__wstf_window_box { \g__wstf_dp_dim }
- }
}
-\cs_new_protected_nopar:Npn \__wstf_build_block_auxi:
+\cs_new_protected_nopar:Npn \__wstf_build_line:
{
- \vbox_set:Nn \l__wstf_body_box
+ \vbox_set_split_to_ht:NNn \l__wstf_l_box \l__wstf_body_box
+ { \g__wstf_baseline_skip }
+ \vbox_set_split_to_ht:NNn \l__wstf_r_box \l__wstf_body_box
+ { \g__wstf_baseline_skip }
+ \__wstf_build_line_repack:
+ \box_if_empty:NTF \l__wstf_body_box
+ { \__wstf_put_last_line: }
{
- \vbox_unpack_drop:N \l__wstf_body_box
- \bool_lazy_and:nnTF
- { \box_if_empty_p:N \l__wstf_bottom_box }
- { \int_if_odd_p:n { \g__wstf_line_int } }
- { \box_set_eq:NN \l__wstf_r_box \l__wstf_empty_box }
- {
- \box_set_to_last:N \l__wstf_r_box
- \tex_unskip:D \tex_unpenalty:D
- }
- \box_set_to_last:N \l__wstf_l_box
- \tex_unskip:D \tex_unpenalty:D
- \hbox_gset:Nn \g__wstf_line_box
- {
- \bool_if:NT \l__wstf_attach_equation_bool
- { \__wstf_build_block_attach: }
- \box_use:N \l__wstf_l_box
- \tex_hfill:D
- \box_use:N \l__wstf_r_box
- }
- \__wstf_build_block_auxii:
+ \__wstf_put_line_box:
+ \__wstf_build_line:
}
}
-\cs_new_protected_nopar:Npn \__wstf_build_block_auxii:
+\cs_new_protected_nopar:Npn \__wstf_build_line_repack:
{
- \int_case:nnTF
- { \tex_lastnodetype:D }
+ \vbox_set:Nn \l__wstf_l_box
+ { \vbox_unpack_drop:N \l__wstf_l_box }
+ \box_if_empty:NF \l__wstf_r_box
{
- { \c__wstf_none_node } { }
- { \c__wstf_whatsit_node } { }
+ \vbox_set:Nn \l__wstf_r_box
+ { \vbox_unpack_drop:N \l__wstf_r_box }
}
- { \__wstf_build_block_finalise: }
- { \__wstf_build_block_auxiii: }
+ \__wstf_save_first_ht:
}
-\cs_new_protected_nopar:Npn \__wstf_build_block_auxiii:
+\cs_new_protected_nopar:Npn \__wstf_put_last_line:
{
- \box_set_to_last:N \l__wstf_r_box
- \tex_unskip:D \tex_unpenalty:D
- \box_set_to_last:N \l__wstf_l_box
- \tex_unskip:D \tex_unpenalty:D
- \hbox_gset:Nn \g__wstf_line_box
- {
- \box_use:N \l__wstf_l_box
- \tex_hfill:D
- \box_use:N \l__wstf_r_box
- \tex_penalty:D \c__wstf_break_int
- \hbox_unpack_drop:N \g__wstf_line_box
- }
- \__wstf_build_block_auxii:
+ \bool_if:NT \l__wstf_attach_equation_bool
+ { \__wstf_attach_left:N \l__wstf_l_box }
+ \__wstf_put_line_box:
}
-\cs_new_protected_nopar:Npn \__wstf_build_block_attach:
+\cs_new_protected_nopar:Npn \__wstf_put_line_box:
{
- \box_set_eq:NN \l__wstf_last_box \l__wstf_l_box
- \__wstf_attach_equation:N \l__wstf_last_box
- \dim_gset:Nn \g__wstf_dp_dim { \box_dp:N \l__wstf_last_box }
- \hbox_set:Nn \l__wstf_l_box
+ \hbox_to_wd:nn { \l__wstf_line_dim }
{
- \box_move_down:nn
- { \box_ht:N \l__wstf_last_box - \box_ht:N \l__wstf_l_box }
- { \box_use_drop:N \l__wstf_last_box }
+ \box_use_drop:N \l__wstf_l_box
+ \tex_hfil:D
+ \box_use_drop:N \l__wstf_r_box
}
}
-\cs_new_protected_nopar:Npn \__wstf_build_block_finalise:
+\cs_new_protected_nopar:Npn \__wstf_save_first_ht:
{
\dim_gset:Nn \g__wstf_ht_dim
{
@@ -1188,38 +1448,23 @@
{ \box_ht:N \l__wstf_l_box }
{ \box_ht:N \l__wstf_r_box }
}
+ \cs_set_eq:NN \__wstf_save_first_ht: \__wstf_empty:
}
-\dim_new:N \g__wstf_dp_dim
\dim_new:N \g__wstf_ht_dim
\box_new:N \l__wstf_l_box
\box_new:N \l__wstf_r_box
-\box_new:N \g__wstf_line_box
-\box_new:N \l__wstf_empty_box
-\hbox_set:Nn \l__wstf_empty_box { }
-\int_const:Nn \c__wstf_break_int { -10000 }
-\int_const:Nn \c__wstf_nobreak_int { 10000 }
\cs_new_protected_nopar:Npn \__wstf_build_column_fuzzy:
{
\hbox_set_to_wd:Nnn \l__wstf_window_box
{ \l__wstf_line_dim }
{
- \skip_zero:N \tex_splittopskip:D
- \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
- \int_set_eq:NN \tex_vbadness:D \c_max_int
+ \__wstf_split_parameter:
\__wstf_build_column_aux:
\box_if_empty:NT \l__wstf_bottom_box
{ \__wstf_build_column_fuzzy_aux: }
- \dim_gset:Nn \g__wstf_ht_dim { \box_ht:N \l__wstf_l_box }
- \vbox_set:Nn \l__wstf_l_box
- {
- \vbox_unpack_drop:N \l__wstf_l_box
- \bool_if:NT \l__wstf_attach_equation_bool
- {
- \box_set_to_last:N \l__wstf_last_box
- \__wstf_attach_equation:N \l__wstf_last_box
- \vbox_unpack_drop:N \l__wstf_last_box
- }
- }
+ \__wstf_repack_left_box:
+ \bool_if:NT \l__wstf_attach_equation_bool
+ { \__wstf_attach_left:N \l__wstf_l_box }
\box_use:N \l__wstf_l_box
\tex_hfil:D
\box_move_up:nn
@@ -1230,7 +1475,7 @@
\cs_new_protected_nopar:Npn \__wstf_build_column_aux:
{
\vbox_set_split_to_ht:NNn \l__wstf_l_box \l__wstf_body_box
- { \c_zero_dim }
+ { \box_ht:N \l__wstf_body_box / 2 }
\vbox_set_top:Nn \l__wstf_l_box
{ \vbox_unpack_drop:N \l__wstf_l_box }
\box_set_eq_drop:NN \l__wstf_r_box \l__wstf_body_box
@@ -1256,23 +1501,25 @@
\cs_new_protected_nopar:Npn \__wstf_rebuild_window:
{
\int_compare:nNnT \l__wstf_window_int > { 2 }
- {
- \int_sub:Nn \l__wstf_window_int { 2 }
- \box_set_eq_drop:NN \l__wstf_last_l_box \l__wstf_l_box
- \box_set_eq_drop:NN \l__wstf_last_r_box \l__wstf_r_box
- \box_set_eq:NN \l__wstf_bottom_box \l__wstf_save_body_box
- \int_set_eq:NN \l__wstf_window_line_int \l__wstf_window_int
- \__wstf_build_window:
- \__wstf_build_column_aux:
- \__wstf_build_column_fuzzy_aux:
- }
+ { \__wstf_rebuild_window_aux: }
}
+\cs_new_protected_nopar:Npn \__wstf_rebuild_window_aux:
+ {
+ \int_sub:Nn \l__wstf_window_int { 2 }
+ \box_set_eq_drop:NN \l__wstf_last_l_box \l__wstf_l_box
+ \box_set_eq_drop:NN \l__wstf_last_r_box \l__wstf_r_box
+ \box_set_eq:NN \l__wstf_bottom_box \l__wstf_save_body_box
+ \int_set_eq:NN \l__wstf_window_line_int \l__wstf_window_int
+ \__wstf_build_window:
+ \__wstf_build_column_aux:
+ \__wstf_build_column_fuzzy_aux:
+ }
+\box_new:N \l__wstf_last_l_box
+\box_new:N \l__wstf_last_r_box
\cs_new_protected_nopar:Npn \__wstf_build_column_strict:
{
\group_begin:
- \skip_zero:N \tex_splittopskip:D
- \dim_set_eq:NN \tex_vfuzz:D \c_max_dim
- \int_set_eq:NN \tex_vbadness:D \c_max_int
+ \__wstf_split_parameter:
\__wstf_build_column_aux:
\box_if_empty:NTF \l__wstf_r_box
{ \__wstf_build_column_strict_auxi: }
@@ -1280,7 +1527,7 @@
\box_if_empty:NTF \l__wstf_bottom_box
{ \__wstf_build_column_strict_auxii: }
{
- \bool_if:NTF \g__wstf_column_right_bool
+ \bool_if:NTF \g__wstf_column_bool
{ \__wstf_build_column_strict_auxiii: }
{ \__wstf_build_column_strict_auxiv: }
}
@@ -1292,9 +1539,9 @@
{
\__wstf_repack_left_box:
\bool_if:NT \l__wstf_attach_equation_bool
- { \__wstf_column_attach:N \l__wstf_l_box }
+ { \__wstf_attach_left:N \l__wstf_l_box }
\box_gset_eq_drop:NN \g__wstf_window_box \l__wstf_l_box
- \bool_gset_true:N \g__wstf_column_right_bool
+ \bool_gset_true:N \g__wstf_column_bool
\bool_if:NF \g__wstf_first_save_bool
{
\bool_gset_true:N \g__wstf_first_save_bool
@@ -1319,12 +1566,12 @@
\dim_gsub:Nn \g__wstf_first_sep_dim
{ \box_dp:N \l__wstf_window_box }
\bool_gset_false:N \g__wstf_entire_bool
- \dim_gzero:N \g__wstf_column_right_ht_dim
+ \dim_gzero:N \g__wstf_column_ht_dim
\dim_gset_eq:NN \g__wstf_prevdepth_dim \g__wstf_first_dp_dim
\__wstf_column_right_move_set:nn
{ \g__wstf_stuff_ht_dim }
{ \g__wstf_window_ht_dim }
- \int_gset_eq:NN \g__wstf_window_int \g__wstf_column_window_int
+ \int_gset_eq:NN \g__wstf_window_int \g__wstf_column_int
}
\cs_new_protected:Npn \__wstf_column_right_move_set:nn #1#2
{
@@ -1343,7 +1590,7 @@
\__wstf_make_next_stuff:nn
{ \l__wstf_line_dim - \l__wstf_r_dim - \l__wstf_rightsep_dim }
{#1}
- \dim_gset:Nn \g__wstf_column_left_dim {#2}
+ \dim_gset:Nn \g__wstf_column_room_dim {#2}
\int_gzero:N \g__wstf_top_int
}
\cs_new_protected_nopar:Npn \__wstf_build_column_strict_auxii:
@@ -1351,11 +1598,12 @@
\bool_gset_false:N \g__wstf_entire_bool
\__wstf_repack_left_box:
\bool_if:NT \l__wstf_attach_equation_bool
- { \__wstf_column_attach:N \l__wstf_r_box }
+ { \__wstf_attach_right:N \l__wstf_r_box }
\dim_gset:Nn \g__wstf_hang_ht_dim
{
\g__wstf_stuff_ht_dim - \tex_baselineskip:D *
\__wstf_unit:n { \box_ht_plus_dp:N \l__wstf_r_box }
+ - \box_ht_plus_dp:N \g__wstf_equation_box
- \g__wstf_pos_skip
}
\dim_compare:nNnTF \g__wstf_hang_ht_dim > \c_zero_dim
@@ -1368,19 +1616,21 @@
{
\int_compare:nNnTF \g__wstf_window_int > \c_zero_int
{
- \dim_gset:Nn \g__wstf_column_left_dim
+ \dim_gset:Nn \g__wstf_column_room_dim
{
\g__wstf_window_ht_dim
- \g__wstf_first_sep_dim
- - \box_ht:N \l__wstf_r_box
+ - \box_ht_plus_dp:N \l__wstf_r_box
+ - \box_ht_plus_dp:N \g__wstf_equation_box
}
\__wstf_next_hang_para:
}
{
- \dim_gset:Nn \g__wstf_column_left_dim
+ \dim_gset:Nn \g__wstf_column_room_dim
{
\box_ht:N \l__wstf_l_box
- - \box_ht:N \l__wstf_r_box
+ - \box_ht_plus_dp:N \l__wstf_r_box
+ - \box_ht_plus_dp:N \g__wstf_equation_box
}
\dim_gset:Nn \g__wstf_first_sep_dim
{ \tex_baselineskip:D - \g__wstf_ht_dim }
@@ -1393,11 +1643,15 @@
\box_use:N \l__wstf_l_box
\tex_hfil:D
\box_move_up:nn
- { \g__wstf_column_left_dim }
+ { \g__wstf_column_room_dim }
{ \box_use:N \l__wstf_r_box }
}
- \dim_gset:Nn \g__wstf_column_right_ht_dim
- { \box_ht:N \l__wstf_r_box + \g__wstf_pos_skip }
+ \dim_gset:Nn \g__wstf_column_ht_dim
+ {
+ \box_ht_plus_dp:N \l__wstf_r_box
+ + \box_ht_plus_dp:N \g__wstf_equation_box
+ + \g__wstf_pos_skip
+ }
}
\cs_new_protected_nopar:Npn \__wstf_column_put_right:
{
@@ -1424,7 +1678,7 @@
{
\__wstf_column_right_move_set:nn
{ \g__wstf_hang_ht_dim }
- { \g__wstf_column_left_dim }
+ { \g__wstf_column_room_dim }
\int_gzero:N \g__wstf_window_int
}
\bool_gset_false:N \g__wstf_next_hang_bool
@@ -1431,7 +1685,7 @@
}
\cs_new_protected_nopar:Npn \__wstf_build_column_strict_auxiii:
{
- \bool_gset_false:N \g__wstf_column_right_bool
+ \bool_gset_false:N \g__wstf_column_bool
\__wstf_repack_left_box:
\hbox_gset_to_wd:Nnn \g__wstf_window_box
{ \l__wstf_line_dim }
@@ -1462,32 +1716,8 @@
\vbox_set:Nn \l__wstf_l_box
{ \vbox_unpack_drop:N \l__wstf_l_box }
}
-\cs_new_protected_nopar:Npn \__wstf_column_attach:N #1
- {
- \vbox_set:Nn #1
- {
- \vbox_unpack_drop:N #1
- \box_set_to_last:N \l__wstf_last_box
- \__wstf_attach_equation:N \l__wstf_last_box
- \vbox_unpack_drop:N \l__wstf_last_box
- }
- }
-\box_new:N \l__wstf_last_l_box
-\box_new:N \l__wstf_last_r_box
\box_new:N \g__wstf_window_box
-\dim_new:N \g__wstf_fake_wd_dim
-\dim_new:N \g__wstf_first_dp_dim
-\dim_new:N \g__wstf_first_sep_dim
-\dim_new:N \g__wstf_column_left_dim
-\dim_new:N \g__wstf_column_right_ht_dim
-\bool_new:N \g__wstf_entire_bool
-\bool_new:N \g__wstf_next_hang_bool
-\bool_new:N \g__wstf_first_save_bool
-\bool_new:N \g__wstf_column_right_bool
-\bool_new:N \l__wstf_column_strict_bool
-\bool_new:N \g__wstf_first_set_bool
\bool_new:N \l__wstf_first_move_bool
-\bool_new:N \g__wstf_right_move_bool
\bool_new:N \l__wstf_column_bool
\cs_new_eq:NN \__wstf_build_column: \__wstf_build_column_strict:
\cs_new_eq:NN \__wstf_build_box: \__wstf_build_column:
@@ -1500,38 +1730,39 @@
{ \vbox_unpack:N \l__wstf_body_box }
\dim_gset:Nn \g__wstf_ht_dim { \box_ht:N \l__wstf_window_box }
}
- \bool_if:NTF \l__wstf_attach_equation_bool
- {
- \vbox_set:Nn \l__wstf_window_box
- {
- \vbox_unpack_drop:N \l__wstf_window_box
- \box_set_to_last:N \l__wstf_last_box
- \__wstf_attach_equation:N \l__wstf_last_box
- \vbox_unpack_drop:N \l__wstf_last_box
- }
- }
- { \box_set_eq_drop:NN \l__wstf_window_box \l__wstf_body_box }
- \dim_compare:nNnTF \g__wstf_column_left_dim > \c_zero_dim
- { \__wstf_build_hang_aux: }
- { \bool_gset_false:N \g__wstf_move_hang_bool }
+ \box_set_eq_drop:NN \l__wstf_window_box \l__wstf_body_box
+ \bool_if:NT \l__wstf_attach_equation_bool
+ { \__wstf_build_hang_attach: }
+ \dim_compare:nNnT \g__wstf_column_room_dim > \c_zero_dim
+ { \__wstf_build_hang_move: }
}
-\cs_new_protected_nopar:Npn \__wstf_build_hang_aux:
+\cs_new_protected_nopar:Npn \__wstf_build_hang_attach:
{
+ \dim_compare:nNnTF \l__wstf_r_dim = \c_zero_dim
+ { \__wstf_attach_left:N \l__wstf_window_box }
+ { \__wstf_attach_right:N \l__wstf_window_box }
+ }
+\cs_new_protected_nopar:Npn \__wstf_build_hang_move:
+ {
\dim_set:Nn \l__wstf_shift_dim
{
\dim_max:nn
{ \box_ht:N \l__wstf_window_box }
{ \tex_baselineskip:D * \g__wstf_line_int }
+ + \box_ht_plus_dp:N \g__wstf_equation_box
+ \tex_parskip:D
}
- \dim_gsub:Nn \g__wstf_column_left_dim { \l__wstf_shift_dim }
- \dim_compare:nNnTF \g__wstf_column_left_dim > \c_zero_dim
+ \dim_gsub:Nn \g__wstf_column_room_dim { \l__wstf_shift_dim }
+ \dim_compare:nNnTF \g__wstf_column_room_dim > \c_zero_dim
{
\box_if_empty:NTF \l__wstf_bottom_box
{ \bool_if:NT \g__wstf_right_move_bool { \__wstf_set_next_hang: } }
- { \bool_gset_false:N \g__wstf_move_hang_bool }
}
- { \bool_gset_false:N \g__wstf_move_hang_bool }
+ { \use:n }
+ {
+ \bool_gset_false:N \g__wstf_move_hang_bool
+ \bool_gset_false:N \g__wstf_right_move_bool
+ }
}
\cs_new_protected_nopar:Npn \__wstf_set_next_hang:
{
@@ -1541,75 +1772,67 @@
\dim_gset_eq:NN \g__wstf_hang_ht_dim \g__wstf_remaining_dim
}
\dim_gsub:Nn \g__wstf_hang_ht_dim { \l__wstf_shift_dim }
- \dim_gset:Nn \g__wstf_dp_dim { \box_dp:N \l__wstf_window_box }
\__wstf_column_right_move_set:nn
{ \g__wstf_hang_ht_dim }
- { \g__wstf_column_left_dim }
+ { \g__wstf_column_room_dim }
\int_gzero:N \g__wstf_window_int
}
-\dim_new:N \g__wstf_hang_ht_dim
-\bool_new:N \g__wstf_move_hang_bool
\cs_new_protected_nopar:Npn \__wstf_build_hangfrom:
{
- \dim_compare:nNnTF \g__wstf_prevdepth_dim > \c__wstf_ignore_depth_dim
- { \__wstf_build_hangfrom_aux: }
- { \dim_gzero:N \g__wstf_ht_dim }
- }
-\cs_new_protected_nopar:Npn \__wstf_build_hangfrom_aux:
- {
\group_begin:
- \skip_zero:N \tex_splittopskip:D
- \vbox_gset:Nn \g__wstf_line_box
+ \vbox_gset:Nn \g__wstf_window_box
{
- \tex_penalty:D \c__wstf_break_int
+ \__wstf_break:
\vbox_unpack:N \l__wstf_body_box
}
- \vbox_set_split_to_ht:NNn \l__wstf_last_box \g__wstf_line_box
+ \__wstf_split_parameter:
+ \vbox_set_split_to_ht:NNn \l__wstf_last_box \g__wstf_window_box
{ \c_zero_dim }
\dim_gset:Nn \g__wstf_ht_dim
{
\g__wstf_baseline_skip
- \g__wstf_prevdepth_dim
- - \l__wstf_shift_dim
- \box_ht:N \l__wstf_body_box
- + \box_ht:N \g__wstf_line_box
+ + \box_ht:N \g__wstf_window_box
}
\group_end:
- \box_set_eq_drop:NN \l__wstf_body_box \g__wstf_line_box
+ \box_set_eq_drop:NN \l__wstf_body_box \g__wstf_window_box
}
\cs_new_protected_nopar:Npn \__wstf_put_box:
{
- \para_raw_end:
+ \__wstf_para_raw_end:
\dim_compare:nNnTF \g__wstf_prevdepth_dim > \c__wstf_ignore_depth_dim
{ \__wstf_add_vskip: }
- { \skip_gzero:N \g__wstf_pre_skip }
+ { \__wstf_set_vskip: }
\skip_set_eq:NN \l__wstf_par_skip \tex_parskip:D
\skip_zero:N \tex_parskip:D
+ \dim_set:Nn \l__wstf_window_ht_dim
+ { \box_ht_plus_dp:N \l__wstf_window_box }
\bool_if:NTF \g__wstf_right_move_bool
{ \__wstf_put_box_aux: }
{
\box_if_empty:NTF \l__wstf_bottom_box
- {
- \dim_compare:nNnTF
- { \g__wstf_remaining_dim }
- >
- { \box_ht_plus_dp:N \l__wstf_window_box }
- { \__wstf_set_next: }
- { \__wstf_put_box_aux: }
- }
+ { \__wstf_put_next_test: }
{ \__wstf_put_box_aux: }
}
}
+\dim_new:N \l__wstf_window_ht_dim
\skip_new:N \l__wstf_par_skip
-\cs_new_protected_nopar:Npn \__wstf_put_box_aux:
+\cs_new_protected_nopar:Npn \__wstf_put_next_test:
{
- \int_gzero:N \g__wstf_window_int
- \__wstf_hbox:n
+ \box_if_empty:NF \g__wstf_equation_box
{
- \__wstf_put_window_box:
- \bool_if:NF \g__wstf_next_bool
- { \__wstf_put_stuff_box: }
+ \dim_add:Nn \l__wstf_window_ht_dim
+ { \box_ht_plus_dp:N \g__wstf_equation_box + \g__wstf_pos_skip }
}
+ \dim_compare:nNnTF
+ { \g__wstf_remaining_dim + \g__wstf_pos_skip } > \l__wstf_window_ht_dim
+ { \__wstf_set_next: }
+ { \__wstf_put_box_aux: }
+ }
+\cs_new_protected_nopar:Npn \__wstf_put_box_aux:
+ {
+ \__wstf_output_window_box:
\box_if_empty:NTF \l__wstf_bottom_box
{ \__wstf_put_trailer_box: }
{ \__wstf_put_bottom_box: }
@@ -1625,32 +1848,49 @@
\bool_if:NTF \g__wstf_right_move_bool
{ \__wstf_next_para_trailer: }
{
- \__wstf_add_pos_skip:
- \box_if_empty:NF \g__wstf_pos_box
- {
- \__wstf_newline:
- \hbox_unpack_drop:N \g__wstf_pos_box
- }
+ \__wstf_add_pos_kludge:
+ \__wstf_put_pos_box:
+ \__wstf_clear_variable:
}
}
}
\cs_new_protected_nopar:Npn \__wstf_put_bottom_box:
{
- \__wstf_newline:
+ \__wstf_para_raw_end:
+ \para_raw_noindent:
\hbox_unpack_drop:N \l__wstf_bottom_box
\box_if_empty:NF \g__wstf_equation_box
{ \__wstf_insert_equation: }
+ \__wstf_put_pos_box:
+ \__wstf_clear_variable:
+ }
+\cs_new_protected_nopar:Npn \__wstf_output_window_box:
+ {
+ \__wstf_hbox:n
+ {
+ \__wstf_put_window_box:
+ \bool_if:NF \g__wstf_next_bool
+ { \__wstf_output_stuff_box: }
+ }
+ }
+\cs_new_protected_nopar:Npn \__wstf_put_pos_box:
+ {
\box_if_empty:NF \g__wstf_pos_box
- { \hbox_unpack_drop:N \g__wstf_pos_box }
- \bool_gset_false:N \g__wstf_right_move_bool
- \bool_gset_false:N \g__wstf_first_save_bool
+ { \__wstf_output_pos_box: }
}
-\cs_new_protected_nopar:Npn \__wstf_newline:
+\cs_new_protected_nopar:Npn \__wstf_output_pos_box:
{
- \tex_penalty:D \c__wstf_nobreak_int
- \tex_hfil:D
- \tex_penalty:D \c__wstf_break_int
+ \__wstf_if_last_none:F
+ { \__wstf_output_pos_box_aux: }
+ \hbox_unpack_drop:N \g__wstf_pos_box
}
+\cs_new_protected_nopar:Npn \__wstf_output_pos_box_aux:
+ {
+ \__wstf_para_raw_end:
+ \bool_if:NT \g__wstf_equation_dp_bool
+ { \__wstf_set_equation_depth: }
+ \para_raw_noindent:
+ }
\cs_new_protected:Npn \__wstf_hbox:n #1
{
\para_raw_noindent:
@@ -1664,22 +1904,22 @@
{ \skip_horizontal:n { \l__wstf_line_dim - \l__wstf_r_dim } }
\box_use:N \l__wstf_window_box
}
-\cs_new_protected_nopar:Npn \__wstf_put_stuff_box:
+\cs_new_protected_nopar:Npn \__wstf_output_stuff_box:
{
- \__wstf_move_stuff_box:nn { up }
+ \hbox_gset:Nn \g__wstf_stuff_box
{
- \l__wstf_voffset_dim
- + ( \box_dp:N \g__wstf_stuff_box -
- \box_dp:N \l__wstf_window_box )
- + ( \box_ht_plus_dp:N \l__wstf_window_box -
- \g__wstf_stuff_ht_dim ) / 2
- \box_if_empty:NT \l__wstf_bottom_box
- { - \g__wstf_pos_skip / 2 }
+ \__wstf_parshape_kern:
+ \box_move_up:nn
+ {
+ + \box_ht:N \l__wstf_window_box
+ - ( \l__wstf_window_ht_dim
+ + \box_ht_plus_dp:N \g__wstf_stuff_box ) / 2
+ + \l__wstf_voffset_dim
+ }
+ { \box_use_drop:N \g__wstf_stuff_box }
}
- \__wstf_output_stuff_box:
- }
-\cs_new_protected_nopar:Npn \__wstf_output_stuff_box:
- {
+ \box_gset_ht:Nn \g__wstf_stuff_box { \c_zero_dim }
+ \box_gset_dp:Nn \g__wstf_stuff_box { \c_zero_dim }
\skip_horizontal:n
{
\dim_compare:nNnTF \l__wstf_r_dim > \c_zero_dim
@@ -1699,18 +1939,6 @@
}
\box_use_drop:N \g__wstf_stuff_box
}
-\cs_new_protected:Npn \__wstf_move_stuff_box:nn #1#2
- {
- \hbox_gset:Nn \g__wstf_stuff_box
- {
- \__wstf_parshape_kern:
- \use:c { box_move_ #1 :nn }
- {#2}
- { \box_use_drop:N \g__wstf_stuff_box }
- }
- \box_gset_ht:Nn \g__wstf_stuff_box { \c_zero_dim }
- \box_gset_dp:Nn \g__wstf_stuff_box { \c_zero_dim }
- }
\cs_new_protected_nopar:Npn \__wstf_add_vskip:
{
\box_if_empty:NTF \g__wstf_display_box
@@ -1719,6 +1947,7 @@
}
\cs_new_protected_nopar:Npn \__wstf_add_vskip_display:
{
+ \bool_set_true:N \l__wstf_display_pre_bool
\vbox_unpack_drop:N \g__wstf_display_box
\__wstf_ignore_depth:
}
@@ -1726,18 +1955,15 @@
{
\dim_compare:nNnTF \tex_pagegoal:D < \c_max_dim
{ \__wstf_add_vskip_auxii: }
- { \__wstf_add_vskip_auxiii: }
+ {
+ \bool_if:NTF \g__wstf_next_bool
+ { \__wstf_add_vskip_auxii: }
+ { \__wstf_add_vskip_auxiii: }
+ }
}
\cs_new_protected_nopar:Npn \__wstf_add_vskip_auxii:
{
- \skip_gset:Nn \g__wstf_pre_skip
- {
- \g__wstf_baseline_skip
- - \g__wstf_prevdepth_dim
- - \g__wstf_ht_dim
- }
- \dim_compare:nNnT \g__wstf_pre_skip < \tex_lineskiplimit:D
- { \skip_gset_eq:NN \g__wstf_pre_skip \tex_lineskip:D }
+ \__wstf_add_vskip_auxiv:
\bool_if:NTF \l__wstf_first_move_bool
{ \__wstf_first_move_skip: }
{ \skip_vertical:N \g__wstf_pre_skip }
@@ -1745,15 +1971,26 @@
}
\cs_new_protected_nopar:Npn \__wstf_add_vskip_auxiii:
{
+ \__wstf_add_vskip_auxiv:
+ \skip_vertical:N \g__wstf_pre_skip
\dim_compare:nNnTF \tex_topskip:D > \g__wstf_ht_dim
{
+ \skip_sub:Nn \tex_topskip:D { \g__wstf_ht_dim }
\tex_hrule:D height \c_zero_dim \scan_stop:
- \skip_gset:Nn \g__wstf_pre_skip
- { \tex_topskip:D - \g__wstf_ht_dim }
- \skip_vertical:n { \g__wstf_pre_skip - \tex_topskip:D }
}
- { \skip_gzero:N \g__wstf_pre_skip }
+ { \__wstf_ignore_depth: }
}
+\cs_new_protected_nopar:Npn \__wstf_add_vskip_auxiv:
+ {
+ \skip_gset:Nn \g__wstf_pre_skip
+ {
+ \g__wstf_baseline_skip
+ - \g__wstf_prevdepth_dim
+ - \g__wstf_ht_dim
+ }
+ \dim_compare:nNnT \g__wstf_pre_skip < \tex_lineskiplimit:D
+ { \skip_gset_eq:NN \g__wstf_pre_skip \tex_lineskip:D }
+ }
\cs_new_protected_nopar:Npn \__wstf_first_move_skip:
{
\skip_vertical:n
@@ -1761,11 +1998,21 @@
\g__wstf_first_sep_dim
- \g__wstf_window_ht_dim
- \tex_parskip:D
- \dim_compare:nNnT \g__wstf_column_right_ht_dim > \c_zero_dim
- { + \g__wstf_column_right_ht_dim + \g__wstf_pre_skip }
+ \dim_compare:nNnT \g__wstf_column_ht_dim > \c_zero_dim
+ { + \g__wstf_column_ht_dim + \g__wstf_pre_skip }
}
}
\skip_new:N \g__wstf_pre_skip
+\bool_new:N \l__wstf_display_pre_bool
+\cs_new_protected_nopar:Npn \__wstf_set_vskip:
+ {
+ \box_if_empty:NTF \g__wstf_display_box
+ {
+ \skip_gset:Nn \g__wstf_pre_skip
+ { \g__wstf_baseline_skip - \g__wstf_ht_dim }
+ }
+ { \__wstf_add_vskip_display: }
+ }
\cs_new_protected_nopar:Npn \__wstf_ignore_depth:
{ \dim_set_eq:NN \tex_prevdepth:D \c__wstf_ignore_depth_dim }
\cs_new_protected_nopar:Npn \__wstf_set_prevdepth:N
@@ -1775,24 +2022,19 @@
{
\dim_set:Nn \l__wstf_height_dim
{
- \g__wstf_pre_skip
- + \g__wstf_pos_skip
- + \box_ht_plus_dp:N \l__wstf_window_box
+ \bool_if:NT \g__wstf_next_bool { \l__wstf_par_skip }
+ + \g__wstf_pre_skip
+ + \l__wstf_window_ht_dim
}
\dim_gadd:Nn \g__wstf_total_ht_dim { \l__wstf_height_dim }
\dim_set:Nn \l__wstf_shift_dim
{ \g__wstf_remaining_dim - \l__wstf_height_dim }
- \dim_compare:nNnTF \l__wstf_shift_dim > \c_zero_dim
- { \__wstf_set_next_auxi: }
- {
- \dim_compare:nNnTF
- { - \l__wstf_shift_dim } > \l__wstf_min_dim
- { \__wstf_set_next_auxii: }
- { \__wstf_set_next_auxi: }
- }
+ \dim_compare:nNnTF
+ { - \l__wstf_shift_dim } < \l__wstf_min_dim
+ { \__wstf_set_next_para: }
+ { \__wstf_set_next_output: }
}
-\dim_new:N \g__wstf_total_ht_dim
-\cs_new_protected_nopar:Npn \__wstf_set_next_auxi:
+\cs_new_protected_nopar:Npn \__wstf_set_next_para:
{
\int_gset:Nn \g__wstf_window_int
{
@@ -1801,9 +2043,7 @@
{ \c_one_int }
}
\__wstf_set_next_verify:
- \bool_if:NF \g__wstf_next_bool
- { \__wstf_move_next_stuff_box: }
- \__wstf_set_next_output:
+ \__wstf_output_window_box:
\__wstf_make_next_stuff:nn
{ \g__wstf_stuff_wd_dim }
{ \l__wstf_shift_dim }
@@ -1810,59 +2050,31 @@
\int_gzero:N \g__wstf_top_int
\__wstf_next_para_trailer:
}
-\cs_new_protected_nopar:Npn \__wstf_move_next_stuff_box:
- {
- \__wstf_move_stuff_box:nn { down }
- {
- \box_ht:N \g__wstf_stuff_box
- - \box_ht:N \l__wstf_window_box
- + ( \g__wstf_window_ht_dim
- - \g__wstf_stuff_ht_dim
- - \g__wstf_pre_skip
- + \g__wstf_pos_skip
- + \l__wstf_par_skip ) / 2
- - \l__wstf_voffset_dim
- }
- }
-\cs_new_protected_nopar:Npn \__wstf_set_next_auxii:
- {
- \int_gzero:N \g__wstf_window_int
- \bool_if:NF \g__wstf_next_bool
- {
- \__wstf_move_stuff_box:nn { down }
- {
- \box_ht:N \g__wstf_stuff_box
- - \box_ht:N \l__wstf_window_box
- - \l__wstf_voffset_dim
- }
- }
- \__wstf_set_next_output:
- \__wstf_add_pos_skip:
- }
\cs_new_protected_nopar:Npn \__wstf_set_next_output:
{
- \__wstf_hbox:n
- {
- \__wstf_put_window_box:
- \bool_if:NF \g__wstf_next_bool
- { \__wstf_output_stuff_box: }
- }
+ \__wstf_output_window_box:
+ \__wstf_add_pos_kludge:
+ \__wstf_put_pos_box:
+ \__wstf_clear_variable:
}
\cs_new_protected_nopar:Npn \__wstf_set_next_verify:
{
\dim_set:Nn \l__wstf_height_dim
- { \g__wstf_window_ht_dim - \g__wstf_total_ht_dim }
- \dim_until_do:nNnn
+ { \g__wstf_window_ht_dim - \g__wstf_total_ht_dim - \l__wstf_min_dim }
+ \dim_while_do:nNnn
{ \tex_baselineskip:D * \g__wstf_window_int + \l__wstf_par_skip }
- >
+ <
{ \l__wstf_height_dim }
{ \int_gincr:N \g__wstf_window_int }
- \dim_gadd:Nn \g__wstf_total_ht_dim
- { \tex_baselineskip:D * \g__wstf_window_int + \l__wstf_par_skip }
+ \bool_if:NF \g__wstf_next_bool
+ {
+ \dim_add:Nn \l__wstf_window_ht_dim
+ { \tex_baselineskip:D * \g__wstf_window_int + \l__wstf_par_skip }
+ }
}
\cs_new_protected_nopar:Npn \__wstf_next_para_trailer:
{
- \__wstf_add_pos_skip:
+ \__wstf_add_pos_kludge:
\box_if_empty:NTF \g__wstf_pos_box
{ \__wstf_next_para: }
{
@@ -1877,7 +2089,6 @@
\dim_gset:Nn \g__wstf_stuff_wd_dim {#1}
\dim_gset:Nn \g__wstf_remaining_dim {#2}
}
-\bool_new:N \g__wstf_next_bool
\cs_new_protected:Npn \__wstf_extract_display_hbox:NN #1
{
\box_gclear:N \g__wstf_pos_box
@@ -1938,11 +2149,7 @@
\dim_new:N \g__wstf_display_pre_dim
\cs_new_protected_nopar:Npn \__wstf_test_display_math:
{
- \__wstf_if_last_hlist:T
- {
- \box_gset_to_last:N \g__wstf_pos_box
- \tex_unskip:D
- }
+ \__wstf_if_last_hlist:T { \__wstf_extract_pos_hbox: }
\box_clear:N \l__wstf_add_box
\box_gclear:N \g__wstf_display_box
\skip_gzero:N \g__wstf_last_skip
@@ -1954,14 +2161,21 @@
\__wstf_add_last_skip:w
\__wstf_add_last_skip:w
\__wstf_add_last_penalty:w
- \__wstf_add_last_finalise:w \q_stop
+ \__wstf_add_last_finalise:w \s_stop
}
+\cs_new_protected_nopar:Npn \__wstf_extract_pos_hbox:
+ {
+ \box_gset_to_last:N \g__wstf_last_box
+ \__wstf_repack_hbox:N \l__wstf_last_box
+ \box_gset_eq_drop:NN \g__wstf_pos_box \l__wstf_last_box
+ \tex_unskip:D
+ }
\box_new:N \l__wstf_add_box
\box_new:N \g__wstf_pos_box
\cs_new_protected_nopar:Npn \__wstf_add_last_stop:w
{
\vbox_unpack_drop:N \l__wstf_add_box
- \use_none_delimit_by_q_stop:w
+ \use_none_delimit_by_s_stop:w
}
\cs_new_protected_nopar:Npn \__wstf_add_last_skip:w
{
@@ -2027,7 +2241,7 @@
}
{ \box_gset_eq_drop:NN \g__wstf_display_box \l__wstf_add_box }
{ \vbox_unpack_drop:N \l__wstf_add_box }
- \use_none_delimit_by_q_stop:w
+ \use_none_delimit_by_s_stop:w
}
\int_new:N \g__wstf_display_pre_int
\skip_new:N \g__wstf_display_pre_skip
@@ -2293,11 +2507,11 @@
}
\regex_const:Nn \c__wstf_integer_regex { \A \d+ \Z }
\cs_new_protected_nopar:Npn \__wstf_unknown_key_error:n
- { \msg_error:nnn { wrapstuff } { unknown-key } }
-\msg_new:nnnn { wrapstuff } { unknown-key }
- { The~key~'#1'~is~unknown~and~is~being~ignored. }
+ { \msg_error:nnn { wstf } { unknown-key } }
+\msg_new:nnnn { wstf } { unknown-key }
+ { The~key~"#1"~is~unknown~and~is~being~ignored. }
{
- The~package~wrapstuff~does~not~have~a~key~called~'#1'.\\
+ The~package~wrapstuff~does~not~have~a~key~called~"#1".\\
Check~that~you~have~spelled~the~key~name~correctly.
}
\NewDocumentCommand \wrapstuffset { m }
More information about the tex-live-commits
mailing list.