⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 aeb_pro.dtx

📁 It uses latex to give question papers
💻 DTX
📖 第 1 页 / 共 5 页
字号:
\let\addJST@PageOpen=\@empty
\let\addJST@PageClose=\@empty
%    \end{macrocode}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \begin{macro}{\aeb@addToPageOpenCloseActions}
% This command gets expanded by \cs{AddToShipoutPicture} for each page. Here we
% define how our page actions are to be inserted.
%    \begin{macrocode}
\def\aeb@addToPageOpenCloseActions{%
    \@ifundefined{addJST@PageOpenAt\the\c@page}%
        {\def\thisOpenPageActionAt{\@empty}}%
        {\def\thisOpenPageActionAt{%
            \csname addJST@PageOpenAt\the\c@page\endcsname}}%
    \@ifundefined{addJST@PageCloseAt\the\c@page}%
        {\gdef\thisClosePageActionAt{\@empty}}%
        {\gdef\thisClosePageActionAt{%
            \csname addJST@PageCloseAt\the\c@page\endcsname}}%
    \aebPageAction{\thisOpenPageActionAt\addJST@PageOpen}%
        {\thisClosePageActionAt\addJST@PageClose}%
    \global\let\addJST@PageOpen\@empty\global\let\addJST@PageClose\@empty
}
\AddToShipoutPicture{\aeb@addToPageOpenCloseActions}
%    \end{macrocode}
%    \end{macro}
% \cs{@@defineJS} is a variation of \cs{@defineJS}, as defined in the \textsf{insdljs} package.
% This version, at the end of the environment, calls the \cs{aebp@rse} command to parse the
% complex command argument, then makes a series of definitions to be used in the open/close
% page events.
%    \begin{macrocode}
\newenvironment{@@defineJS}[3][]
{%
    \gdef\argType{#2}%
    \gdef\defineJSArg{#3}\JStoks={}%
    \def\verbatim@processline
        {%
            \xdef\JS@temp{\the\JStoks\the\verbatim@line\defineJSjsR}%
            \global\JStoks=\expandafter{\JS@temp}%
        }%
    \let\do\@makeother\dospecials\catcode`\^^M\active
    #1%
    \verbatim@start
}{%
    \expandafter\aebp@rse\expandafter{\defineJSArg}%
    \edef\shakeandbake{%
        \noexpand\@for\noexpand\@mytoks:=\the\aeb@parsetoks}%
    \aeb@parsecnt=0 \shakeandbake \do {%
        \ifnum\aeb@parsecnt=0
            \edef\firsttok{\@mytoks}%
            \expandafter\xdef\csname\argType\@mytoks\endcsname{%
                \the\JStoks}%
        \else
            \edef\letsmakelet{\global\let\expandafter\noexpand
                \csname\argType\@mytoks\endcsname=\expandafter\noexpand
                \csname\argType\firsttok\endcsname}%
            \letsmakelet
        \fi
        \advance\aeb@parsecnt1
    }%
}
%    \end{macrocode}
%    \begin{macrocode}
\newif\ifaeb@PageOpen
\newif\ifaeb@PageClose
\newif\if@everyPageOpen\@everyPageOpenfalse
\newif\if@everyPageClose\@everyPageClosefalse
%    \end{macrocode}
%    \begin{macro}{\aebPageAction}
% This is use internally, but can be used by the document author. The commands creates the code
% to set an open page and a close page action. The first (optional) argument is a the page number (base 1),
% this optional argument defaults to the current page if no page number is given. The second and third
% arguments are the open and closed JavaScript actions.
%
% If the document author uses this command, he my overwrite actions created by the \texttt{addJSTo...}
% environments. See \cs{aeb@addToPageOpenCloseActions} for usage by this package.
%    \begin{macrocode}
\newcommand\aebPageAction[3][ThisPage]{%
    \let\ispageactions=0\aeb@PageOpenfalse\aeb@PageOpenfalse
    \def\@aebOpen{#2}%
    \if1\@aebOpen1%
        \if@everyPageOpen
            \aeb@PageOpentrue\let\ispageactions=1%
            \def\@aebOpen{/O << \JS{\every@PageOpen#2} >>}%
        \fi
    \else
        \let\ispageactions=1%
        \aeb@PageOpentrue
        \def\@aebOpen{/O << \JS{\every@PageOpen#2} >>}%
    \fi
    \def\@aebClose{#3}%
    \if1\@aebClose1%
        \if@everyPageClose
            \aeb@PageClosetrue\let\ispageactions=1%
            \def\@aebClose{/C << \JS{\every@PageClose#3} >>}%
        \fi
    \else
        \let\ispageactions=1%
        \aeb@PageClosetrue
        \def\@aebClose{/C << \JS{\every@PageClose#3} >>}%
    \fi
    \if@everyPageOpen\aeb@PageOpentrue\let\ispageactions=1\fi
    \if@everyPageClose\@everyPageClosetrue\let\ispageactions=1\fi
    \if\ispageactions1%
    \literalps@out{[ {#1} << /AA
        << \ifaeb@PageOpen\@aebOpen\space\fi
           \ifaeb@PageClose\@aebClose\space\fi >> >> /PUT pdfmark}%
    \fi
}
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\atPage}
% \cs{atPage} is a modification of \cs{pageref}, so its value will always be an integer.
% returned in the token register \cs{aeb@parsetoks}. Used in the arguments of such environments
% as \texttt{addJSToPageOpenAt} and \texttt{addJSToPageCloseAt}.
%    \begin{macrocode}
\def\aeb@exiii{\expandafter\expandafter\expandafter}
\let\ahrefexafter\aeb@exiii
\def\atPage#1{\@ifundefined{r@#1}{1}
    {\aeb@exiii\@secondoffive\csname r@#1\endcsname}}
\def\labelRef#1{\@ifundefined{r@#1}{Doc-Start}
    {\aeb@exiii\@fourthoffive\csname r@#1\endcsname}}
%    \end{macrocode}
%    \end{macro}
% The command \cs{aebp@rse} parses such arguments as
%\begin{verbatim}
%   {1,3,4-6,8-12,15,\atPage{firstlabel}-\atPage{secondlabel},30-}
%\end{verbatim}
% The expanded list is returned in the token register \cs{aeb@parsetoks}.
%    \begin{macrocode}
\newtoks\aeb@parsetoks
\newcount\aeb@parsecnt
\def\aeb@removelastcomma#1,\@nil{\aeb@parsetoks={#1}}
\def\aebp@rse#1{\aeb@parsetoks={}\aeb@parse#1,\relax}
\def\aeb@parse{\@ifnextchar\relax
    {\expandafter\aeb@removelastcomma\the\aeb@parsetoks\@nil}
    {\aeb@@parse}}
\def\aeb@@parse#1,{\aeb@@@parse#1-\@nil}
\def\aeb@@@parse#1-#2\@nil{%
    \def\argi{#2}\ifx\argi\@empty\def\aeb@next{\aeb@@@@parse{#1}}\else
        \def\aeb@next{\aeb@@@@@parse#1-#2}\fi\aeb@next
}
\def\aeb@@@@parse#1{%single page #1
    \aeb@parsecnt=#1
    \edef\edefaeb@parsetoks{\the\aeb@parsetoks\the\aeb@parsecnt,}%
    \aeb@parsetoks=\expandafter{\edefaeb@parsetoks}%
%    \par
    \aeb@parse}
\def\aeb@@@@@parse#1-#2-{\def\aeb@lowerlimit{#1}\def\aeb@upperlimit{#2}%
    % range argument from #1 to \csname aebLastPage\endcsname
    \ifx\aeb@upperlimit\@empty
        \@ifundefined{aebLastPage}{\aeb@parsecnt=#1}
            {\expandafter\aeb@parsecnt\expandafter=
                \csname aebLastPage\endcsname}%
    \else % page range #1 to #2, switch the two if #2 < #1
        \aeb@parsecnt=\aeb@lowerlimit
        \edef\aeb@lowerlimit{\the\aeb@parsecnt}
        \aeb@parsecnt=\aeb@upperlimit
        \ifnum\aeb@parsecnt<\aeb@lowerlimit\relax
            \aeb@parsecnt=\aeb@lowerlimit
            \def\aeb@lowerlimit{#2}%
            \def\aeb@upperlimit{#1}%
        \fi
    \fi
       \advance\aeb@parsecnt1
       \edef\aeb@upperlimit{\the\aeb@parsecnt}%
       \aeb@parsecnt=\aeb@lowerlimit
    \loop
        \edef\edefaeb@parsetoks{\the\aeb@parsetoks\the\aeb@parsecnt,}%
        \aeb@parsetoks=\expandafter{\edefaeb@parsetoks}%
        \advance\aeb@parsecnt1
    \ifnum\aeb@parsecnt < \aeb@upperlimit\repeat
%    \par
    \aeb@parse}
%    \end{macrocode}
% \section{Set Document Actions}
%    \begin{environment}{willClose}
%    \begin{environment}{willSave}
%    \begin{environment}{didSave}
%    \begin{environment}{willPrint}
%    \begin{environment}{didPrint}
% We add a \texttt{willClose} environment, not really meant for the document
% author to use. This environment is used with \cs{setDefaultFS} for saving
% setting and restoring the application preferences for full screen.
%    \begin{macrocode}
\newenvironment{willClose}
{\@defineJS{\will@Close}}
{\end@defineJS}
\let\will@Close=\@empty
\newenvironment{fs@willClose}
{\@defineJS{\fs@will@Close}}
{\end@defineJS}
\let\fs@will@Close\@empty
\newenvironment{willSave}
{\@defineJS{\will@Save}}
{\end@defineJS}
\let\will@Save=\@empty
\newenvironment{didSave}
{\@defineJS{\did@Save}}
{\end@defineJS}
\let\did@Save=\@empty
\newenvironment{willPrint}
{\@defineJS{\will@Print}}
{\end@defineJS}
\let\will@Print=\@empty
\newenvironment{didPrint}
{\@defineJS{\did@Print}}
{\end@defineJS}
\let\did@Print=\@empty
%    \end{macrocode}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
%    \end{environment}
% In addition to the provided environments, there are developer hooks, the package developer
% can use to insert page actions, in addition to what the package user may do.
% Now put the \texttt{willClose} JS into the document \texttt{Catalog}. The developer's
% actions will possibly overwrite that of the user; under the theory that the developer's
% actions are critical to the functioning of the package. The hooks are
%    \begin{macrocode}
\let\developer@will@Close\@empty
\let\developer@will@Save\@empty
\let\developer@did@Save\@empty
\let\developer@will@Print\@empty
\let\developer@did@Print\@empty
%    \end{macrocode}
%\changes{v0.8g}{2008/06/30}
%{
%   Added developer hooks to this open page events.
%}
%    \begin{macrocode}
\newcommand\@setDocActions{%
    \edef\test@will@Close{%
        \fs@will@Close\will@Close\developer@will@Close}%
    \edef\test@will@Save{\will@Save\developer@will@Save}%
    \edef\test@did@Save{\did@Save\developer@did@Save}%
    \edef\test@will@Print{\will@Print\developer@will@Print}%
    \edef\test@did@Print{\did@Print\developer@did@Print}%
\literalps@out{%
[ {Catalog} << /AA <<
   \ifx\test@will@Close\@empty\else/WC <<
        \JS{\fs@will@Close\will@Close\developer@will@Close} >>\fi
   \ifx\test@will@Save\@empty\else/WS <<
        \JS{\will@Save\developer@will@Save} >>\fi
   \ifx\test@did@Save\@empty\else/DS <<
        \JS{\did@Save\developer@did@Save} >>\fi
   \ifx\test@will@Print\@empty\else/WP <<
        \JS{\will@Print\developer@will@Print} >>\fi
   \ifx\test@did@Print\@empty\else/DP <<
        \JS{\did@Print\developer@did@Print} >>\fi
    >> >>
    /PUT pdfmark}%
}
\AtBeginDocument{\@setDocActions}
%    \end{macrocode}
% \section{In support of attachments}
%
% \subsection{Processing the \texttt{attachsource} and \texttt{attachments} key}
%
% If the value of either the \texttt{\texttt{attachsource}} or
% \texttt{attachments} keys are non empty, the values are contained
% in the macros \cs{aeb@attachsource} and \cs{aeb@attachments}. If
% either of these text macros is different from \cs{empty}, we need
% to write out a cut file that lists the requested attachments, then
% input the cut file back in at the end of the package.
%    \begin{macro}{\aref}
% This command, whose argument is \textit{delimited by parentheses},
% is to be used with \cs{inputDataObject}, defined below, to expand
% the value of the \texttt{cName} key, when the label is defined by
% \cs{labelName}. It is also used by this package to set the
% description of the attachment.
%    \begin{macrocode}
\def\aref(#1){\csname aeb@aName@#1\endcsname}
%    \end{macrocode}
%    \end{macro}
% The next command \cs{aeb@initAttachWrite} we prepare to write by opening a stream, and
% starting the \texttt{execJS} environment, but only if we have an attachment request.
%    \begin{macrocode}
\def\aeb@initAttachWrite{%
    \newwrite \aeb@attachmentswrite
    \immediate\openout \aeb@attachmentswrite \jobname_attach.cut
    \let\verbatim@out\aeb@attachmentswrite
% Old version that had problems when file name had characters in it that
% were not permitted for a JS variable.
%    \aeb@IWVO{\string\begin{execJS}{\jobname_attach}}%
    \aeb@IWVO{\string\begin{execJS}{aebpro_attach}}%
    {\lccode`P=`\{\lowercase{\aeb@IWVO{try P}}}%
}
%    \end{macrocode}
% If either the two attachments keys were used, execute \cs{aeb@initAttachWrite}.
%    \begin{macrocode}
\ifx\aeb@attachsource\@empty
    \ifx\aeb@attachments\@empty
    \else\aeb@initAttachWrite\fi
\else
    \@ifundefined{aeb@attachmentswrite}
    {\aeb@initAttachWrite}{}
\fi
%    \end{macrocode}
% If \cs{aeb@attachsource} is non empty, go through the comma delimited list, and write to the
% cut file we just opened.
%
%    \begin{macrocode}
\ifx\aeb@attachsource\@empty\else
    \edef\temp@expand{\noexpand\@for\noexpand\@@tmp:=\aeb@attachsource}
    \temp@expand\do
    {%
        \aeb@IWVO{\space\space\space\space\string\importDataObject({cName: "\jobname.\@@tmp", cDIPath: "\jobname.\@@tmp"});}%
        \expandafter\edef\csname aeb@aName@\@@tmp\endcsname{\jobname.\@@tmp}
    }
\fi
%    \end{macrocode}
% Similarly, if \cs{aeb@attachments} is non empty, go through the comma delimited list, and write to the
% cut file we just opened.
%
% The attachments are listing in a comma-delimited list. If there is a space following a comma, it may appear
% as part of the path of the next attachment. So, we'll get JavaScript to strip away any leading spaces to
% avoid the need to instruct the user to insert a \texttt{\%} if the attachment list is on multiple lines.
%    \begin{macrocode}
\def\jsstrsps{replace(/^\string\s*/, "")}
%    \end{macrocode}
%    \begin{macrocode}
\ifx\aeb@attachments\@empty\else
    \aeb@parsecnt=0
    \edef\temp@expand{\noexpand\@for\noexpand\@@tmp:=\aeb@attachments}
    \temp@expand\do
    {%
        \advance\aeb@parsecnt1
        \aeb@IWVO{\space\spac

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -