% This is a LaTeX style file for dviout special `input (Ver.3.16.1 and after) % Ver.0.5 % Written by hoda, misc, SHIMA % February 25, 2006 % % \usepackage[]{keyin} % % Options: Ktrue(*) \K{\K} is valid % Kfalse \K{\K} is not valid (interpreted as ) % Kfalseall Same as Kfalse but \Ktrue does not work % Kmeaning(*) Use \K{\K} in Kmeaning-mode (see below) % Kverb Use \K{\K} in Kverb-mode (see below) %                 (*)--default % keyin(*) \keyin is valid % nokeyin \keyin is invalid % % % \keyin{}{} % : The string to be copied to Clipboard when the hot spot is % clicked. % Two hexadecimal characters (0,1,...,9,A,...,F,a,...,f) following % one space character are translated into one character with the % corresponding code. % Two adjacent space characters are translated into one space % character. % If the top character is "." and two hexadecimal characters % followed after it, they are translated into one character with % the code. % If the top two characters are "..", they are translated into % ".". % : Hot spot in the dvi file. % % This command is interpreted as % % \special{html: is never expanded. But if it is used in some macro, % will be expanded in the usual way. % % % \K{\K} % This is similar to \keyin{}{} but the translations % mentioned above are ignored. % This is useful when one is writing a source file of TeX with complex % formulas or equations. For example, use % % \usepackage{keyin} % % when the corresponding source file is edited. In the final version use % % \usepackage[Kfalse]{keyin} % % or change \K{ and \K} into spaces by an Editor. % The function of \K{\K} is also switched on and off by \Ktrue % and \Kfalse in the document area. % \K{\K} has two different modes: `Kmeaning', `Kverb'. These modes % are changed by \Kmeaning and \Kverb. % % Kmeaning-mode: % Adjusted form of is copied to Clipboard. \K{, \K} in comment % area are ignored. \K{\K} can be used inside any other macro. % % Kverb-mode: % CR/LF/SPACE/TAB in is copied verbatim to Clipboard. % \K} in comment area are counted and extra \K} are ignored. % For example, if the source is % % \K{ \K{ x \K} % y \K} z % % then the string to be copied is " \K{ x \K} % y ". % \K{\K} CAN NOT BE USED inside any other macro. % % (eg.) AMSLaTeX environment: equation, aligned, gathered -> OK % align, multline, gather,... -> not OK % % % \begin{prototype}\end{prototype} % This is almost the same as {\K{\K}} in Kverb-mode but it ignores % comment area. \end{prototype} can not be replaced by \end {prototype} nor % \end{ prototype } etc.. % % % \Ksetext{} % \K{\K} in Kverb-mode and `prototype' environment use an extra % output file. \Ksetext{} set the extension of this file (=`key' % by default). % % % \newif\if@K@command \newif\if@K@falseall \newif\if@K@verb \newif\if@K@keyin \DeclareOption{Kfalseall}{\@K@falsealltrue\@K@commandfalse} \DeclareOption{Kfalse}{\@K@commandfalse} \DeclareOption{Ktrue}{\@K@commandtrue} \DeclareOption{Kverb}{\@K@verbtrue} \DeclareOption{Kmeaning}{\@K@verbfalse} \DeclareOption{keyin}{\@K@keyintrue} \DeclareOption{nokeyin}{\@K@keyinfalse} % \ExecuteOptions{Ktrue,Kmeaning,keyin} \ProcessOptions\relax \def\Kfalse{\global\@K@commandfalse} \def\Ktrue{\if@K@falseall\else\global\@K@commandtrue\fi} \def\Kmeaning{\global\let\K=\m@K} \def\Kverb{\global\let\K=\v@K} % \def\K@ext{key} \def\Ksetext#1{\gdef\K@ext{#1}} \newwrite\@key@file % % definition of `\keyin', `\verbkeyin' ------------------------ {% \@makeother\^^M% \@makeother\^^J% \gdef\@dosrtn{^^M^^J}% return of DOS \gdef\K@otherM{^^M}% } { \catcode`\^^M=\active% \gdef\@ctivate@rtn{% \@makeother\^^I% tab \catcode`\^^M=\active% \def^^M{\@dosrtn}% }% \gdef\re@l@rtn{% \def^^M{\K@otherM}% \newlinechar=\endlinechar% }% } % \keyin \def\keyin{\leavevmode\begingroup\@sanitize% \@ctivate@rtn\@keyin} \if@K@keyin \def\@keyin#1{\special{html:}\endgroup\@@keyin} \def\@@keyin#1{#1\special{html:}} \else \def\@keyin#1{\endgroup\@@keyin} \def\@@keyin#1{#1} \fi % \verbkeyin \def\verbkeyin{\leavevmode\begingroup\@sanitize% \@ctivate@rtn\@verbkeyin} \if@K@keyin \def\@verbkeyin#1{\special{html:}\endgroup\@@keyin} \else \def\@verbkeyin#1{\endgroup\@@keyin} \fi % % ------------------------ internal tools ------------------------ % % \K@aplyproctolist#1#2#3 % #1: #2: #3: % \Kexit: exit from the loop \newif\if@K@exit \def\Kexit{\global\@K@exittrue} \def\K@aplyproctolist#1#2#3{% {% \def\aplyproctoitm##1#3##2\@nil{% #1{##1}% \if@K@exit% \def\nxt@todo{\global\@K@exitfalse}% \else% \def\rstlist{##2}% \ifx\rstlist\@empty% \let\nxt@todo=\relax% \else% \def\nxt@todo{\aplyproctoitm##2\@nil}% \fi% \fi% \nxt@todo% }% \global\@K@exitfalse% \aplyproctoitm#2#3\@nil% }% }% % % \K@warning \def\K@warning#1{\typeout{ at l.\the\inputlineno:}% \typeout{#1}} % % \K@chk@incmt \newif\if@K@incmt { \catcode`/=0 /catcode`/\=12 /global/def/K@bs@char{\} /catcode`/^^M=/active% /gdef/K@chk@incmt#1^^M#2/@nil{% /let/nxt@todoc=/relax% /def/rst@lin{#2}% /ifx/rst@lin/@empty% /if@K@incmt/else% /K@aplyproctolist/K@rmvesccmt{#1}{\\}% /fi% /else% /global/@K@incmtfalse% /def/nxt@todoc{/K@chk@incmt#2/@nil}% /fi% /nxt@todoc% }% /catcode`/*=14% /@makeother/%* /gdef/K@rmvesccmt#1{* /K@aplyproctolist/K@chkcmtchar{#1}{\%}* /if@K@incmt/Kexit/fi* }* /gdef/K@chkcmtchar#1{* /K@@chkcmtchar#1%/@nil* }* /gdef/K@@chkcmtchar#1%#2/@nil{* /def/rst@lin{#2}* /ifx/rst@lin/@empty/else* /global/@K@incmttrue/Kexit* /fi* }* } % % \Kcmtchkr \def\Kcmtchkr{% \K@warning{I misjudged this place would be in comment area!}% } % % \K@wrtkeyfile \def\K@wrtkeyfile#1{% \immediate\openout\@key@file=\jobname.\K@ext\relax% {% \re@l@rtn% \immediate\write\@key@file{#1}% }% \immediate\closeout\@key@file% }% % \K@execkeyblk \def\K@execkeyblk{% \endgroup% \global\@K@topfalse% \input{\jobname.\K@ext}% \global\@K@toptrue% \special{html:}% } % { % `%' of catcode 12 \@makeother\% \gdef\K@cmt@char{%} } % `{', `}' -> catcode 12 \def\@other@enb{% \@makeother\{% \@makeother\}% } % % definition of environment `prototype' ------------------------ \newif\if@K@top \@K@toptrue \newcounter{prot@depth} % \newenvironment{prototype}{% \leavevmode% \let\nxt@todo=\relax% \if@K@top% \if@K@command% \begingroup% \@sanitize\@ctivate@rtn\@other@enb% \setcounter{prot@depth}{1}% \global\@K@incmtfalse% \def\nxt@todo{\wrt@protostr{}}% \fi% \fi% \nxt@todo% }{} { \catcode`\[=1 \catcode`\]=2 \@makeother\{ \@makeother\} \catcode`/=0% \catcode`/^^M=\active% /catcode`/\=12% % get the whole text before the corresponding `\end{prototype}' /gdef/wrt@protostr#1#2\end{prototype}[% /K@aplyproctolist/K@cnt@vldbgn[#2][\begin{prototype}]% /if@K@incmt% /def/nxt@todo[/wrt@protostr[#1#2\end{prototype}]]% /else% /addtocounter[prot@depth][-2]% /ifnum/value[prot@depth]=0% /special[html:]% /K@wrtkeyfile[#1#2/K@cmt@char]% /K@execkeyblk% /def/nxt@todo[/end[prototype]]% /else% /def/nxt@todo[/wrt@protostr[#1#2\end{prototype}]]% /fi% /fi% /nxt@todo% ]% /gdef/K@cnt@vldbgn#1[% /K@chk@incmt#1^^M/@nil% /if@K@incmt/else% /stepcounter[prot@depth]% /fi% ]% ] % definition of `\K{ ... \K}' ------------------------ % % ------------ Kmeaning-mode ------------ \long\def\m@K#1{\m@@K#1\@nil} \long\def\m@@K#1\K\@nil{% \if@K@command% \if@K@top% \leavevmode% \def\@keyin@temp{#1}% \@onelevel@sanitize\@keyin@temp% \special{html:}% \global\@K@topfalse% #1% \global\@K@toptrue% \special{html:}% \else% #1% \fi% \else% #1% \fi% } % % ------------ Kverb-mode ------------ \newcounter{K@depth} % \outer\def\v@K{% \leavevmode% \begingroup% \@other@enb% \K@enb% } % { \catcode`\[=1 \catcode`\]=2 \@other@enb% \catcode`/=0 \catcode`/^^M=\active% /catcode`/\=12% % /gdef/K@enb#1[% /def/nxt@todo[/endgroup]% /if {#1% /if@K@top% /if@K@command% /setcounter[K@depth][1]% /global/@K@incmtfalse% /@sanitize/@ctivate@rtn% /def/nxt@todo[/v@@K[]]% /fi% /fi% /else% /if }#1/else% /errmessage[\K must be followed by { or }]% /fi% /fi% /nxt@todo% ]% % /gdef/v@@K#1#2\K#3[% /K@chk@incmt#2^^M/@nil% /if }#3% /addtocounter[K@depth][-1]% /ifnum/value[K@depth]=0% /special[html:]% /if@K@incmt% /K@wrtkeyfile[#1#2/K@bs@char Kcmtchkr]% /def/nxt@todo[/K@skipaftr]% /else% /K@wrtkeyfile[#1#2/K@cmt@char]% /def/nxt@todo[/K@execkeyblk]% /fi% /else% /def/nxt@todo[/v@@K[#1#2\K#3]]% /fi% /else% /def/nxt@todo[/v@@K[#1#2\K#3]]% /if@K@incmt% /ifcat /noexpand#3/noexpand^^M% /@K@incmtfalse% /fi% /else% /if {#3% /stepcounter[K@depth]% /else% /ifcat /noexpand#3a/else% /errmessage[\K must be followed by { or }]% /fi% /fi% /fi% /fi% /nxt@todo% ]% /gdef/K@skipaftr#1^^M[/K@execkeyblk]% ] % \if@K@verb \Kverb \else \Kmeaning \fi