# -*- CPERL -*- package LaTeXML::Package::Pool; use strict; use LaTeXML::Package; use LaTeXML::Document; RequirePackage('LaTeX'); sub remove_tokens_from_list { my ($list, $pattern, $math) = @_; if (ref $list) { my @toks = $list->unlist; @toks = grep($_->toString !~ /$pattern/, @toks); ($math ? (LaTeXML::MathList->new(@toks)) : (LaTeXML::List)->new(@toks)); } else { undef; } } sub remove_math_commas { my ($whatsit, $argno) = @_; my @args = $whatsit ? $whatsit->getArgs() : undef; $argno--; if ($args[$argno]) { $args[$argno] = remove_tokens_from_list($args[$argno], ',', 1); $whatsit->setArgs(@args); } return; } DefConstructor('\Capply [] {} {}', "#2 #3"); DefConstructor('\Ccn [] {}',"#2"); DefConstructor('\Cci [] {}',"#2"); DefConstructor('\Ccsymbol [] {}', ""); DefConstructor('\Cccinterval [] {}{}', "" . "" . "#2" . "#3"); DefConstructor('\Ccointerval [] {}{}', "" . "" . "#2" . "#3"); DefConstructor('\Cocinterval [] {}{}', "" . "" . "#2" . "#3"); DefConstructor('\Coointerval [] {}{}', "" . "" . "#2" . "#3"); DefConstructor('\Cinverse [] {}', "" . "" . "#2" . ""); DefConstructor('\Clambda [] {}{}', "" . "" . "#2" . "#2" . ""); DefConstructor('\ClambdaDA [] {}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\Crestrict [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CcomposeOp []', ""); DefConstructor('\Ccompose [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\Cident []', ""); DefConstructor('\Cdomain [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccodomain [] {}', "" . "" . "#2" . ""); DefConstructor('\Cimage [] {}', "" . "" . "#2" . ""); DefConstructor('\Cpiecewise [] {}', "" . "" . "#2" . ""); DefConstructor('\Cpiece [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cotherwise [] {}', "" . "" . "#2" . ""); DefConstructor('\Cquotient [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CfactorialOp []', ""); DefConstructor('\Cfactorial [] {}', "" . "" . "#2" . ""); DefConstructor('\CdivideOp []', ""); DefConstructor('\Cdivide [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CmaxOp []', ""); DefConstructor('\Cmax [] {}', "" . "" . "#2" . ""); DefConstructor('\CminOp []', ""); DefConstructor('\Cmin [] {}', "" . "" . "#2" . ""); DefConstructor('\CminusOp []', ""); DefConstructor('\Cminus [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cuminus [] {}', "" . "" . "#2" . ""); DefConstructor('\CplusOp []', ""); DefConstructor('\Cplus [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\Cpower [] {} {}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CremOp []', ""); DefConstructor('\Crem [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CtimesOp []', ""); DefConstructor('\Ctimes [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CrootOp []', ""); DefConstructor('\Croot [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cgcd [] {}', "" . "" . "#2" . ""); DefConstructor('\CandOp []', ""); DefConstructor('\Cand [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CorOp []', ""); DefConstructor('\Cor [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CxorOp []', ""); DefConstructor('\Cxor [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CnotOp []', ""); DefConstructor('\Cnot [] {}', "" . "" . "#2" . ""); DefConstructor('\CimpliesOp []', ""); DefConstructor('\Cimplies [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CAndDa [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CAndCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\COrDa [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\COrCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CXorDa [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CXorCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\Cforall [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CforallCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\Cexists [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CexistsCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\Cabs [] {}', "" . "" . "#2" . ""); DefConstructor('\Cconjugate [] {}', "" . "" . "#2" . ""); DefConstructor('\Carg [] {}', "" . "" . "#2" . ""); DefConstructor('\Creal [] {}', "" . "" . "#2" . ""); DefConstructor('\Cimaginary [] {}', "" . "" . "#2" . ""); DefConstructor('\Clcm [] {}', "" . "" . "#2" . ""); DefConstructor('\Cfloor [] {}', "" . "" . "#2" . ""); DefConstructor('\Cceiling [] {}', "" . "" . "#2" . ""); DefConstructor('\CeqOp []', ""); DefConstructor('\Ceq [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CneqOp []', ""); DefConstructor('\Cneq [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CgtOp []', ""); DefConstructor('\Cgt [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CltOp []', ""); DefConstructor('\Clt [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CgeqOp []', ""); DefConstructor('\Cgeq [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CleqOp []', ""); DefConstructor('\Cleq [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CequivalentOp []', ""); DefConstructor('\Cequivalent [] {}', "" . "" . "#2" . ""); DefConstructor('\CapproxOp []', ""); DefConstructor('\Capprox [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CfactorofOp []', ""); DefConstructor('\Cfactorof [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CintOp []', ""); DefConstructor('\Cint [] {}', "" . "" . "#2" . ""); DefConstructor('\CintLimits [] {}{}{}{}', "" . "" . "#2" . "#3" . "#4" . "#5" . ""); DefConstructor('\CintDA [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CintCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\Cdiff [] {}', "" . "" . "#2" . ""); DefConstructor('\Cddiff [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cpartialdiff [] {}{}{}', "" . "" . "#3" . "?#2(#2)()" . "#4" . ""); DefConstructor('\Cdegree {}{}', "" . "" . "#2" . "#1" . ""); DefConstructor('\Climit [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\ClimitCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CtendstoOp []', ""); DefConstructor('\Ctendsto [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CtendstoAboveOp []', ""); DefConstructor('\CtendstoAbove [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CtendstoBelowOp []', ""); DefConstructor('\CtendstoBelow [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cdivergence [] {}', "" . "" . "#2" . ""); DefConstructor('\Cgrad [] {}', "" . "" . "#2" . ""); DefConstructor('\Curl [] {}', "" . "" . "#2" . ""); DefConstructor('\Claplacian [] {}', "" . "" . "#2" . ""); DefConstructor('\Cset [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CsetRes [] {}{}', "" . "" . "#2" . "#3" . "#2" . ""); DefConstructor('\CsetCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CsetDA [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\ClistOp []', ""); DefConstructor('\Clist [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CunionOp []', ""); DefConstructor('\Cunion [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CintersectOp []', ""); DefConstructor('\Cintersect [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CinOp []', ""); DefConstructor('\Cin [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CnotinOp []', ""); DefConstructor('\Cnotin [] {}{}', "" . "" . "#2" . ""); DefConstructor('\CsubsetOp []', ""); DefConstructor('\Csubset [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CprsubsetOp []', ""); DefConstructor('\Cprsubset [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CnotsubsetOp []', ""); DefConstructor('\Cnotsubset [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CnotprsubsetOp []', ""); DefConstructor('\Cnotprsubset [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CsetdiffOp []', ""); DefConstructor('\Csetdiff [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CcardOp []', ""); DefConstructor('\Ccard [] {}', "" . "" . "#2" . ""); DefConstructor('\CcartesianproductOp []', ""); DefConstructor('\Ccartesianproduct [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\CsupsetOp []', ""); DefConstructor('\CprsupsetOp []', ""); DefConstructor('\CnotsupsetOp []', ""); DefConstructor('\CnotprsupsetOp []', ""); DefMacro('\Csupset[]{}','\Csubset[#1]{#2}'); DefMacro('\Cprsupset[]{}','\Cprsubset[#1]{#2}'); DefMacro('\Cnotsupset[]{}{}','\Cnotsubset[#1]{#3}{#2}'); DefMacro('\Cnotprsupset[]{}{}','\Cnotprsubset[#1]{#3}{#2}'); DefConstructor('\CUnionDAOp []', ""); DefConstructor('\CUnionDA [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CUnionCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CIntersectDaOp []', ""); DefConstructor('\CIntersectDa [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CIntersectCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CCartesianproductDaOp []', ""); DefConstructor('\CCartesianproductDa [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CCartesianproductCond [] {}{}{}', "" . "" . "#2" . "#3" . "#4" . ""); DefConstructor('\CsumOp []', ""); DefConstructor('\CsumLimits [] {}{}{}{}', "" . "" . "#2" . "#3" . "#4" . "#5"); DefConstructor('\CprodOp []', ""); DefConstructor('\CprodLimits [] {}{}{}{}', "" . "" . "#2" . "#3" . "#4" . "#5"); DefConstructor('\Csin [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccos [] {}', "" . "" . "#2" . ""); DefConstructor('\Ctan [] {}', "" . "" . "#2" . ""); DefConstructor('\Csec [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccsc [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccot [] {}', "" . "" . "#2" . ""); DefConstructor('\Csinh [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccosh [] {}', "" . "" . "#2" . ""); DefConstructor('\Ctanh [] {}', "" . "" . "#2" . ""); DefConstructor('\Csech [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccsch [] {}', "" . "" . "#2" . ""); DefConstructor('\Ccoth [] {}', "" . "" . "#2" . ""); DefConstructor('\Carcsin [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccos [] {}', "" . "" . "#2" . ""); DefConstructor('\Carctan [] {}', "" . "" . "#2" . ""); DefConstructor('\Carcsec [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccsc [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccot [] {}', "" . "" . "#2" . ""); DefConstructor('\Carcsinh [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccosh [] {}', "" . "" . "#2" . ""); DefConstructor('\Carctanh [] {}', "" . "" . "#2" . ""); DefConstructor('\Carcsech [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccsch [] {}', "" . "" . "#2" . ""); DefConstructor('\Carccoth [] {}', "" . "" . "#2" . ""); DefConstructor('\Cexp [] {}', "" . "" . "#2" . ""); DefConstructor('\Cln [] {}', "" . "" . "#2" . ""); DefConstructor('\Clog [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cmean [] {}', "" . "" . "#2" . ""); DefConstructor('\Csdev [] {}', "" . "" . "#2" . ""); DefConstructor('\Cvar [] {}', "" . "" . "#2" . ""); DefConstructor('\Cmedian [] {}', "" . "" . "#2" . ""); DefConstructor('\Cmode [] {}', "" . "" . "#2" . ""); DefConstructor('\Cmoment [] {}', "" . "" . "#2" . ""); DefConstructor('\Cvector [] {}', "" . "" . "#2" . "", afterDigest=>sub { remove_math_commas($_[1], 2); }); DefConstructor('\Cmatrix [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cdeterminant [] {}', "" . "" . "#2" . ""); DefConstructor('\Ctranspose [] {}', "" . "" . "#2" . ""); DefConstructor('\Cselector [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CvectorproductOp []', ""); DefConstructor('\Cvectorproduct [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cscalarproduct [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\CouterproductOp []', ""); DefConstructor('\Couterproduct [] {}{}', "" . "" . "#2" . "#3" . ""); DefConstructor('\Cintegers []', ""); DefConstructor('\Creals []', ""); DefConstructor('\Crationals []', ""); DefConstructor('\Cnaturalnumbers []', ""); DefConstructor('\Ccomplexes []', ""); DefConstructor('\Cprimes []', ""); DefConstructor('\Cexponentiale []', ""); DefConstructor('\Cimaginaryi []', ""); DefConstructor('\Cnotanumber []', ""); DefConstructor('\Ctrue []', ""); DefConstructor('\Cfalse []', ""); DefConstructor('\Cemptyset []', ""); DefConstructor('\Cpi []', ""); DefConstructor('\Ceulergamma []', ""); DefConstructor('\Cinfinit []', ""); 1;