diff options
author | Norbert Preining <norbert@preining.info> | 2022-07-27 03:00:56 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2022-07-27 03:00:56 +0000 |
commit | ba846abb1dbfe9c19277bb894d88c7cce953b4be (patch) | |
tree | 8e086071d6cad7f29221e0a94fe03e60c2d5aaa1 /macros/latex/contrib | |
parent | ae37b2329c8f0475412617b3248d58906904d54d (diff) |
CTAN sync 202207270300
Diffstat (limited to 'macros/latex/contrib')
-rw-r--r-- | macros/latex/contrib/intopdf/intopdf.dtx | 12 | ||||
-rw-r--r-- | macros/latex/contrib/intopdf/intopdf.pdf | bin | 378812 -> 379897 bytes | |||
-rw-r--r-- | macros/latex/contrib/rec-thy/README | 1 | ||||
-rw-r--r-- | macros/latex/contrib/rec-thy/rec-thy.pdf | bin | 127698 -> 128602 bytes | |||
-rw-r--r-- | macros/latex/contrib/rec-thy/rec-thy.sty | 37 | ||||
-rw-r--r-- | macros/latex/contrib/rec-thy/rec-thy.tex | 3 | ||||
-rw-r--r-- | macros/latex/contrib/wrapstuff/wrapstuff.dtx | 1381 | ||||
-rw-r--r-- | macros/latex/contrib/wrapstuff/wrapstuff.pdf | bin | 422157 -> 449185 bytes |
8 files changed, 886 insertions, 548 deletions
diff --git a/macros/latex/contrib/intopdf/intopdf.dtx b/macros/latex/contrib/intopdf/intopdf.dtx index 86d1454acc..aa474573bb 100644 --- a/macros/latex/contrib/intopdf/intopdf.dtx +++ b/macros/latex/contrib/intopdf/intopdf.dtx @@ -35,6 +35,7 @@ \usepackage{intopdf,metalogo} \begin{document} \DocInput{intopdf.dtx} +\clearpage \PrintIndex \PrintChanges \end{document} @@ -46,7 +47,7 @@ % % \GetFileInfo{intopdf.dtx} % \title{The \pkg{intopdf} package\thanks{This document -% corresponds to \pkg{intopdf}~0.4.0, dated~2021/02/26.}} +% corresponds to \pkg{intopdf}~0.4.1, dated~2022/07/21.}} % \author{Marcel Kr\"uger \\ \href{mailto:tex@2krueger.de}{tex@2krueger.de}} % % \maketitle @@ -89,8 +90,8 @@ \RequirePackage{expl3,xparse} \ProvidesExplPackage {intopdf} - {2021/02/26} - {0.4.0} + {2022/07/21} + {v0.4.1} {Embed non-PDF files into PDF with hyperlink} \RequirePackage{hyperref} @@ -100,6 +101,7 @@ % \changes{v0.2.0}{2019/05/21}{Added filespec support. (The first optional argument) Added \cs{intopdf_attach_link:nnnnn}.} % \changes{v0.3.0}{2020/03/13}{Switched to \texttt{l3pdf} instead of using primitives directly. Currently some internal functions from \texttt{l3backend} are needed too for handling links.} % \changes{v0.4.0}{2021/02/26}{Update to new \texttt{l3pdf} names and support more engines.} +% \changes{v0.4.1}{2022/07/21}{Properly separate legacy and Unicode filenames} % The main functionality. % \begin{macrocode} \str_new:N \l__intopdf_mime_str @@ -112,11 +114,13 @@ \pdf_object_unnamed_write:nx {fstream} { { /Subtype /\l__intopdf_mime_str } { #2 } } - \str_set_convert:Nnnn \l__intopdf_filename_str { #1 } { default } { utf16/string } + \str_set_convert:Nnnn \l__intopdf_filename_str { #1 } { default } { utf8/string } + \str_set_convert:Nnnn \l__intopdf_filename_unicode_str { #1 } { default } { utf16/string } \str_set_convert:Nnnn \l__intopdf_description_str { #4 } { default } { utf16/string } \pdf_object_unnamed_write:nx {dict} { /Type /Filespec /F (\l__intopdf_filename_str) + /UF (\l__intopdf_filename_unicode_str) /EF << /F~\pdf_object_ref_last: >> /Desc (\l__intopdf_description_str) } diff --git a/macros/latex/contrib/intopdf/intopdf.pdf b/macros/latex/contrib/intopdf/intopdf.pdf Binary files differindex 99a5f4338f..e361d41580 100644 --- a/macros/latex/contrib/intopdf/intopdf.pdf +++ b/macros/latex/contrib/intopdf/intopdf.pdf diff --git a/macros/latex/contrib/rec-thy/README b/macros/latex/contrib/rec-thy/README index e7e6761ca9..be0217da27 100644 --- a/macros/latex/contrib/rec-thy/README +++ b/macros/latex/contrib/rec-thy/README @@ -42,3 +42,4 @@ v3.6 - Fixed \REA[n] so that dash is shorter. Added BeamerRequirements to add a v3.7 - Fixed cases enviornment (both prettier and no problem with creating newline). Major refactor to fix all options. Fixed bug with \set display. Added \st command inside the \set command to depreciate second argument. Added experimental commands \finSsets (alt \ssetsOfsize), \finsets and optional argument to \powset. Changed \REAop so the hat is on the starred version as intended. Added the steps (experimental) code which requires an option to enable and fixed some problems with existing options. Reimplemented \REset to use xparse to avoid some errors in unusual contexts. Fixed the display of \tpath. Depreciated \iREAop and \oneREAop. v3.8 - Adjusted \Tdeg to be more beamer friendly and fixed it not to dumbly underline 0^n. Fixed BeamerRequirements to work with differing values of \abovedisplayskip. Removed a few typos in docs for the requirements assistance. Added BeamerRequire and BeamerRequire* that put the requirements in a block and offer overlay specifications. v3.8.1 Fixed issues displaying the prime for jump operations +v3.8.2 Removed option to put the set at the end of an \REset operation to avoid capturing later paren arguments, e.g. \REset{i}(A) no longer works to avoid confusion with \REset{i}(x). diff --git a/macros/latex/contrib/rec-thy/rec-thy.pdf b/macros/latex/contrib/rec-thy/rec-thy.pdf Binary files differindex 4e691732fe..b710697678 100644 --- a/macros/latex/contrib/rec-thy/rec-thy.pdf +++ b/macros/latex/contrib/rec-thy/rec-thy.pdf diff --git a/macros/latex/contrib/rec-thy/rec-thy.sty b/macros/latex/contrib/rec-thy/rec-thy.sty index 36f77892a9..2020e4527a 100644 --- a/macros/latex/contrib/rec-thy/rec-thy.sty +++ b/macros/latex/contrib/rec-thy/rec-thy.sty @@ -10,10 +10,10 @@ \RequirePackage{etoolbox} \RequirePackage{pict2e,picture} \RequirePackage{xparse} -\def\recthyVersion{3.8.1} +\def\recthyVersion{3.8.2} \ProvidesExplPackage {rec-thy} - {2022/04/24} + {2022/07/26} {\recthyVersion} {Provides commands for writing up recursion theory papers} @@ -1955,7 +1955,7 @@ % \NewDocumentCommand{\REset}{D(){}omd()}{ % W_{#2\IfNoValueTF{#1}{}{, #1}}\IfNoValueTF{#3}{}{^{#3}} % } - \NewDocumentCommand{\REset}{D(){}oD(){#1}mD(){#3}}{{W_{#4\IfValueTF{#2}{, #2}{}}^{#5}}} + \NewDocumentCommand{\REset}{D(){}oD(){#1}mO{#2}}{{W_{#4\IfValueTF{#5}{, #5}{}}^{#3}}} % \newcommand*{\REset}{\let\@PMG@parenarg\@PMG@undefined\let\@PMG@braketarg\@PMG@undefined\@REsetbody} % \newcommand*{\@REsetbody}[1]{W\ifdefined\@PMG@parenarg % ^{\@PMG@parenarg}% @@ -2053,8 +2053,6 @@ \providecommand*{\Teq}{\Tequiv} \providecommand*{\nTequiv}{\mathrel{\ncong_{\@recthy@TSYM}}} \providecommand*{\nTeq}{\nTequiv} - %turing below - \providecommand*{\Tlneq}{\lneq_{\@recthy@TSYM}} \providecommand*{\Tleq}{\leq_{\@recthy@TSYM}} \providecommand*{\Tgneq}{\gneq_{\@recthy@TSYM}} @@ -2091,6 +2089,35 @@ \newcommand*{\ttless}{<_{\@recthy@ttSYM}} \newcommand*{\ttnleq}{\nleq_{\@recthy@ttSYM}} \newcommand*{\ttngeq}{\ngeq_{\@recthy@ttSYM}} + +%arithmetic comparisons + + + + \newcommand*{\@recthy@ASYM}{\symbf{a}} + \providecommand*{\Adegvar}[1]{\symbf{#1}_{\@recthy@ASYM}} + \providecommand*{\Aequiv}{\mathrel{\equiv_{\@recthy@ASYM}}} + \providecommand*{\Aeq}{\Aequiv} + \providecommand*{\nAequiv}{\mathrel{\ncong_{\@recthy@ASYM}}} + \providecommand*{\nAeq}{\nAequiv} + \providecommand*{\Alneq}{\lneq_{\@recthy@ASYM}} + \providecommand*{\Aleq}{\leq_{\@recthy@ASYM}} + \providecommand*{\Agneq}{\gneq_{\@recthy@ASYM}} + \providecommand*{\Ageq}{\geq_{\@recthy@ASYM}} + \providecommand*{\Agtr}{>_{\@recthy@ASYM}} + \providecommand*{\Aless}{<_{\@recthy@ASYM}} + \providecommand*{\nAleq}{\nleq_{\@recthy@ASYM}} + \providecommand*{\nAgeq}{\ngeq_{\@recthy@ASYM}} + \providecommand*{\wjump}[1]{\jumpn{#1}{\omega}} + \providecommand*{\zerow}[1]{\zeron{\omega}} + + \newcommand*{\Azerosym}{\symbf{0}_{\@recthy@ASYM}} + \providecommand*{\Azero}{{\Azerosym}} + \providecommand*{\Azeron}[1]{{\Azerosym}^{(#1)}} + \providecommand*{\Azeroj}{\jump{{\Azerosym}}} + \providecommand*{\Azerojj}{\jjump{\Azerosym}} + \providecommand*{\Azerojjj}{\jjjump{\Azerosym}} + \fi diff --git a/macros/latex/contrib/rec-thy/rec-thy.tex b/macros/latex/contrib/rec-thy/rec-thy.tex index b80b17f6b5..c3fe39ddd3 100644 --- a/macros/latex/contrib/rec-thy/rec-thy.tex +++ b/macros/latex/contrib/rec-thy/rec-thy.tex @@ -781,6 +781,9 @@ Finally to enable the mrref helper macros pass the option \verb=mrref=.\\ These % TESTING: \verb=\fpmapsto=, \verb=\fpmapsfrom=, \verb=\ParFuncs{Y}{X}= and \verb=\FinParFuncs{Y}{X}= \begin{itemize} + \item[3.8.2] Removed option to put the set at the end of an \verb=\REset= operation to avoid capturing later parenthesized arguments, e.g. \verb=\REset{i}(A)= no longer works to avoid confusion with \verb=\REset{i}(x)=. Fixed failed pdf doc update. + \item[3.8.1] Fixed issues displaying the prime for jump operations. + \item[3.8] Adjusted \verb=\Tdeg= to be more beamer friendly and fixed it not to dumbly underline \verb=0^n=. Fixed BeamerRequirements to work with differing values of \verb=\abovedisplayskip=. Removed a few typos in docs for the requirements assistance. Added BeamerRequire and BeamerRequire* that put the requirements in a block and offer overlay specifications. \item[3.7] Fixed cases environment (both prettier and no problem with creating newline). Major re-factor to fix all options. Fixed bug with \verb=\set= display. Added \verb=\st= command inside the \verb=\set= command to depreciate second argument. Added \verb=\finSsets= (alt \verb=\ssetsOfsize=), \verb=\finsets= and optional argument to \verb=\powset=. Changed \verb=\REAop= so the hat is on the starred version as intended. Added the steps (experimental) environment which requires an option to enable and fixed some problems with existing options. Reimplemented \verb=\REset= to use xparse to avoid some errors in unusual contexts. Fixed the display of \verb=\tpath=. Depreciated \verb=\iREAop= and \verb=\oneREAop=. Fixed \verb=\Join=. \item[3.6] Fixed \verb=\REA[n]= so that dash is shorter. Added BeamerRequirements to add a block for requirements in beamer and fixed the requirements environment for beamer. Fixed \verb=\req*= error. Improved syntax for \verb=\recfnl= so it can accept a parenthesis delimited argument as the oracle. Improved \verb=\setcol= to allow it to be used in a nested fashion without typesetting bugs. Changed the \verb=\code= and \verb=\pair= commands to use only a single angle bracket. \item[3.5] Added \verb=\Hop= and misc code cleanup. diff --git a/macros/latex/contrib/wrapstuff/wrapstuff.dtx b/macros/latex/contrib/wrapstuff/wrapstuff.dtx index 5b8c03ec03..7fef0c9542 100644 --- a/macros/latex/contrib/wrapstuff/wrapstuff.dtx +++ b/macros/latex/contrib/wrapstuff/wrapstuff.dtx @@ -119,12 +119,12 @@ Copyright and Licence %<*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@gmail.com> $ +%<+package>\GetIdInfo$Id: wrapstuff.dtx e891159 2022-07-26 19:00:31 +0800 Qing Lee <sobenlee@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 @@ Copyright and Licence %</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 @@ Copyright and Licence % \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 @@ Copyright and Licence % 设置绕排内容的高度,初始值为 \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 @@ Copyright and Licence % \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 @@ Copyright and Licence % \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 @@ Copyright and Licence \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@parboxrestore,\@arrayparboxrestore} +% 在 \LaTeX\ 的 \cs{parbox} 和 \env{minipage} 等环境中恢复正常的段落状态。 +% \tn{wrapstuff@parboxrestore} 的初始值是在分组后清除活动的段落钩子和相关全局变量, +% 只有在 \env{wrapstuff@par} 环境内部才等于 \cs{@@_status_restore:}, +% 保存和恢复相关状态。 +% \begin{macrocode} +\cs_new_protected_nopar:Npn \wrapstuff@parboxrestore + { \group_insert_after:N \@@_status_clear: } +\cs_new_protected_nopar:Npn \@@_parbox_restore: + { + \cs_set_eq:NN + \wrapstuff@parboxrestore + \@@_status_restore: + } +\g@addto@macro \@arrayparboxrestore + { \wrapstuff@parboxrestore } +% \end{macrocode} +% \end{macro} +% % \begin{macro}[TF]{ % \@@_if_last_none:, % \@@_if_last_hlist:, @@ -451,6 +721,21 @@ Copyright and Licence % \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 @@ Copyright and Licence \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 @@ Copyright and Licence } \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@label - { \@@_counter:n { wrapstuff } } + {#1} { \exp_not:N \wrapstuff@counter { page } } } } +\newcounter { wrapstuff } \cs_new:Npn \@@_counter:n #1 { \int_value:w \value {#1} } \cs_new_eq:NN \wrapstuff@counter \@@_counter:n \cs_new_protected_nopar:Npn \wrapstuff@label - { \@newl@bel { wrapstuff@label } } -\tl_const:Nn \c_@@_label_tl - { wrapstuff@label@ \int_value:w \value { wrapstuff } } + { \prop_gput:Nnn \g_@@_page_prop } \@@_gadd_hook:nn { begindocument } { \legacy_if:nTF { @filesw } @@ -602,7 +890,35 @@ Copyright and Licence } { \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 @@ Copyright and Licence \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 @@ Copyright and Licence % \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,69 +1003,13 @@ Copyright and Licence % \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@par} 中。 % 为了控制钩子执行顺序,需要使用 |wrapstuff| 标签, % 而不用更为方便的 \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,12 +1027,14 @@ Copyright and Licence \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: } \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,14 +1079,15 @@ Copyright and Licence \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 } } } \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence } \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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,16 +1402,32 @@ Copyright and Licence \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} % @@ -1207,7 +1477,7 @@ Copyright and Licence % \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 @@ Copyright and Licence \@@_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 @@ Copyright and Licence } \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence % \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 @@ Copyright and Licence \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: - } - \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 } + \@@_split_parameter: + \skip_set_eq:NN \tex_baselineskip:D \g_@@_baseline_skip + \@@_build_line: } } -\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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \@@_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 @@ Copyright and Licence \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 @@ Copyright and Licence \@@_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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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 @@ Copyright and Licence \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,14 +2284,14 @@ Copyright and Licence { \@@_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 } \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 @@ Copyright and Licence \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 @@ Copyright and Licence { \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_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_aux: +\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 @@ Copyright and Licence \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 @@ Copyright and Licence % \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 @@ Copyright and Licence % \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,31 +2474,48 @@ Copyright and Licence \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 { @@ -2202,22 +2530,22 @@ Copyright and Licence { \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 @@ Copyright and Licence % \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 @@ Copyright and Licence } \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 @@ Copyright and Licence { \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,14 +2602,25 @@ Copyright and Licence } \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: { @@ -2309,11 +2629,26 @@ Copyright and Licence \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} % @@ -2333,24 +2668,19 @@ Copyright and Licence { \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,64 +2689,34 @@ Copyright and Licence { \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 } \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 @@ Copyright and Licence % \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 @@ Copyright and Licence \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 @@ Copyright and Licence % \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,7 +2827,14 @@ Copyright and Licence \@@_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 @@ -2544,7 +2846,7 @@ Copyright and Licence \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 @@ Copyright and Licence } { \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 @@ Copyright and Licence % \env{align} 等环境的开头 \tn{ifdt@p} 为真,会插入两个 \tn{vskip}, % 但是 \env{multline} 定义中的 \tn{mmeasure@} 没有重定义 \tn{everycr}, % 上述定义中的 \tn{dt@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 @@ Copyright and Licence } \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} diff --git a/macros/latex/contrib/wrapstuff/wrapstuff.pdf b/macros/latex/contrib/wrapstuff/wrapstuff.pdf Binary files differindex c9cd89da98..d190fafbd8 100644 --- a/macros/latex/contrib/wrapstuff/wrapstuff.pdf +++ b/macros/latex/contrib/wrapstuff/wrapstuff.pdf |