diff --git a/lib/LaTeXML/Engine/LaTeX.pool.ltxml b/lib/LaTeXML/Engine/LaTeX.pool.ltxml index ce07ee48f..aed074397 100644 --- a/lib/LaTeXML/Engine/LaTeX.pool.ltxml +++ b/lib/LaTeXML/Engine/LaTeX.pool.ltxml @@ -36,6 +36,10 @@ Let('\magnification', '\@undefined'); Let('\@empty', '\lx@empty'); Let('\@ifundefined', '\lx@ifundefined'); +# Use Package's register allocation to avoid allocating same slot twice; and ALWAYS have room! +DefMacro('\e@alloc{}{}{}{}{}{}', '\lx@alloc@{#1}{#3}{#2}{#6}', locked => 1); +DefMacro('\e@ch@ck{}{}{}{}', '', locked => 1); + #********************************************************************** # Basic \documentclass & \documentstyle @@ -771,6 +775,7 @@ sub beginAppendices { else { NewCounter($counter, 'document', idprefix => 'A'); DefMacroI('\the' . $counter, undef, '\Alph{' . $counter . '}', scope => 'global'); } + SetCounter($counter => Number(0)); # In case register was already defined AssignMapping('counter_for_type', appendix => $counter); Let(T_CS('\\' . $counter), T_CS('\@@appendix'), 'global'); Let(T_CS('\@appendix'), T_CS('\relax'), 'global'); diff --git a/lib/LaTeXML/Engine/plain.pool.ltxml b/lib/LaTeXML/Engine/plain.pool.ltxml index 45b52279a..afa62213c 100644 --- a/lib/LaTeXML/Engine/plain.pool.ltxml +++ b/lib/LaTeXML/Engine/plain.pool.ltxml @@ -196,6 +196,10 @@ DefPrimitive('\wlog{}', sub { NoteLog(ToString(Expand($_[1]))); return; }, locked => 1); + +# Use Package's register allocation to avoid allocating same slot twice; and ALWAYS have room! +DefMacro('\alloc@{}{}{}{}{}', '\lx@alloc@{#2}{\count1#1}{#3}{#5}', locked => 1); +DefMacro('\ch@ck{}{}{}', '', locked => 1); # From plain.tex RawTeX(<<'EoTeX'); \outer\def\newcount{\alloc@0\count\countdef\insc@unt} @@ -211,18 +215,9 @@ RawTeX(<<'EoTeX'); \outer\def\newfam{\alloc@8\fam\chardef\sixt@@n} \outer\def\newlanguage{\alloc@9\language\chardef\@cclvi} EoTeX -DefMacro('\e@alloc{}{}{}{}{}{}', - '\global\advance#3\@ne -% \e@ch@ck{#3}{#4}{#5}#1% - \allocationnumber#3\relax - \global#2#6\allocationnumber -% \wlog{\string#6=\string#1\the\allocationnumber} -'); -DefMacro('\alloc@{}{}{}{}', '\e@alloc#2#3{\count1#1}#4\float@count'); # This implementation is quite wrong DefPrimitive('\newinsert Token', sub { DefRegisterI($_[1], undef, Number(0)); }); -# \alloc@, \ch@ck # TeX plain uses \newdimen, etc. for these. # Is there any advantage to that?