diff options
Diffstat (limited to 'macros')
-rw-r--r-- | macros/latex/contrib/easybook/easybook.dtx | 13 | ||||
-rw-r--r-- | macros/latex/contrib/easybook/easybook.pdf | bin | 639763 -> 640091 bytes | |||
-rw-r--r-- | macros/latex/contrib/easybook/easybook.tex | 34 | ||||
-rw-r--r-- | macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf | bin | 288578 -> 288571 bytes | |||
-rw-r--r-- | macros/latex/contrib/profmaquette/latex/ProfMaquette.sty | 127 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/Makefile | 4 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/NEWS | 5 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/luamplib.dtx | 401 | ||||
-rw-r--r-- | macros/luatex/generic/luamplib/luamplib.pdf | bin | 170008 -> 170094 bytes |
9 files changed, 298 insertions, 286 deletions
diff --git a/macros/latex/contrib/easybook/easybook.dtx b/macros/latex/contrib/easybook/easybook.dtx index 08b7136aac..f4ee675755 100644 --- a/macros/latex/contrib/easybook/easybook.dtx +++ b/macros/latex/contrib/easybook/easybook.dtx @@ -15,7 +15,7 @@ %<*class> \NeedsTeXFormat{LaTeX2e}[2021/11/15] \RequirePackage{l3keys2e} -\ProvidesExplClass{easybook}{2024/04/24}{2024az} +\ProvidesExplClass{easybook}{2024/04/25}{2024ba} {Easily typesetting Chinese theses or books} \bool_new:N \l__eb_compile_draft_bool @@ -297,7 +297,7 @@ %<*package> \NeedsTeXFormat{LaTeX2e}[2021/11/15] \RequirePackage{l3keys2e,etoolbox} -\ProvidesExplPackage{easybase}{2024/04/24}{2024az} +\ProvidesExplPackage{easybase}{2024/04/25}{2024ba} {Easily typesetting Chinese theses or books} \cs_generate_variant:Nn \dim_set:Nn { NV } @@ -1823,7 +1823,7 @@ } \cs_new_protected:Npn \ebaddtofont #1#2 { - \str_case:nnF {#1} + \str_case:nn {#1} { { table } { \tl_put_right:Nn \l__eb_font_caption_table_tl {#2} } @@ -1837,8 +1837,11 @@ \tl_put_right:Nn \l__eb_font_caption_figure_tl {#2} \tl_put_right:Nn \l__eb_font_caption_listing_tl {#2} } + { footnote } + { \tl_put_right:Nn \eb@font@footnote {#2} } + { marginpar } + { \tl_put_right:Nn \marginfont {#2} } } - { \tl_put_right:cn { l__eb_font_#1_tl } {#2} } } \ctex_define:nn { spread } { @@ -2479,7 +2482,7 @@ } %</package> %<*tcolorbox> -\ProvidesExplFile{eb-tcolorbox.cfg}{2024/04/24}{2024az} +\ProvidesExplFile{eb-tcolorbox.cfg}{2024/04/25}{2024ba} {Customization of tcolorbox for easybook} \cs_set_protected:Npn \addtotcbstyle #1#2 diff --git a/macros/latex/contrib/easybook/easybook.pdf b/macros/latex/contrib/easybook/easybook.pdf Binary files differindex eb2bc6422e..1dbab645f4 100644 --- a/macros/latex/contrib/easybook/easybook.pdf +++ b/macros/latex/contrib/easybook/easybook.pdf diff --git a/macros/latex/contrib/easybook/easybook.tex b/macros/latex/contrib/easybook/easybook.tex index a00aeb12d0..760a8de58b 100644 --- a/macros/latex/contrib/easybook/easybook.tex +++ b/macros/latex/contrib/easybook/easybook.tex @@ -23,8 +23,8 @@ name = easybook, color-scheme = blue, title = EASYBOOK使用手册, - version = v2024az, - date = 2024/04/24, + version = v2024ba, + date = 2024/04/25, authors = 瞿毅, info = 简便地排版中文学位论文或书籍, email = toquyi@163.com, @@ -53,7 +53,7 @@ \setlist[1]{labelindent = \parindent} \setlist[itemize,1]{label = smallbullet,leftmargin = *} \setcounter{tocdepth}{2} -\SetTblrInner[longtblr]{hline{1,Z} = {1pt,DarkBlue}} +\SetTblrInner[longtblr]{columns = c,hline{1,Z} = {1pt,DarkBlue}} \SetTblrOuter[longtblr]{presep = \bigskipamount,postsep = \bigskipamount} \DefTblrTemplate{caption-tag}{default}{表\thetable} \DefTblrTemplate{caption-sep}{default}{\quad} @@ -242,7 +242,6 @@ \begin{longtblr} [caption = 依赖的宏包清单,label = table:package list] { - colspec = *{5}{c}, cells = {cmd = \pkg*}, cell{1}{3,4} = PaleTurquoise, cell{2}{5} = PaleTurquoise, @@ -294,18 +293,15 @@ \setCJKmonofont{FangSong} \newCJKfontfamily[song]\songti{SimSun} \end{ctexexam} -\end{options} - -\begin{options} \keychoice{font}{noto,times,times*,ebgaramond,libertine,palatino,\fbox{auto}}\dtag 预置的英文字体相关配置方案如\ref{table:english font} 所示。这些字体已经包含在了 \hologo{TeXLive} 发行版中,所以通常不需要再专门安装。如果您想使用其它英文字体,可以使用 \pkg*{fontspec} 宏包的相关命令进行设置。 \begin{longtblr} [ caption = 英文字体预设方案, label = table:english font, - remark{\ding{72}} = \code{times*} 方案为 \textsf{windows} 系统的预置字体。 + remark{\ding{72}} = \code{times*} 方案为 \textsf{windows} 系统的预置字体。, + postsep = \bigskipamount-\itemsep ]{ - colspec = @{}*{4}{c}@{}, hline{2} = {0.5pt,DarkBlue}, row{1} = {font = \sffamily}, column{1} = {cmd = \code} @@ -318,9 +314,6 @@ palatino & TG Pagella & Libertinus Sans & LM Mono \\ libertine & Libertinus Serif & Libertinus Sans & LM Mono \end{longtblr} -\end{options} - -\begin{options} \keychoice{mathfont}{\fbox{times},noto,notosans,nc,ncf,stix2,charter,ebgaramond,libertine}\dtag \leftfillchoice{mathfont}{minion,garamondx,baskervaldx,baskerville,none} \\ 选择合适的数学字体,将会加载 \pkg*{newtxmath} 和 \pkg*{bm} 宏包。使用选项 \code{none} 时可以使用 \pkg*{unicode-math} 等其它数学字体宏包定义字体。 @@ -344,12 +337,11 @@ \begin{longtblr} [caption = 模块功能和名称清单,label = table:module List] { - colspec = @{}*{5}{c}@{}, hline{3} = {0.5pt,DarkBlue}, - row{1,3} = {font = \sffamily,belowsep = 0pt}, + row{1,3} = {font = \sffamily}, row{2,4} = {cmd = \module*} } - \hyperref[subsec:tools]{工具} & \hyperref[subsec:font]{字体} & \hyperref[subsec:spread]{行距} & \hyperref[subsec:hyperlinks]{超链接} & \hyperref[subsec:reference]{参考文献} \\ + \hyperref[subsec:tools]{工具} & \hyperref[subsec:font]{部件字体} & \hyperref[subsec:spread]{行距} & \hyperref[subsec:hyperlinks]{超链接} & \hyperref[subsec:reference]{参考文献} \\ tools & font & spread & ref & bib \\ \hyperref[subsec:theorem]{定理} & \hyperref[subsec:page margins]{页面尺寸} & \hyperref[subsec:header and footer]{页眉页脚} & \hyperref[subsec:catalog]{目录} & \\ thmt & geo & hdr & toc & @@ -499,7 +491,7 @@ 行间公式与下面正文间的额外距离。 \end{options} -\subsection[其它字体]{其它字体\smodule{font}} +\subsection[部件字体]{部件字体\smodule{font}} \label{subsec:font} \begin{options} \keyval{caption-table}{字体命令}\Default{\cs*{sffamily}\cs*{small}} @@ -639,7 +631,7 @@ \begin{commands}\noitemsep \command{listoftheorems}[\sarg\oarg{键值列表}]\default{} \item\key{listoftheorems}{定理目录标题名} - \command{settheoremtocline}[\sarg\marg{环境名}\marg{标题定义}]\newtagv{2024az}% + \command{settheoremtocline}[\sarg\marg{环境名}\marg{标题定义}]\newtagv{2024ba}% 对 \pkg*{thmtools} 宏包的定理环境目录命令 \cs{listoftheorems} 进行了兼容调整,\ref{subsec:directory command} 和\ref{subsec:catalog} 中的选项机制均可用,但标题定义选项 \option{tocline} 较为特殊,需用 \cs{settheoremtocline} 命令单独设置。在 \meta{标题定义} 中有三个命令 \cs{thmtname}、\cs{thmtenvname} 和 \cs{thmtnote} 分别代表定理名、定理环境名和题注用于排版目录条目。 \end{commands} @@ -872,10 +864,10 @@ \keyval{tocindent}{刚性长度}\dtag 目录条目左边的缩进距离,通常标题级别越低缩进越大。如果是段落型目录,仅在当前条目级别为段落中最高时有效。 \keyval{tocrule}{引导线命令}\dtag - 引导线选项 \option{tocrule} 中一般可以使用基于 \cs*{xleaders} 命令的 \cs{tocrule} 绘制引导线。 + 目录条目的引导线和页码。引导线可以使用基于 \cs*{xleaders} 命令的 \cs{tocrule} 绘制(同时输出页码),如果是一般不需要引导线的段落型目录,可以使用 \cs{thecontentspage} 命令输出页码。 \begin{commands} \command{tocrule}[\sarg\harg\oarg{引导点间距}\darg{放大因子}\marg{引导点}\oarg{页码格式}] - 生成目录引导线的命令,需要在引导线选项 \option{tocrule} 中使用。带有星号的命令与 \keyis{dotalign}{false} 效果相同。命令带 \harg{} 号参数不添加目录页码,此时无格式的页码被保存在 \cs{thecontentspage} 命令中,可以配合盒子命令设置不同的页码左右间距和对齐方式。\meta{引导点间距} 需带有长度单位,\meta{放大因子} 为 \meta{引导点} 的放大倍数。\meta{页码格式} 中最后一个命令可以带有一个参数为页码编号。 + 生成目录引导线的命令,需要在引导线选项 \option{tocrule} 中使用。带有星号的命令与 \keyis{dotalign}{false} 效果相同。命令带 \harg{} 号参数不输出目录页码,此时无格式的页码被保存在 \cs{thecontentspage} 命令中,可以配合盒子命令设置不同的页码左右间距和对齐方式。\meta{放大因子} 为 \meta{引导点} 的放大倍数。\meta{页码格式} 中最后一个命令可以带有一个参数用于接受页码。 \end{commands} \keyval{toclabel}{标题标签定义}\dtag\newtagv{2024as}% 目录中各类型条目标题标签的定义,可与 \option{tocline} 选项联用设置标题。其中参数 \code{\#1} 代表标签的编号 \cs{thecontentslabel},参数 \code{\#2} 代表 \meta{条目名}。定义最后的命令可带有一个参数,用于接受标题内容,一些特殊情况例如需要将标题内容放在标签后,可以通过定义命令实现: @@ -907,7 +899,7 @@ \begin{commands} \command{RegisterTocName}[\sarg\marg{条目名}]\newtagv[Changed]{2024as}% - 给条目类型名称为 \meta{条目名} 的标题注册用于设置目录样式的选项,即选项前有符号 \ding{73} 表示需要注册后使用。前面提到的条目类型均已注册,新类型的条目注册后选项初始值与图表条目相同。带有星号参数的命令使注册目录的条目形成一个段落,此时多出下面三个选项可用: + 给条目类型名称为 \meta{条目名} 的标题注册用于设置目录样式的选项,即选项前有符号 \ding{73} 表示需要注册后使用。前面提到的条目类型均已注册,新类型的条目注册后默认格式与图表条目相同。这个命令可以重复使用,会重置目录条目为默认格式。带有星号参数的命令使注册目录的条目形成一个段落,此时多出下面三个选项可用: \begin{options} \keyval{tocbegin}{开始代码}\dtag\newtagv{2024as}% 当前级别目录条目第一个标题前的代码,仅在存在更高级别的条目时有效。 @@ -1509,7 +1501,7 @@ \item 新增段落型目录条目附加代码的选项 \option{tocbegin}、\option{tocsep} 和 \option{tocend}。 \end{version} \shortversion{v = 2024aw,date = 2022/04/22,changes = 新增新建章节标题命令 \cs{NewTitleCommand} 和 \cs{NewTitleEntryCommand}。} - \shortversion{v = 2024az,date = 2022/04/24,changes = 增加对 \pkg*{thmtools} 宏包定理环境目录 \cs{listoftheorems} 的支持。} + \shortversion{v = 2024ba,date = 2022/04/25,changes = 增加对 \pkg*{thmtools} 宏包定理环境目录 \cs{listoftheorems} 的支持。} \end{changelog} \nocite{*} diff --git a/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf b/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf Binary files differindex dbd1708aaf..552ebfe62c 100644 --- a/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf +++ b/macros/latex/contrib/profmaquette/doc/ProfMaquette-doc.pdf diff --git a/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty b/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty index 62f7313ca3..9d2e501a04 100644 --- a/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty +++ b/macros/latex/contrib/profmaquette/latex/ProfMaquette.sty @@ -2,9 +2,9 @@ % licence : Released under the LaTeX Project Public License v1.3c % or later, see http://www.latex-project.org/lppl.txtf \NeedsTeXFormat{LaTeX2e}% -\def\filedate{2024/04/13}% +\def\filedate{2024/04/25}% \let\PfMfiledate\filedate% -\def\fileversion{0.91}% +\def\fileversion{0.92}% \let\PfMfileversion\fileversion% \ProvidesPackage{ProfMaquette}[\filedate\space v\fileversion\space Maquettage de documents]% @@ -40,7 +40,7 @@ \makeatother %définition des clés \RequirePackage{simplekv}% -\setKVdefault[Boulot]{Dys=false,Taille=14,Cours=false,Base=false,BaseHTML=false,CAN=false,Fiche=false,DM=false,DS=false,IE=false,Kholle=false,RecapBrevet=false,PdT=false,Parcours=false,Contrat=false,FdR=false,ParcoursPerso=false,OlympiadesAPMEP=false,CorrigeSeul=false,CorrigeApres=false,CorrigeFin=false,CorrigeAll=false,Brevet=false,BaremeComplet=false,BaremeGlobal=false,CorrectionColonnes=false,Epaisseur=0pt,VersSolution=false,Small=false,Footnotesize=false,Scriptsize=false,AllDirect=false,AllPouce=false}%Les deux derniers pour essayer de mettre tous les exercices d'un même fichier en mode Reponse, en mode Indice. Pas implanté, pas testé +\setKVdefault[Boulot]{Dys=false,Taille=14,Cours=false,Base=false,BaseHTML=false,CAN=false,Fiche=false,DM=false,DS=false,IE=false,Kholle=false,RecapBrevet=false,PdT=false,Parcours=false,Contrat=false,FdR=false,ParcoursPerso=false,OlympiadesAPMEP=false,CorrigeInverse=false,CorrigeSeul=false,CorrigeApres=false,CorrigeFin=false,CorrigeAll=false,Brevet=false,BaremeComplet=false,BaremeGlobal=false,CorrectionColonnes=false,Epaisseur=0pt,VersSolution=false,Small=false,Footnotesize=false,Scriptsize=false,AllDirect=false,AllPouce=false}%Les deux derniers pour essayer de mettre tous les exercices d'un même fichier en mode Reponse, en mode Indice. Pas implanté, pas testé \defKV[Boulot]{Colonnes=\setKV[Boulot]{CorrectionColonnes}}% \setKVdefault[Cours]{Couleur=Crimson,Theme=Trace écrite,NomExercice=Exercice}% \setKVdefault[DM]{Numero=1,Date=\today,Classe={},Niveau=3,Code=\jobname}% @@ -85,12 +85,28 @@ \IfNoValueTF{#1}{\PfMDotfill}{\makebox[#1]{\PfMDotfill}}% }% % -\NewDocumentCommand\PfMLignespointilles{m}{% - \xintifboolexpr{\fpeval{#1}>1}{% - \xintFor* ##1 in {\xintSeq {1}{\fpeval{#1}}}\do{% - \PfMpointilles\par% - }% - }{}% +\NewDocumentCommand\PfMNbLignesRestantes{}{% + \edef\measurepage{\dimexpr\pagegoal-\pagetotal\relax}% + \xdef\PfMResteLignes{\fpeval{trunc((\the\measurepage)/(\baselineskip),0)}}% +}% + +\NewDocumentCommand\PfMLignesFinales{}{% + \PfMNbLignesRestantes% + \xintFor* ##1 in {\xintSeq {1}{\PfMResteLignes}}\do{% + \PfMpointilles\par% + }% +}% + +\NewDocumentCommand\PfMLignespointilles{sm}{% + \IfBooleanTF{#1}{% + \par\PfMLignesFinales% + }{% + \xintifboolexpr{\fpeval{#2}>1}{% + \xintFor* ##1 in {\xintSeq {1}{#2}}\do{% + \PfMpointilles\par% + }% + }{}% + }% }% % Definition de longueurs \newlength\PfMLargeurSchemaParcours% @@ -143,6 +159,8 @@ \newcounter{Nbcolonnes} +\newbox\PfMSauvegardeBox% + \newif\ifPfMDeuxColonnes \newif\ifPfMRectoVerso \makeatletter @@ -2278,6 +2296,8 @@ \fi% }% +\newbox\PfMBoxSauvegarde% + \NewDocumentEnvironment{exerciceFiche}{so+b}{% \setcounter{PfMAlea}{0}% \setcounter{PfMNbLogo}{1}% @@ -2298,6 +2318,8 @@ \refstepcounter{PfMSection}% \PfMChoixCorrection% \refstepcounter{PfMExo}% + % \setbox\PfMBoxSauvegarde{#3\unskip\unpenalty\unpenalty} +% \setbox\PfMBoxSauvegarde=\vbox{#3} \ifboolKV[Boulot]{CorrigeSeul}{}{% \PfMChoixTitreSolution% \PfMChoixHideItemSolution% @@ -3373,47 +3395,54 @@ }{% \ifboolKV[Boulot]{CAN}{% \setKV[CAN]{#2}% - \ifboolKV[Boulot]{CorrigeSeul}{}{\TikzCAN}% + %\ifboolKV[Boulot]{CorrigeSeul}{}{\TikzCAN}% \PfMChangerTailleCorrection% - \setcounter{PfMCNNumQ}{0}% - \setlength{\PfMLargeurQuestion}{\useKV[CAN]{CoefQ}\linewidth}\setlength{\PfMLargeurReponse}{\useKV[CAN]{CoefR}\linewidth}\setlength{\PfMLargeurJury}{\useKV[CAN]{CoefJ}\linewidth}% - \let\exercice\ExoCANWrite\let\endexercice\endExoCANWrite% - \AddToHook{env/exercice/begin}{\setcounter{PfMAlea}{0}}% - \AddToHook{env/Maquette/end}{% - \xdef\PfMCANTotalExo{\thePfMExo}% - \ifboolKV[Boulot]{CorrigeSeul}{}{ - \setcounter{PfMExo}{0}% - \renewcommand{\arraystretch}{2}% - \begin{longtable}{|c|m{\PfMLargeurQuestion}|>{\centering\arraybackslash}m{\PfMLargeurReponse}|m{\PfMLargeurJury}|}% - \hhline{~---}% - \multicolumn{1}{c|}{}&\cellcolor{gray!15}\centering Question&\cellcolor{gray!15}\centering Réponse&\cellcolor{gray!15}\centering\arraybackslash Jury\\% - \hline% - \endhead% - \xintFor* ##1 in {\xintSeq{1}{\PfMCANTotalExo}}\do{% - \refstepcounter{PfMCNNumQ}\ttfamily{\thePfMCNNumQ}\label{TestCAN-\thePfMCNNumQ}&\Complement{}\stepcounter{PfMExo}\setcounter{PfMAlea}{0}\input{\jobname-Ex##1.can}&\CNReponse&\\ - \hline% - }% - \end{longtable}% - \renewcommand{\arraystretch}{1}% - }% - }% - \ifboolKV[Boulot]{CorrigeFin}{% - \AddToHook{env/Maquette/after}[Correction]{% - \PfMPrepareCorrection{#1}% -% \useKVdefault[Boulot]% -% \setKV[Boulot]{#1}% -% \if@Dyslexie -% \setKV[Boulot]{Dys} -% \fi -% \PfMBasculeDys% -% \setlength{\columnseprule}{\useKV[Boulot]{Epaisseur}}% - \TikzCANCor{#2}% -% \ifboolKV[Boulot]{CorrectionColonnes}{\begin{multicols}{\useKV[Boulot]{Colonnes}}}{}% -% \PfMAffichageCorrige% -% \ifboolKV[Boulot]{CorrectionColonnes}{\end{multicols}}{}% - \PfMAffichageCorrectionColonnes% - }% - }{}% + \setcounter{PfMCNNumQ}{0}% + \setlength{\PfMLargeurQuestion}{\useKV[CAN]{CoefQ}\linewidth}\setlength{\PfMLargeurReponse}{\useKV[CAN]{CoefR}\linewidth}\setlength{\PfMLargeurJury}{\useKV[CAN]{CoefJ}\linewidth}% + \let\exercice\ExoCANWrite\let\endexercice\endExoCANWrite% + \AddToHook{env/exercice/begin}{\setcounter{PfMAlea}{0}}% + \AddToHook{env/Maquette/end}{% + \xdef\PfMCANTotalExo{\thePfMExo}% + \setbox\PfMSauvegardeBox\vbox{% + \setcounter{PfMExo}{0}% + \renewcommand{\arraystretch}{2}% + \begin{longtable}{|c|m{\PfMLargeurQuestion}|>{\centering\arraybackslash}m{\PfMLargeurReponse}|m{\PfMLargeurJury}|}% + \hhline{~---}% + \multicolumn{1}{c|}{}&\cellcolor{gray!15}\centering Question&\cellcolor{gray!15}\centering Réponse&\cellcolor{gray!15}\centering\arraybackslash Jury\\% + \hline% + \endhead% + \xintFor* ##1 in {\xintSeq{1}{\PfMCANTotalExo}}\do{% + \refstepcounter{PfMCNNumQ}\ttfamily{\thePfMCNNumQ}\label{TestCAN-\thePfMCNNumQ}&\Complement{}\stepcounter{PfMExo}\setcounter{PfMAlea}{0}\input{\jobname-Ex##1.can}&\CNReponse&\\ + \hline% + }% + \end{longtable}% + \renewcommand{\arraystretch}{1}% + } + \ifboolKV[Boulot]{CorrigeInverse}{% + \PfMPrepareCorrection{#1}% + \TikzCANCor{#2}% + \PfMAffichageCorrectionColonnes% + \clearpage + \TikzCAN% + \usebox{\PfMSauvegardeBox}% + }{% + \TikzCAN% + \usebox{\PfMSauvegardeBox}% + \ifboolKV[Boulot]{CorrigeFin}{\ifboolKV[Boulot]{CorrigeInverse}{}{\clearpage + \PfMPrepareCorrection{#1}% + \TikzCANCor{#2}% + \PfMAffichageCorrectionColonnes% + } + }{} + } + }% +% \ifboolKV[Boulot]{CorrigeFin}{% +% \AddToHook{env/Maquette/after}[Correction]{% +% \PfMPrepareCorrection{#1}% +% \TikzCANCor{#2}% +% \PfMAffichageCorrectionColonnes% +% }% +% }{}% }{% \ifboolKV[Boulot]{FdR}{% \ifboolKV[Boulot]{CorrigeSeul}{}{% diff --git a/macros/luatex/generic/luamplib/Makefile b/macros/luatex/generic/luamplib/Makefile index a842e2c30b..f4d638764e 100644 --- a/macros/luatex/generic/luamplib/Makefile +++ b/macros/luatex/generic/luamplib/Makefile @@ -42,8 +42,8 @@ $(UNPACKED): $(DTX) luatex -interaction=batchmode $< >/dev/null check: $(UNPACKED) - luatex -interaction=batchmode test-$(NAME)-plain.tex >/dev/null - lualatex -interaction=batchmode test-$(NAME)-latex.tex >/dev/null + @texfot --quiet --tee=/dev/null luatex -interaction=batchmode test-$(NAME)-plain.tex + @texfot --quiet --tee=/dev/null lualatex -interaction=batchmode test-$(NAME)-latex.tex ! grep "blank space" test-$(NAME)-plain.log ! grep "blank space" test-$(NAME)-latex.log diff --git a/macros/luatex/generic/luamplib/NEWS b/macros/luatex/generic/luamplib/NEWS index 52aacc7f62..f0dd1cf2f4 100644 --- a/macros/luatex/generic/luamplib/NEWS +++ b/macros/luatex/generic/luamplib/NEWS @@ -1,5 +1,10 @@ History of the luamplib package +2024/04/25 2.28.2 + * direction of figure box is explicitly declared as TLT (#129) + * figure box materials are emitted in one go at the end of the figure + (to enable tex.runtoks in spot color shading routine) + 2024/04/19 2.28.1 * fix spot color shading routine diff --git a/macros/luatex/generic/luamplib/luamplib.dtx b/macros/luatex/generic/luamplib/luamplib.dtx index 28c6bc037e..283120c622 100644 --- a/macros/luatex/generic/luamplib/luamplib.dtx +++ b/macros/luatex/generic/luamplib/luamplib.dtx @@ -85,7 +85,7 @@ See source file '\inFileName' for licencing and contact information. %<*driver> \NeedsTeXFormat{LaTeX2e} \ProvidesFile{luamplib.drv}% - [2024/04/19 v2.28.1 Interface for using the mplib library]% + [2024/04/25 v2.28.2 Interface for using the mplib library]% \documentclass{ltxdoc} \usepackage{metalogo,multicol,mdwlist,fancyvrb,xspace} \usepackage[x11names]{xcolor} @@ -153,7 +153,7 @@ See source file '\inFileName' for licencing and contact information. % \author{Hans Hagen, Taco Hoekwater, Elie Roux, Philipp Gesang and Kim Dohyun\\ % Maintainer: LuaLaTeX Maintainers --- % Support: \email{lualatex-dev@tug.org}} -% \date{2024/04/19 v2.28.1} +% \date{2024/04/25 v2.28.2} % % \maketitle % @@ -476,8 +476,8 @@ See source file '\inFileName' for licencing and contact information. luatexbase.provides_module { name = "luamplib", - version = "2.28.1", - date = "2024/04/19", + version = "2.28.2", + date = "2024/04/25", description = "Lua package to typeset Metapost with LuaTeX's MPLib.", } @@ -520,9 +520,15 @@ local function termorlog (target, text, kind) end end -local warn = function(...) termorlog("term and log", format(...)) end -local info = function(...) termorlog("log", format(...)) end -local err = function(...) termorlog("error", format(...)) end +local function warn (...) -- beware '%' symbol + termorlog("term and log", select("#",...) > 1 and format(...) or ...) +end +local function info (...) + termorlog("log", select("#",...) > 1 and format(...) or ...) +end +local function err (...) + termorlog("error", select("#",...) > 1 and format(...) or ...) +end luamplib.showlog = luamplib.showlog or false @@ -531,10 +537,8 @@ luamplib.showlog = luamplib.showlog or false % This module is a stripped down version of libraries that are used by % \ConTeXt. Provide a few ``shortcuts'' expected by the imported code. % \begin{macrocode} -local tableconcat = table.concat -local texsprint = tex.sprint -local textprint = tex.tprint - +local tableconcat = table.concat +local texsprint = tex.sprint local texgettoks = tex.gettoks local texgetbox = tex.getbox local texruntoks = tex.runtoks @@ -889,7 +893,7 @@ local function luamplibload (name) % Append our own MetaPost preamble to the preamble above. % \begin{macrocode} local preamble = tableconcat{ - preamble, + format(preamble, replacesuffix(name,"mp")), luamplib.mplibcodepreamble, luamplib.legacy_verbatimtex and luamplib.legacyverbatimtexpreamble or "", luamplib.textextlabel and luamplib.textextlabelpreamble or "", @@ -898,7 +902,7 @@ local function luamplibload (name) if not mpx then result = { status = 99, error = "out of memory"} else - result = mpx:execute(format(preamble, replacesuffix(name,"mp"))) + result = mpx:execute(preamble) end log = reporterror(result) return mpx, result, log @@ -924,8 +928,12 @@ local function process (data) if instancename and instancename ~= "" then currfmt = instancename else - currfmt = currentformat..(luamplib.numbersystem or "scaled") - ..tostring(luamplib.textextlabel)..tostring(luamplib.legacy_verbatimtex) + currfmt = tableconcat{ + currentformat, + luamplib.numbersystem or "scaled", + tostring(luamplib.textextlabel), + tostring(luamplib.legacy_verbatimtex), + } end local mpx = mplibinstances[currfmt] local standalone = false @@ -961,7 +969,7 @@ end % % |dvipdfmx| is supported, though nobody seems to use it. % \begin{macrocode} -local pdfmode = tex.get"outputmode" > 0 +local pdfmode = tex.outputmode > 0 % \end{macrocode} % % |make_text| and some |run_script| uses \LuaTeX's |tex.runtoks|, @@ -984,8 +992,7 @@ local catat11 = luatexbase.registernumber("catcodetable@atletter") % \end{verbatim} % \begin{macrocode} local function run_tex_code (str, cat) - cat = cat or catlatex - texruntoks(function() texsprint(cat, str) end) + texruntoks(function() texsprint(cat or catlatex, str) end) end % \end{macrocode} @@ -1015,10 +1022,8 @@ withprescript "mplibtexboxid=%i:%f:%f")' local function process_tex_text (str) if str then local boxtable, global - if instancename and instancename ~= "" then - texboxes[instancename] = texboxes[instancename] or {} - boxtable, global = texboxes[instancename], "\\global" - elseif luamplib.globaltextext or luamplib.codeinherit then + if instancename and instancename ~= "" + or luamplib.globaltextext or luamplib.codeinherit then boxtable, global = texboxes.globals, "\\global" else boxtable, global = texboxes.locals, "" @@ -1036,7 +1041,9 @@ local function process_tex_text (str) [[\expandafter\newbox\csname luamplib.box.%s\endcsname]], boxid)) tex_box_id = tex.getcount'allocationnumber' end - boxtable[str] = tex_box_id + if str:find"^[%s%w%{%}%$%^%_]*$" then -- the same cs may expand differently + boxtable[str] = tex_box_id + end run_tex_code(format("%s\\setbox%i\\hbox{%s}", global, tex_box_id, str)) box = texgetbox(tex_box_id) end @@ -1122,7 +1129,7 @@ local function colorsplit (res) local be = tt[1]:find"^%d" and 1 or 2 for i=be, #tt do if tt[i]:find"^%a" then break end - table.insert(t, tt[i]) + t[#t+1] = tt[i] end return t end @@ -1145,7 +1152,6 @@ luamplib.shadecolor = function (str) % \end{macrocode} % An example of spot color shading: % \begin{verbatim} -% \DocumentMetadata{ } % \documentclass{article} % \usepackage{luamplib} % \mplibsetformat{metafun} @@ -1233,7 +1239,7 @@ end % \end{macrocode} % % Newly introduced method of processing |verbatimtex ... etex|. -% Used when |\mpliblegacybehavior{false}| is declared. +% This function is used when |\mpliblegacybehavior{false}| is declared. % \begin{macrocode} local function process_verbatimtex_text (str) if str then @@ -1568,51 +1574,46 @@ local function process_mplibcode (data, instance) local everyendmplib = luamplib.everyendmplib[instancename] or luamplib.everyendmplib[""] data = format("\n%s\n%s\n%s\n",everymplib, data, everyendmplib) - data = data:gsub("\r","\n") + :gsub("\r","\n") % \end{macrocode} -% This three lines are needed for |mplibverbatim| mode. +% These five lines are needed for |mplibverbatim| mode. % \begin{macrocode} if luamplib.verbatiminput then data = data:gsub("\\mpcolor%s+(.-%b{})","mplibcolor(\"%1\")") - data = data:gsub("\\mpdim%s+(%b{})", "mplibdimen(\"%1\")") - data = data:gsub("\\mpdim%s+(\\%a+)","mplibdimen(\"%1\")") - end - - data = data:gsub(btex_etex, function(str) - return format("btex %s etex ", -- space - luamplib.verbatiminput and str or protect_expansion(str)) - end) - data = data:gsub(verbatimtex_etex, function(str) - return format("verbatimtex %s etex;", -- semicolon - luamplib.verbatiminput and str or protect_expansion(str)) - end) - + :gsub("\\mpdim%s+(%b{})", "mplibdimen(\"%1\")") + :gsub("\\mpdim%s+(\\%a+)","mplibdimen(\"%1\")") + :gsub(btex_etex, "btex %1 etex ") + :gsub(verbatimtex_etex, "verbatimtex %1 etex;") % \end{macrocode} % % If not |mplibverbatim|, expand |mplibcode| data, % so that users can use \TeX\ codes in it. % It has turned out that no comment sign is allowed. % \begin{macrocode} - if not luamplib.verbatiminput then - data = data:gsub("\".-\"", protect_expansion) - - data = data:gsub("\\%%", "\0PerCent\0") - data = data:gsub("%%.-\n","") - data = data:gsub("%zPerCent%z", "\\%%") - + else + data = data:gsub(btex_etex, function(str) + return format("btex %s etex ", protect_expansion(str)) -- space + end) + :gsub(verbatimtex_etex, function(str) + return format("verbatimtex %s etex;", protect_expansion(str)) -- semicolon + end) + :gsub("\".-\"", protect_expansion) + :gsub("\\%%", "\0PerCent\0") + :gsub("%%.-\n","\n") + :gsub("%zPerCent%z", "\\%%") run_tex_code(format("\\mplibtmptoks\\expandafter{\\expanded{%s}}",data)) data = texgettoks"mplibtmptoks" % \end{macrocode} % % Next line to address issue \#55 % \begin{macrocode} - data = data:gsub("##", "#") - data = data:gsub("\".-\"", unprotect_expansion) - data = data:gsub(btex_etex, function(str) + :gsub("##", "#") + :gsub("\".-\"", unprotect_expansion) + :gsub(btex_etex, function(str) return format("btex %s etex", unprotect_expansion(str)) end) - data = data:gsub(verbatimtex_etex, function(str) + :gsub(verbatimtex_etex, function(str) return format("verbatimtex %s etex", unprotect_expansion(str)) end) end @@ -1660,28 +1661,33 @@ local function convert(result, flusher) end luamplib.convert = convert +local figcontents = { post = { } } +local function put2output(a,...) + figcontents[#figcontents+1] = type(a) == "string" and format(a,...) or a +end + local function pdf_startfigure(n,llx,lly,urx,ury) - texsprint(format("\\mplibstarttoPDF{%f}{%f}{%f}{%f}",llx,lly,urx,ury)) + put2output("\\mplibstarttoPDF{%f}{%f}{%f}{%f}",llx,lly,urx,ury) end local function pdf_stopfigure() - texsprint("\\mplibstoptoPDF") + put2output("\\mplibstoptoPDF") end % \end{macrocode} % -% |tex.tprint| with catcode regime -2, as sometimes |#| gets doubled +% |tex.sprint| with catcode regime -2, as sometimes |#| gets doubled % in the argument of pdfliteral. % \begin{macrocode} -local function pdf_literalcode(fmt,...) -- table - textprint({"\\mplibtoPDF{"},{-2,format(fmt,...)},{"}"}) +local function pdf_literalcode (fmt,...) + put2output{-2, format(fmt,...)} end local function pdf_textfigure(font,size,text,width,height,depth) text = text:gsub(".",function(c) - return format("\\hbox{\\char%i}",string.byte(c)) -- kerning happens in metapost + return format("\\hbox{\\char%i}",string.byte(c)) -- kerning happens in metapost : false end) - texsprint(format("\\mplibtextext{%s}{%f}{%s}{%s}{%f}",font,size,text,0,0)) + put2output("\\mplibtextext{%s}{%f}{%s}{%s}{%s}",font,size,text,0,0) end local bend_tolerance = 131/65536 @@ -1771,14 +1777,14 @@ local function start_pdf_code() if pdfmode then pdf_literalcode("q") else - texsprint("\\special{pdf:bcontent}") -- dvipdfmx + put2output"\\special{pdf:bcontent}" end end local function stop_pdf_code() if pdfmode then pdf_literalcode("Q") else - texsprint("\\special{pdf:econtent}") -- dvipdfmx + put2output"\\special{pdf:econtent}" end end @@ -1807,7 +1813,7 @@ local function put_tex_boxes (object,prescript) end start_pdf_code() pdf_literalcode("%f %f %f %f %f %f cm",sx,rx,ry,sy,tx,ty) - texsprint(format("\\mplibputtextbox{%i}",n)) + put2output("\\mplibputtextbox{%i}",n) stop_pdf_code() end end @@ -1817,32 +1823,36 @@ end % Colors and Transparency % \begin{macrocode} local pdfmanagement = is_defined'pdfmanagement_add:nnn' -local pdf_objs = {} -pdf_objs.pgfextgs = "pgf@sys@addpdfresource@extgs@plain" +local pdfobjs, pdfetcs = {}, {} +pdfetcs.pgfextgs = "pgf@sys@addpdfresource@extgs@plain" if pdfmode then - pdf_objs.getpageres = pdf.getpageresources or function() return pdf.pageresources end - pdf_objs.setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end + pdfetcs.getpageres = pdf.getpageresources or function() return pdf.pageresources end + pdfetcs.setpageres = pdf.setpageresources or function(s) pdf.pageresources = s end else texsprint("\\special{pdf:obj @MPlibTr<<>>}","\\special{pdf:obj @MPlibSh<<>>}") end local function update_pdfobjs (os) - local on = pdf_objs[os] + local on = pdfobjs[os] if on then return on,false end if pdfmode then on = pdf.immediateobj(os) else - on = pdf_objs.cnt or 0 + on = pdfetcs.cnt or 1 texsprint(format("\\special{pdf:obj @mplibpdfobj%s %s}",on,os)) - pdf_objs.cnt = on + 1 + pdfetcs.cnt = on + 1 end - pdf_objs[os] = on + pdfobjs[os] = on return on,true end +% \end{macrocode} +% +% transparency +% \begin{macrocode} local transparancy_modes = { [0] = "Normal", "Normal", "Multiply", "Screen", "Overlay", "SoftLight", "HardLight", "ColorDodge", "ColorBurn", @@ -1851,7 +1861,24 @@ local transparancy_modes = { [0] = "Normal", "Compatible", } -local function update_tr_res(res,mode,opaq) +local function opacity_initialize () + pdfetcs.opacity_res = {} + if pdfmode and luatexbase.callbacktypes.finish_pdffile then -- ltluatex + local extgstate_obj = pdf.reserveobj() + pdfetcs.setpageres(format("%s/ExtGState %i 0 R",pdfetcs.getpageres() or "",extgstate_obj)) + luatexbase.add_to_callback("finish_pdffile", function() + pdf.immediateobj(extgstate_obj, format("<<%s>>",tableconcat(pdfetcs.opacity_res))) + end, "luamplib.opacity.finish_pdffile") + end +end + +local function update_tr_res(mode,opaq) + if pdfetcs.pgfloaded == nil then + pdfetcs.pgfloaded = is_defined(pdfetcs.pgfextgs) + if not pdfmanagement and not pdfetcs.pgfloaded and not is_defined"TRP@list" then + opacity_initialize() + end + end local os = format("<</BM /%s/ca %.3f/CA %.3f/AIS false>>",mode,opaq,opaq) local on, new = update_pdfobjs(os) if new then @@ -1863,8 +1890,8 @@ local function update_tr_res(res,mode,opaq) }) else local tr = format("/MPlibTr%s %s 0 R",on,on) - if pdf_objs.pgfloaded then - texsprint(format("\\csname %s\\endcsname{%s}", pdf_objs.pgfextgs,tr)) + if pdfetcs.pgfloaded then + texsprint(format("\\csname %s\\endcsname{%s}", pdfetcs.pgfextgs,tr)) elseif is_defined"TRP@list" then texsprint(catat11,{ [[\if@filesw\immediate\write\@auxout{]], @@ -1876,7 +1903,16 @@ local function update_tr_res(res,mode,opaq) texsprint(catat11,[[\global\TRP@reruntrue]]) end else - res = res..tr + if luatexbase.callbacktypes.finish_pdffile then + pdfetcs.opacity_res[#pdfetcs.opacity_res+1] = tr + else + local tpr, n = pdfetcs.getpageres() or "", 0 + tpr, n = tpr:gsub("/ExtGState<<", "%1"..tr) + if n == 0 then + tpr = format("%s/ExtGState<<%s>>", tpr, tr) + end + pdfetcs.setpageres(tpr) + end end end else @@ -1887,40 +1923,59 @@ local function update_tr_res(res,mode,opaq) }) else local tr = format("/MPlibTr%s @mplibpdfobj%s",on,on) - if pdf_objs.pgfloaded then - texsprint(format("\\csname %s\\endcsname{%s}", pdf_objs.pgfextgs,tr)) + if pdfetcs.pgfloaded then + texsprint(format("\\csname %s\\endcsname{%s}", pdfetcs.pgfextgs,tr)) else texsprint(format("\\special{pdf:put @MPlibTr<<%s>>}",tr)) + texsprint"\\special{pdf:put @resources<</ExtGState @MPlibTr>>}" end end end end - return res,on + return on end -local function tr_pdf_pageresources(mode,opaq) - if pdf_objs.pgfloaded == nil then - pdf_objs.pgfloaded = is_defined(pdf_objs.pgfextgs) - end - local res, on_on, off_on = "", nil, nil - res, off_on = update_tr_res(res, "Normal", 1) - res, on_on = update_tr_res(res, mode, opaq) - if pdfmanagement or pdf_objs.pgfloaded or is_defined"TRP@list" then - return on_on, off_on +local function do_preobj_TR(prescript) + local opaq = prescript and prescript.tr_transparency + local tron_no, troff_no + if opaq then + local mode = prescript.tr_alternative or 1 + mode = transparancy_modes[tonumber(mode)] + troff_no = update_tr_res("Normal", 1) + tron_no = update_tr_res(mode, opaq) + pdf_literalcode("/MPlibTr%i gs",tron_no) end - if pdfmode then - if res ~= "" then - local tpr, n = pdf_objs.getpageres() or "", 0 - tpr, n = tpr:gsub("/ExtGState<<", "%1"..res) - if n == 0 then - tpr = format("%s/ExtGState<<%s>>", tpr, res) - end - pdf_objs.setpageres(tpr) + return troff_no +end + +% \end{macrocode} +% +% color +% \begin{macrocode} +local prev_override_color +local function do_preobj_CR(object,prescript) + local override = prescript and prescript.MPlibOverrideColor + if override then + if pdfmode then + pdf_literalcode(override) + override = nil + else + put2output("\\special{%s}",override) + prev_override_color = override end else - texsprint"\\special{pdf:put @resources<</ExtGState @MPlibTr>>}" + local cs = object.color + if cs and #cs > 0 then + pdf_literalcode(luamplib.colorconverter(cs)) + prev_override_color = nil + elseif not pdfmode then + override = prev_override_color + if override then + put2output("\\special{%s}",override) + end + end end - return on_on, off_on + return override end % \end{macrocode} @@ -1928,18 +1983,18 @@ end % Shading with |metafun| format. % \begin{macrocode} local function shading_initialize () - pdf_objs.shading_res = {} + pdfetcs.shading_res = {} if pdfmode and luatexbase.callbacktypes.finish_pdffile then -- ltluatex local shading_obj = pdf.reserveobj() - pdf_objs.setpageres(format("%s/Shading %i 0 R",pdf_objs.getpageres() or "",shading_obj)) + pdfetcs.setpageres(format("%s/Shading %i 0 R",pdfetcs.getpageres() or "",shading_obj)) luatexbase.add_to_callback("finish_pdffile", function() - pdf.immediateobj(shading_obj,format("<<%s>>",tableconcat(pdf_objs.shading_res))) - end, "luamplib.finish_pdffile") + pdf.immediateobj(shading_obj,format("<<%s>>",tableconcat(pdfetcs.shading_res))) + end, "luamplib.shading.finish_pdffile") end end local function sh_pdfpageresources(shtype,domain,colorspace,ca,cb,coordinates,steps,fractions) - if not pdfmanagement and not pdf_objs.shading_res then + if not pdfmanagement and not pdfetcs.shading_res then shading_initialize() end local fun2fmt,os = "<</FunctionType 2/Domain [%s]/C0 [%s]/C1 [%s]/N 1>>" @@ -1972,20 +2027,7 @@ local function sh_pdfpageresources(shtype,domain,colorspace,ca,cb,coordinates,st format("/Coords [%s]", coordinates), "/Extend [true true]/AntiAlias true>>", } - local on, new - if colorspace == [[\pdf_object_ref_last:]] then - if pdfmode then - on, new = pdf.reserveobj(), true - texsprint(ccexplat, format([[\immediate\pdfextension obj useobjnum %s{%s}]],on,os)) - else - local int = tex.getcount"g__pdf_backend_object_int"+1 - tex.setcount("global","g__pdf_backend_object_int", int) - on, new = format("cs%s",int), true - texsprint(ccexplat, format("\\special{pdf:obj @mplibpdfobj%s %s}",on,os)) - end - else - on, new = update_pdfobjs(os) - end + local on, new = update_pdfobjs(os) if pdfmode then if new then if pdfmanagement then @@ -1996,14 +2038,14 @@ local function sh_pdfpageresources(shtype,domain,colorspace,ca,cb,coordinates,st else local res = format("/MPlibSh%s %s 0 R", on, on) if luatexbase.callbacktypes.finish_pdffile then - pdf_objs.shading_res[#pdf_objs.shading_res+1] = res + pdfetcs.shading_res[#pdfetcs.shading_res+1] = res else - local pageres = pdf_objs.getpageres() or "" + local pageres = pdfetcs.getpageres() or "" if not pageres:find("/Shading<<.*>>") then pageres = pageres.."/Shading<<>>" end pageres = pageres:gsub("/Shading<<","%1"..res) - pdf_objs.setpageres(pageres) + pdfetcs.setpageres(pageres) end end end @@ -2040,57 +2082,7 @@ local function color_normalize(ca,cb) end end -% \end{macrocode} -% -% transparency -% \begin{macrocode} -local function do_preobj_TR(prescript) - local opaq = prescript and prescript.tr_transparency - local tron_no, troff_no - if opaq then - local mode = prescript.tr_alternative or 1 - mode = transparancy_modes[tonumber(mode)] - tron_no, troff_no = tr_pdf_pageresources(mode,opaq) - pdf_literalcode("/MPlibTr%i gs",tron_no) - end - return troff_no -end - -% \end{macrocode} -% -% color -% \begin{macrocode} -local prev_override_color -local function do_preobj_CR(object,prescript) - local override = prescript and prescript.MPlibOverrideColor - if override then - if pdfmode then - pdf_literalcode(override) - override = nil - else - texsprint(format("\\special{%s}",override)) - prev_override_color = override - end - else - local cs = object.color - if cs and #cs > 0 then - pdf_literalcode(luamplib.colorconverter(cs)) - prev_override_color = nil - elseif not pdfmode then - override = prev_override_color - if override then - texsprint(format("\\special{%s}",override)) - end - end - end - return override -end - -% \end{macrocode} -% -% shading -% \begin{macrocode} -luamplib.clrspcs = { } +pdfetcs.clrspcs = { } local function do_preobj_SH(object,prescript) local shade_no local sh_type = prescript and prescript.sh_type @@ -2165,38 +2157,18 @@ local function do_preobj_SH(object,prescript) colorspace = objref else local name = tableconcat(names,"-") - local obj = luamplib.clrspcs[name] or 0 - if type(obj) == "string" then + local obj = pdfetcs.clrspcs[name] + if obj then colorspace = obj else - obj = obj+1 - luamplib.clrspcs[name] = obj - colorspace = [[\pdf_object_ref_last:]] - local function put_devicen() - texsprint(ccexplat,{ - [[\color_model_new:nnn]], - format("{mplibcolorspace_%s_%s}", name, obj), - format("{DeviceN}{names={%s}}", tableconcat(names,",")), - }) - end - if obj == 1 then - put_devicen() - texsprint(ccexplat,"\\directlua{luamplib.clrspcs['",name,"']='",colorspace,"'}") - if is_defined'@auxout' then - texsprint(ccexplat,format("\\if@filesw\\immediate\\write\\@auxout{\z - \\string\\expandafter\\string\\gdef\\string\\csname\\space luamplib.colorspace.%s\z - \\string\\endcsname{%s}}\\fi", name, colorspace)) - end - else - local auxobj = get_macro(format("luamplib.colorspace.%s",name)) - colorspace = auxobj or colorspace - if not auxobj then put_devicen() end - if is_defined'@auxout' then - texsprint(format("\\directlua{ if luamplib.clrspcs['%s']=='%s' then else \z - texio.write_nl('term and log','Module luamplib Warning: Rerun to get smaller PDF \z - on input line %s','') end }", name, auxobj, tex.inputlineno)) - end - end + run_tex_code({ + [[\color_model_new:nnn]], + format("{mplibcolorspace_%s}", name), + format("{DeviceN}{names={%s}}", tableconcat(names,",")), + [[\edef\mplib_@tempa{\pdf_object_ref_last:}]], + }, ccexplat) + colorspace = get_macro'mplib_@tempa' + pdfetcs.clrspcs[name] = colorspace end end else @@ -2239,12 +2211,16 @@ local function do_preobj_SH(object,prescript) return shade_no end +% \end{macrocode} +% +% color stuffs at the end of object +% \begin{macrocode} local function do_postobj_color(tr,over,sh) if sh then pdf_literalcode("W n /MPlibSh%s sh Q",sh) end if over then - texsprint"\\special{pdf:ec}" + put2output"\\special{pdf:ec}" end if tr then pdf_literalcode("/MPlibTr%i gs",tr) @@ -2281,14 +2257,13 @@ local function flush(result,flusher) % \begin{macrocode} else % \end{macrocode} -% -% For legacy behavior. Insert `pre-fig' \TeX\ code here, and +% For collecting pdf materials and +% for legacy behavior. Insert `pre-fig' \TeX\ code here, and % prepare a table for `in-fig' codes. % \begin{macrocode} if tex_code_pre_mplib[f] then - texsprint(tex_code_pre_mplib[f]) + put2output(tex_code_pre_mplib[f]) end - local TeX_code_bot = {} pdf_startfigure(fignum,llx,lly,urx,ury) start_pdf_code() if objects then @@ -2325,7 +2300,7 @@ local function flush(result,flusher) % Legacy behavior. % \begin{macrocode} if prescript and prescript.postmplibverbtex then - TeX_code_bot[#TeX_code_bot+1] = prescript.postmplibverbtex + figcontents.post[#figcontents.post+1] = prescript.postmplibverbtex end elseif objecttype == "text" then local ot = object.transform -- 3,4,5,6,1,2 @@ -2484,7 +2459,15 @@ local function flush(result,flusher) end stop_pdf_code() pdf_stopfigure() - if #TeX_code_bot > 0 then texsprint(TeX_code_bot) end + for _,v in ipairs(figcontents) do + if type(v) == "table" then + texsprint"\\mplibtoPDF{"; texsprint(v[1], v[2]); texsprint"}" + else + texsprint(v) + end + end + if #figcontents.post > 0 then texsprint(figcontents.post) end + figcontents = { post = { } } end end end @@ -2528,7 +2511,7 @@ luamplib.colorconverter = colorconverter \else \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{luamplib} - [2024/04/19 v2.28.1 mplib package for LuaTeX] + [2024/04/25 v2.28.2 mplib package for LuaTeX] \ifx\newluafunction\@undefined \input ltluatex \fi @@ -2540,7 +2523,7 @@ luamplib.colorconverter = colorconverter \directlua{require("luamplib")} % \end{macrocode} % -% Support older engine. Seems we don't need it, but no harm. +% legacy commands. Seems we don't need it, but no harm. % \begin{macrocode} \ifx\pdfoutput\undefined \let\pdfoutput\outputmode @@ -2791,7 +2774,7 @@ luamplib.colorconverter = colorconverter % \begin{macrocode} \def\mplibstarttoPDF#1#2#3#4{% \prependtomplibbox - \hbox\bgroup + \hbox dir TLT\bgroup \xdef\MPllx{#1}\xdef\MPlly{#2}% \xdef\MPurx{#3}\xdef\MPury{#4}% \xdef\MPwidth{\the\dimexpr#3bp-#1bp\relax}% diff --git a/macros/luatex/generic/luamplib/luamplib.pdf b/macros/luatex/generic/luamplib/luamplib.pdf Binary files differindex 1a8934e0cc..6d410a4c26 100644 --- a/macros/luatex/generic/luamplib/luamplib.pdf +++ b/macros/luatex/generic/luamplib/luamplib.pdf |