From 01c9ee84c09adfc3efe1cd93191a9c0473f985fe Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 12 Jul 2017 23:26:39 +0900 Subject: add acrotex --- texmf-dist/tex/latex/acrotex/dljslib.sty | 1725 ++++++++++++++++++++++++++++++ 1 file changed, 1725 insertions(+) create mode 100644 texmf-dist/tex/latex/acrotex/dljslib.sty (limited to 'texmf-dist/tex/latex/acrotex/dljslib.sty') diff --git a/texmf-dist/tex/latex/acrotex/dljslib.sty b/texmf-dist/tex/latex/acrotex/dljslib.sty new file mode 100644 index 00000000..871720d7 --- /dev/null +++ b/texmf-dist/tex/latex/acrotex/dljslib.sty @@ -0,0 +1,1725 @@ +%% +%% This is file `dljslib.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% dljslib.dtx (with options: `copyright,package') +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% dljsLib.sty package, %% +%% Copyright (C) 2001-2016 D. P. Story %% +%% dpstory@uakron.edu %% +%% %% +%% This program can redistributed and/or modified under %% +%% the terms of the LaTeX Projet Public License %% +%% Distributed from CTAN archives in directory %% +%% macros/latex/base/lppl.txt; either version 1 of the %% +%% License, or (at your option) any later version. %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{dljslib} + [2014/10/05 v2.0 Manage a Library of Document Level JavaScripts (dps)] +\newcommand\dljsRegister[2][n] + {\expandafter\let\csname checkout@#2\endcsname=#1} +\def\@ifcheckedout#1{\expandafter\if\csname checkout@#1\endcsname y} +\newcommand\DeclareAndRegister[1] + {\DeclareOption{#1}{\dljsRegister[y]{#1}}\dljsRegister{#1}} +\dljsRegister[y]{dljslib} +\DeclareAndRegister{equations} +\DeclareAndRegister{vectors} +\DeclareAndRegister{indefIntegral} +\DeclareAndRegister{ImplMulti} +\DeclareAndRegister{nodec} +\DeclareAndRegister{noBinFac} +\DeclareAndRegister{limitArith} +\DeclareAndRegister{combinatorics} +\DeclareAndRegister{setSupport} +\DeclareOption{unordered}{\PackageWarning{dljslib} + {The `unordered' option is now combined with the\MessageBreak + `setSupport' option, will use the `setSupport' option\MessageBreak + instead}\ExecuteOptions{setSupport}} +\DeclareAndRegister{complex} +\DeclareAndRegister{satisfyEq} +\DeclareAndRegister{useGermanNums} +\DeclareAndRegister{factors} +\DeclareAndRegister{point} +\DeclareAndRegister{intervals} +\def\includeOptions#1{\@for\@option:=#1\do{\dljsRegister[y]{\@option}}} +\InputIfFileExists{libcusopt.opt}{}{} +\ProcessOptions +\RequirePackage{insdljs} +\def\setdecimalpoint#1{\def\aebdecimalpoint{\eqbs#1}} +\setdecimalpoint{.} +\newwrite\dljslib@verbatim@out +\immediate\openout\dljslib@verbatim@out=dljslib.ljs +\newenvironment{library@holding}[1] +{% + \expandafter\ifx\csname checkout@#1\endcsname y% + \let\js@verbatim@out\dljslib@verbatim@out + \let\dljs@verbatim\js@verbatimwrite + \let\enddljs@verbatim\endjs@verbatimwrite\else + \let\dljs@verbatim\comment + \let\enddljs@verbatim\endcomment\fi\dljs@verbatim +}{\enddljs@verbatim} +\begin{library@holding}{dljslib} +\begin{insDLJS*}[dljslib]{dljslib} +\begin{newsegment}{dljslib: AcroTeX DLJS Library} +/* + The Document Level JavaScript Library + D. P. Story copyright 2001-\the\year +*/ +var dljslib = true; +\end{newsegment} +\end{library@holding} +\@ifcheckedout{equations} +\newcommand\equationsAlertMsg{"An equation is expected"} +\fi +\begin{library@holding}{equations} +\begin{newsegment}{dljslib: Equation Handling} +function ProcRespEq(flag,CorrAns,n,epsilon,domain,indepVar,oComp) +{ + if (!ProcessIt) return null; + ok2Continue = true; + var success; + var fieldname = event.target.name; + var UserAns = event.value; + var CorrExpressions = CorrAns.split("="); + var zCorrAns = "("+CorrExpressions[0]+")-("+CorrExpressions[1] +")"; + UserAns = stripWhiteSpace (UserAns); + if(!ok2Continue ) return null; + if (!/[=]/.test(UserAns)) { + eqAppAlert(\equationsAlertMsg, 3); + return null; + } + var reComma=/,/; + if ( reComma.test(UserAns) ) { + eqAppAlert(\eqSyntaxErrorComma,3); + return null; + } + var UserExpressions = UserAns.split("="); + var zUserAns = "("+UserExpressions[0]+")-("+UserExpressions[1] +")"; + + var comp = ( typeof oComp == "object" ) ? + (typeof oComp.comp == "undefined" ) ? + diffCompare : oComp.comp : oComp; + if ( typeof oComp == "object" + && typeof oComp.priorParse != "undefined" ) { + if ( typeof oComp.priorParse == "object" ) { + for ( var i=0; i < oComp.priorParse.length; i++) { + var retn = oComp.priorParse[i](zUserAns); + if ( retn == null ) return null; + } + } else { + var retn = oComp.priorParse(zUserAns); + if ( retn == null ) return null; + } + } + zCorrAns = ParseInput(zCorrAns); + if (!ok2Continue) { + eqAppAlert("Syntax error in author's answer! Check console.", 3); + console.println("Syntax Error: " + CorrAns); + return null; + } + zUserAns = ParseInput(zUserAns); + if (!ok2Continue) return null; + indepVar = TypeParameters(indepVar); + var lambda = getNonZeroRatio (domain, indepVar, zCorrAns, zUserAns); + if ( lambda == null ) { + eqAppAlert(\eqSyntaxErrorUndefVar,3); return null; }; + if ( !ok2Continue ) return notifyField(false, flag, fieldname); + zCorrAns = lambda + "*(" + zCorrAns + ")"; + success=randomPointCompare (n,domain,indepVar,epsilon, + zCorrAns,zUserAns,comp) + if ( success == null ) { eqAppAlert(\eqSyntaxErrorUndefVar,3); + return null; } + return notifyField(success, flag, fieldname); +} +function getNonZeroRatio (_a, _v, _F, _G) +{ + var _i, _j; + var aXY = new Array(); + _a = _a.replace(/[\[\]\s]/g, ""); + var _V = _v.split(","); // e.g. _V[0] = "i:x" + var _n = _V.length; + var aIntervals = _a.split("&"); + var aInterval = aIntervals[0].split("x"); + var endpoints = aInterval[0].split(","); + for (_j=0; _j < 4; _j++) { + for (_i = 0; _i < _n; _i++) { + var endpoints = aInterval[_i].split(","); + aXY[_i] = endpoints[0]-0 + +(endpoints[1]-endpoints[0])*Math.random(); +\db console.println("aXY["+_i+"] = " + aXY[_i]);\db% + } + for (var _i = 0; _i< _n; _i++) { + if (_V[_i].charAt(0) == "r" ) + eval ( "var "+ _V[_i].charAt(2) + + " = " + aXY[_i] + ";"); + else // assume type "i" + eval ( "var "+ _V[_i].charAt(2) + + " = " + Math.ceil(aXY[_i]) + ";"); + } + _F = eval(_F); + if ( app.viewerVersion >= 5) + { + var rtnCode = 0; + eval("try { if(isNaN(_G = eval(_G))) rtnCode=-1; }" + +"catch (e) { rtnCode=1; }"); + switch(rtnCode) { + case 0: break; + case 1: return null; + case -1: ok2Continue=false; + return -1; + } + } + else + if(isNaN(_G=eval(_G))) {ok2Continue=false;return -1;} + if ( _F != 0 && _G != 0 ) return _G/_F; + } + console.println( "Can't find a non zero scalar"); + return null; +} +\end{newsegment} +\end{library@holding} +\@ifcheckedout{vectors} +\newcommand\vectorsErrorMsgi{"I'm looking for a vector. + You need to use proper vector notation, try using + angle brackets <....>."} +\newcommand\vectorsErrorMsgii{"Angle brackets are not balanced. + Check the expression you typed in."} +\newcommand\vectorsErrorMsgiii{"Incorrect number of components. + The answer requires " + aCorrAns.length+" components."} +\def\vectorEmptyCompMsgiv(#1){"You entered nothing for the + component " +(#1+1) +" of your answer. Please enter + a component for the vector."} +\fi +\begin{library@holding}{vectors} +\begin{newsegment}{dljslib: Vector Handling} +function ProcVec (flag,CorrAns,n,epsilon,domain,indepVar,oComp) +{ + if (!ProcessIt) return null; + ok2Continue = true; + var i, success, truthCnt=1; + var aScalar, scalar = 1; + var fieldname = event.target.name; + var UserAns = event.value; + UserAns = stripWhiteSpace(UserAns); // sets ok2Continue + CorrAns = stripWhiteSpace(CorrAns); + if ( !ok2Continue ) return null; + var isSpecResp=false; + for ( var i=0; i]/.test(UserAns)) { + eqAppAlert(\vectorsErrorMsgi, 3); + return null; + } + if (!CkBalP(UserAns,"<",">")) { + eqAppAlert(\vectorsErrorMsgii, 3); + return null; + } + // see if there is a scalar multiple to the left of '<' + aScalar = UserAns.match(/(.*)(\*)(\s*<)/); + if (aScalar != null) { + scalar = aScalar[1]; + UserAns = UserAns.slice(aScalar.index + aScalar[0].length-1) + } + var comp = ( typeof oComp == "object" ) ? + (typeof oComp.comp == "undefined" ) ? + diffCompare : oComp.comp : oComp; + CorrAns = CorrAns.replace(/[<>]/g, ""); // strip of < and > + UserAns = UserAns.replace(/[<>]/g, ""); + if ( typeof oComp == "object" && % +typeof oComp.priorParse != "undefined" ) { + var retn=processSpecialParse(oComp.priorParse,UserAns); + if (retn==null) return null; + } + aUserAns = UserAns.split(","); + aCorrAns = CorrAns.split(","); + if (scalar != 1) + for (i=0; i)."} +\fi +\begin{library@holding}{setSupport} +\begin{newsegment}{dljslib: Support for Sets} +function ProcRespSetNum(flag,CorrAns,n,epsilon,domain,indepVar,oComp) +{ + ok2Continue = true; + if (!ProcessIt) return null; + var fieldname = event.target.name; + var UserAns = event.value; + UserAns = stripWhiteSpace(UserAns); + CorrAns = stripWhiteSpace(CorrAns); + if (!ok2Continue) return null; + var isSpecResp=false; + for ( var i=0; i$/.test(UserAns) ) { + ok2format=false; + return eqAppAlert(\noBracketsInAnsMsg,3), null; + } + else return true; +} +function formatAsVector() { + if (ok2format&&event.value.replace(/\\s/g,"") != "") { + event.value = "< " + event.value + " >"; + } +} +function ProcRespSetSym(flag,CorrAns,n,epsilon,domain,indepVar,oComp) +{ + ok2Continue = true; + if (!ProcessIt) return null; + var fieldname = event.target.name; + var UserAns = event.value; + UserAns = stripWhiteSpace(UserAns); + CorrAns = stripWhiteSpace(CorrAns); + if (!ok2Continue) return null; + var isSpecResp=false; + for ( var i=0; i 1) { + eqAppAlert(\alertNotComplexMsg, 3); + return null; + } + var comp = ( typeof oComp == "object" ) ? + (typeof oComp.comp == "undefined" ) ? + diffCompare : oComp.comp : oComp; + if ( typeof oComp == "object" && + typeof oComp.priorParse != "undefined" ) { + if ( typeof oComp.priorParse == "object" ) { + for ( var i=0; i < oComp.priorParse.length; i++) { + var retn = oComp.priorParse[i](UserAns); + if ( retn == null ) return null; + } + } else { + var retn = oComp.priorParse(UserAns); + if ( retn == null ) return null; + } + } + UserAns = ParseInput(UserAns); + CorrAns = ParseInput(CorrAns); + indepVar = TypeParameters(indepVar); + if (!ok2Continue) return null; + success=randomPointCompare( + n,domain,indepVar,epsilon,CorrAns,UserAns,comp); + if ( success == null ) { eqAppAlert(% +\eqSyntaxErrorUndefVar,3); return null; } + return notifyField(success, flag, fieldname); +} +function ProcRespListComplex(flag,CorrAns,n,epsilon,% +domain,indepVar,oComp) { + ok2Continue = true; + if (!ProcessIt) return null; + var fieldname = event.target.name; + var UserAns = event.value; + UserAns = stripWhiteSpace(UserAns); + CorrAns = stripWhiteSpace(CorrAns); // sets ok2Continue + if ( !ok2Continue ) return null; + var isSpecResp=false; + for ( var i=0; i aUserAns.length ) + return eqAppAlert(\eqTooFewEntries,3), null; + var _v = TypeParameters(indepVar); + var _V = _v.split(","); // e.g. _V[0] = "i:x" + var _n = _V.length; + var testFunc=""; + for (var _i=0; _i < _n; _i++) + testFunc += ("+"+(Math.random()*9)+"*"+_V[_i].charAt(2)); + var isCorrect=1; + for (var pair=0; pair< l; pair++) { + if ( (aUserAns[pair].charAt(0) != "\(") || % +(aUserAns[pair].charAt(aUserAns[pair].length-1) != "\)")) + return eqAppAlert(\eqSyntaxErrorNoParens,3), null; + UserAnsPair=aUserAns[pair].substring(1,aUserAns[pair].length-1); + var aUserAnsPair = UserAnsPair.split(","); + for ( var i=0; i < aUserAnsPair.length; i++) { + try { if (isNaN(eval(aUserAnsPair[i]))) % +return syntaxError(), null; + if (!allowzero && (eval(aUserAnsPair[i])==0)) + return eqAppAlert(\eqNonzeroEntries,3), null; + } catch(e) { return syntaxError(), null; } + } + if ( aUserAnsPair.length != _n) { + if (bNotifyWrngNumEntries) + return eqAppAlert(\wrongNumEntriesMsg,3), null; + else + return notifyField(false, flag, fieldname); + } + for (var _i=0; _i < _n; _i++) { + if (_V[_i].charAt(0) == "r" ) + eval ("var "+_V[_i].charAt(2)+"="+aUserAnsPair[_i]+";"); + else // assume type "i" + eval ("var "+_V[_i].charAt(2)+"="% ++Math.ceil(aUserAnsPair[_i])+";"); + } + var UserInput=ParseInput(aCorrAns[1]); + var UserAns=eval(UserInput); + aUsersArray[pair]=eval(testFunc); + success=(Math.abs(UserAns) < epsilon)?true:false; +isCorrect *=Number(success); + } + success=(isCorrect==1); + var aOrderArray = aUsersArray.sort(function(a,b){return a-b}); + var m = aUsersArray.length - 1; + for (i=0; i= 5) + { + var rtnCode = 0; + eval("try {if (isNaN(eqC = eval(_F)-eval(_G))) rtnCode=-1;}" + +" catch (e) { rtnCode=1; }"); + switch(rtnCode) + { + case 0: break; + case 1: return null; + case -1: return -1; + } + } + else + if (isNaN(eqC = eval(_F)-eval(_G))) return -1; + for (var _i=0; _i< _n; _i++) + { + if (_V[_i].charAt(0) == "r" ) + eval ( "var "+ _V[_i].charAt(2) + + " = " + aXY[_i] + ";"); + else // assume type "i" + eval ( "var "+ _V[_i].charAt(2) + + " = " + Math.ceil(aXY[_i]) + ";"); + } + _F = eval(_F); + if ( app.viewerVersion >= 5) + { + var rtnCode = 0; + eval("try { if(isNaN(_G = eval(_G))) rtnCode=-1; }" + +" catch (e) { rtnCode=1; }"); + switch(rtnCode) + { + case 0: break; + case 1: return null; + case -1: return -1; + } + } + else + if(isNaN(_G = eval(_G))) return -1; + return Math.abs( _F - _G - eqC ); +} +\end{newsegment} +\end{library@holding} +\@ifcheckedout{nodec} +\newcommand\nodecAlertMsg{% + "A decimal answer is not acceptable here. + Please express your answer using fractions, square roots, + e, log, etc."} +\fi +\begin{library@holding}{nodec} +\begin{newsegment}{dljslib: Contrib - No Decimals} +function nodec(UserAns) +{ + var dot = /[\.\aebdecimalpoint]/; + if (dot.test(UserAns)) { + eqAppAlert(\nodecAlertMsg,3); + return null; + } else return true; +} +\end{newsegment} +\end{library@holding} +\@ifcheckedout{noBinFac} +\newcommand\noBinFactBinCoeffAlertMsg{% + "You may not use this notation here. + Please evaluate the binomial coefficient. + You may present your answer as a product rather + than calculating a very large number."} +\newcommand\noBinFactPermAlertMsg{% + "You may not use this notation here. + Please evaluate the permutation. + You may present your answer as a product rather + than calculating a very large number."} +\newcommand\noBinFactFactAlertMsg{% + "You may not use this notation here. + Please evaluate the factorial. + You may present your answer as a product rather + than calculating a very large number."} +\fi +\begin{library@holding}{noBinFac} +\begin{newsegment}{dljslib: Contrib - No Binomial Coefficients Allowed} +aReFact = new Array( + /(?=\()?(\d+)(?=\))?!/, + /(?=\[)?(\d+)(?=\])?!/, + /(?=\{)?(\d+)(?=\})?!/ +); +function noBinFac(UserAns) +{ + var bad = /(C\()/; + if (bad.test(UserAns)) { + eqAppAlert(\noBinFactBinCoeffAlertMsg,3); + return null; + } + bad = /(P\()/; + if (bad.test(UserAns)) { + eqAppAlert(\noBinFactPermAlertMsg,3); + return null; + } + for ( var i=0; i= 10 ) { + if (bAllowWrngNormSciNotn) + return true; + else + return eqAppAlert(\sciNotNormalForm,3), null; + } + else { + bItsNormSciNot=true; + return true + } + } else + return eqAppAlert(\sciNotSyntaxError,3), null; +} +function sciNotResp(UserAns) {return SciNotResp(UserAns);} +function postSciNotResp(UserAns) { + bAllowWrngNormSciNotn=false; + return bItsNormSciNot; +} +function NoNegExp (UserAns) { + var re=/(\^|\^\()+-/g; + UserAns=ChngAllGrpsToParens(UserAns); + if (re.test(UserAns)) + return eqAppAlert(\NoNegExpMsg,3), null; + return true; +} +function noNegExp(UserAns){return NoNegExp(UserAns)} +\end{newsegment} +\end{library@holding} +\begin{library@holding}{combinatorics} +\begin{newsegment}{dljslib: Contrib - Combinatorial Functions} +function ch(n,r) +{ + if ((n==r)||(r==0)) return(1); + if ((n==(r+1))||(r==1)) return(n); + if (r > (n-r)) + var coeff = factorialCancel( + expandFactorial(r+1,n),expandFactorial(1,n-r)); + else + var coeff = factorialCancel( + expandFactorial(n-r+1,n),expandFactorial(1,r)); + return (eval(coeff)); +} +function perm(n,r) +{ + if (r==0) return(1); + else + var coeff = factorialCancel( + expandFactorial(n-r+1,n),expandFactorial(1,n-r)); + return (eval(coeff)); +} +function expandFactorial(lo,hi) +{ + var f = lo; + for (var i=lo+1;i<=hi;i++) f = i+"*"+f; + return f; +} +function factorialCancel(top,bot) +{ + var num = top.split("*"); + var denom = bot.split("*"); + var len = denom.length; + var temp = 0; + var i, j; + for (i=0;i<=len-1;i++) { + for (j=0;j<=len-1;j++) { + temp = num[i]/denom[j]; + if ((temp - Math.round(temp)) == 0) { + num[i] = temp; + denom[j] = 1; + } + } + } + var t = denom.join(""); + var reg = /[^1]/; + if (reg.test(t)) { + temp = factorialCancel(denom.join("*"),num.join("*")); + } else { + temp = num.join("*"); + } + return (temp); +} +function fact(num) +{ + var tot = 1; + for (var r=1; r <= num; r++) tot *= r; + return(tot); +} +\end{newsegment} +\end{library@holding} +\begin{library@holding}{ImplMulti} +\begin{newsegment}{dljslib: Implied Multiplication} +function Ck4Products(UserInput) +{ + var re, aR; + for (var i=0; i