%% 1.2.95 (kamo)
%% Beim Schreiben des lab-Files wird der 4-te Parameter
%% (Ebene, f"ur die Map) nicht mit geschrieben.
%% 
%% 20.1.95 (kamo)
%% Trennzeichen im \special-Befehl durch \TRENNCHR ersetzt
%% Hyperlinks statt \fbox durch \underline gekennzeichnet.
%%
%% 18.12.96 tom
%% Neuer Schalter \newif\ifMbspmode
%% Ist dieser gesetzt, so wird ein anklickbares Beispiel nicht mit 
%% dem Unterstrich, sondern mit einer Box markiert. Dies wird vom
%% MuPAD Makroo \Mbsp genutzt.
%%
%% 24.9.96 ccr
%% Neuer Schalter \newif\ifiMmark
%% Wird von der Option nomark des Mhelp.sty auf false gesetzt, dann
%% werden hyperlinks einfach nur in einer \hbox, also als einfacher
%% Text ohne Markierung, innerhalb dessen aber Leerzeichen feste Breite
%% haben und kein Zeilenumbruch stattfinden kann, ausgegeben.
\def\TRENNCHR{|}


%% This is hypertex.sty by Jochen Hillebrand to use with Previewer
%% Hypertex, Version 2.1
%% error reports and suggestions to
%%      bicho@uni-paderborn.de
%%
%  This file defines the following commands :
%
%  \@@@nodelabel        \@putgiffile
%  \@@nodelabel         \@rspace
%  \@@@noderef
%  \@@noderef           \@setnode
%  \@@putgiffile        \@snodepageref
%  \@@subnode           \@subnode
%  \@arg                \hyp@depth
%  \@bnoderef           \hyp@height
%  \@checkmaplevel      \hyp@width
%  \@defaultmaplevel    \hyperclearpage
%  \@eqnnummem          \hyperpagebreak
%  \@getarg             \hytexpagesize
%  \@hyclp              \nc@nodelabel
%  \@hypaux             \newnodelabel
%  \@hyplab             \newsubnode
%  \@hyptmpa            \newsubnodelabel
%  \@hyptmpb            \nodelabel
%  \@hyptmpc            \nodepageref
%  \@hyptmpd            \noderef
%  \@hywarning          \putgiffile
%  \@hywsp              \putxpmfile
%  \@nodelabel          \subnode
%  \@noderef
%  \@nodemaplevel
%  \@nodename
%  \@nodetext
%  \@nodepageref
%
%  The following `if's are defined :
%
%  \if@qnnumr@f         \ifhytexwarnings
%  \ifhypermode
%
\def\fileversion{Version 2.1a}
\def\filedate{20 Jan 95, kamo}
\@ifundefined{@hypaux}{}{\endinput}
\typeout{Document Style Option `HyperTeX'
   \fileversion \space <\filedate>  (NK,TfS,JH)}
\newif\ifMbspmode\Mbspmodefalse
\newif\ifhytexwarnings\hytexwarningstrue
\def\@hywarning#1{%     created 20-9-93  JH
\ifhytexwarnings\typeout{>>HyTeX Warning: #1. (Input line \the\inputlineno)}\fi}
\RequirePackage{count1to}
\AtBeginDocument{\count1=1\relax}
%
\newif\ifhypermode
\newwrite\@hypaux
\newwrite\@hyplab
%
% Commands to open/close |\jobname.lab| and |\jobname.hyp| 
%
\def\HyTeXSetUp{%
   \ifhypermode{\immediate\openout\@hyplab=\jobname.lab\relax
      \immediate\openout\@hypaux=\jobname.hyp\relax}\fi}
\def\HyTeXSetDown{%    \immediate cut  15-9-93  JH
   \ifhypermode{\closeout\@hypaux\relax\closeout\@hyplab\relax}\fi}
%
% |hytexpagesize| sets the page's measures for the HyTeX previwer
%
\def\hytexpagesize{%
   \ifhypermode
      \topmargin -35mm
      \oddsidemargin -20mm
      \evensidemargin -20mm
      \textwidth 137mm
      \textheight 160mm\fi}
%
% The next two commands have their equivalents in |\pagebreak| and |\clearpage|
% with the difference that they only act if hypermode is true
%
\def\hyperpagebreak{%
   \ifhypermode\newpage\fi}
\def\hyperclearpage{%
   \ifhypermode\clearpage\fi}
%
% \nodepageref sets button with reference to node in toprow of previewer
% syntax : \nodepageref {<nodename>} {<label for button>}
% option |\nodepageref*| added on 10-9-93 to enable references to other
% HyTeX-files and system calls by dynamic buttons. (JH) Syntax :
%   \nodepageref* {<nodename>$<filename without suffix>}{<label for button>}| %$%
%   \nodepageref* {!<shell command>}{<label for button>}|
% \clearbuttons clears topline of previewer of any button that was
% previously set.
%
%bij% zur Vermeidung von Seiteneffekten bei der Parameter-Expansion
%bij% \immediate\write
\def\nodepageref{%
   \@ifstar{\@snodepageref}{\@nodepageref}}%
\def\@nodepageref#1#2{%
   \ifhypermode\@ifundefined{nr@#1}%
      {\@hywarning{nodepageref `#1' on page \thepage \space undefined}}%
      {\immediate\write\@hypaux{{\@arabic{\count1}}{#2}%
                                {\expandafter\@nameuse{nr@#1}}}}\fi}%
\def\@snodepageref#1#2{%
   \ifhypermode\immediate\write\@hypaux{{\number\count1}{#2$#1}{-2}}\fi}%$%
\def\clearbuttons{%
   \ifhypermode\immediate\write\@hypaux{{\number\count1}{!clear}{1}}\fi}%
%
% \newnodelabel, \newsubnodelabel and \newsubnode are internal commands
% the user doesn't need to make use of.
%
\def\newnodelabel#1#2#3#4{%
   \ifhypermode\global\@namedef{nr@#1}{#2}%
   % changed kamo (1.2.95)
   % The fourth operand won't be used anymore (no map)
   %\write\@hyplab{{#2}{#1}{#3}{#4}}\fi}
   \write\@hyplab{{#2}{#1}{#2}}\fi}%
\def\newsubnodelabel#1#2#3#4{%
   \ifhypermode\global\@namedef{nr@#1}{#2}%
   % changed kamo (1.2.95)
   % The fourth operand won't be used anymore (no map)
   %\write\@hyplab{{#2}{^#1}{#3}{#4}}\fi}
   \write\@hyplab{{#2}{#1}{#2}}\fi}%
\let\newsubnode\newsubnodelabel
%
% Commands \nodelabel and \subnode: They set nodes in a HyTeX-document.
% Syntax: \nodelabel {<nodename>} and \subnode {<nodename>}
% \nodelabel should be followed by an 'official' LaTeX sectioning-command as
% for example \chapter, \section or \subsection. If not, a warning will appear,
% and level and label of the node will be set to default values.
% Option \subnode* makes \subnode behave like \nodelabel, with the difference,
% that there will be no \clearpage.
% last changes : 21- 4-94       JH
%
\def\nodelabel{%
 \gdef\@nodetype{nodelabel}\global\let\@hyclp\clearpage\def\@hywsp{\space}%
 \@ifundefined{chapter}{\gdef\@defaultmaplevel{s}}{\gdef\@defaultmaplevel{c}}%
 \@ifnextchar[{\@nodelabel}{\@nodelabel[\relax]}}%
\def\@nodelabel[#1]{%
  \if\relax#1\global\let\@nodetext=\relax\else\gdef\@nodetext{#1}\fi%
  \@ifnextchar({\@@nodelabel}{\@@nodelabel(\relax)}}%
\def\@@nodelabel(#1)#2{%
  \let\@hyptmpa\@@@nodelabel\@ifundefined{nn@#2}{\global\@namedef{nn@#2}{defined}}%
   {\global\let\@hyptmpa\relax\@hywarning{Node `#2' multiple defined}}%
  \if\relax#1\global\let\@nodemaplevel\relax\else\gdef\@nodemaplevel{#1}\fi%
  \gdef\@nodename{#2}\@hyptmpa}%
\def\@@@nodelabel#1{%   created 20-9-93 JH
 \ifhypermode\@hyclp\gdef\@arg{#1}%
  \def\@hyptmpa{\@setnode\@arg}%
  \ifx#1\part\def\@hyptmpb{p}%
  \else\ifx#1\chapter\def\@hyptmpb{c}%
  \else\ifx#1\section\def\@hyptmpb{s}%
  \else\ifx#1\subsection\def\@hyptmpb{ss}%%
  \else\ifx#1\subsubsection\def\@hyptmpb{sss}%
  \else\@ifundefined{@nodemaplevel}%
    {\global\let\@nodemaplevel\@defaultmaplevel\def\@hyptmpc%
     {\@hywarning{No sectioning command after \@nodetype\@hywsp`\@nodename'}}}%
    {\let\@hyptmpc\relax}%
   \@ifundefined{@nodetext}{\global\let\@nodetext\@nodename\def\@hyptmpc%
     {\@hywarning{No sectioning command after \@nodetype\@hywsp`\@nodename'}}}{}%
  \@hyptmpc\fi\fi\fi\fi\fi%
  \@ifundefined{@nodemaplevel}{\global\let\@nodemaplevel\@hyptmpb}{}%
  \@checkmaplevel\@ifundefined{@nodetext}{\def\@hyptmpa{\@getarg}}{}%
 \else\def\@hyptmpa{#1}\fi\@hyptmpa}%
\def\@getarg#1{%
 \def\@hyptmpa{#1}\def\@hytmpb{*}\def\@hytmpc{[}%
 \ifx\@hyptmpa\@hytmpb%
  \def\nc@nodelabel##1{\gdef\@nodetext{##1}\@arg*{##1}\@setnode}%
 \else\ifx\@hyptmpa\@hytmpc%
   \def\nc@nodelabel##1]##2{\gdef\@nodetext{##1}\@arg[##1]{##2}\@setnode}%
  \else\def\nc@nodelabel{\gdef\@nodetext{#1}\@arg{#1}\@setnode}\fi\fi%
 \nc@nodelabel}%

\def\subnode{%
 \gdef\@nodetype{subnode}\global\let\@hyclp\relax\def\@hywsp{*\space}%
 \gdef\@defaultmaplevel{sss}\@ifstar%
  {\@esphack\@ifnextchar[{\@nodelabel}{\@nodelabel[\relax]}}%
  {\@ifnextchar[{\@subnode}{\@subnode[\relax]}}}%
\def\@subnode[#1]{%
 \if\relax#1\gdef\@nodetext{\@nodename}\else\gdef\@nodetext{#1}\fi%
 \@ifnextchar({\@@subnode}{\@@subnode(sss)}}%
\def\@@subnode(#1)#2{%
 \ifhypermode\@ifundefined{nn@#2}{\gdef\@nodemaplevel{#1}\gdef\@nodename{#2}%
   \@checkmaplevel\@setnode\global\@namedef{nn@#2}{defined}}%
  {\@hywarning{Node `#2' multiple defined}}\fi}%

\def\@setnode{%                         last changes : 21-12-93 JH
  \@bsphack\if@filesw\xdef\@hyptmpb{%
    \immediate\write\@auxout{\expandafter\string\csname new\@nodetype\endcsname{\@nodename}%
                    {\number\count1}{\@nodetext}{\@nodemaplevel}}}%
    \@hyptmpb\if@nobreak\ifvmode\nobreak\fi\fi\fi\@esphack}%
\def\@checkmaplevel{%%
 \def\@hyptmpb{p}\ifx\@hyptmpb\@nodemaplevel\else%
  \def\@hyptmpb{c}\ifx\@hyptmpb\@nodemaplevel\else%
   \def\@hyptmpb{s}\ifx\@hyptmpb\@nodemaplevel\else%
    \def\@hyptmpb{ss}\ifx\@hyptmpb\@nodemaplevel\else%
     \def\@hyptmpb{sss}\ifx\@hyptmpb\@nodemaplevel\else%
      \def\@hyptmpb{n}\ifx\@hyptmpb\@nodemaplevel\else%
       \@hywarning%
        {Illegal level `\@nodemaplevel' for node `\@nodename' on page \thepage}%
        \global\let\@nodemaplevel\@defaultmaplevel\fi\fi\fi\fi\fi\fi}%
%
% The \noderef command sets a referencemark to a node in current text.
% Syntax : \noderef{<nodename>}{<text>}
% `text' will appear in a fbox, so there will be no linebreak within that box!
% options: (see manuals for further information)
% - A star after the command will omitt warnings.
% - An exclamationmark at beginning of argument 1 will execute argument 1 as a
% shell command.
% - ?? fter nodename followed by documentname sets reference to that
% HyTeX-document. Changed from :: to ?? bei tom  01.06.97
% - (<dimension>,<dimension>,<dimension>) between arg1 and arg2 will set 
% surrounding fbox to (width, height, depth)
% - to `activate' equationnumbers, put \noderef {<nodename>} {} before \\ or
% end of line.
% last changes : 18- 4-93       JH
%
\newcount\hyp@height
\newcount\hyp@depth
\newcount\hyp@width
\newdimen\@rspace\global\@rspace\z@
\newdimen\@noderefdep
\newif\if@qnnumr@f\@qnnumr@ffalse

\def\noderef{%
\gdef\@shsp{hyp}%
\let\@hyptmpd\ifhytexwarnings\@ifstar{\hytexwarningsfalse\@noderef}%
{\@noderef}}

\def\@noderef#1{%
 \hskip\z@%
 \@ifnextchar({\@bnoderef{#1}}{\@@noderef{#1}}}%

\def\@bnoderef#1(#2,#3,#4)#5{%
 \@bsphack\setbox0\hbox{#5}\@esphack%
 \ifdim\wd0<#2\wd0=#2\fi\ifdim\ht0<#3\ht0=#3\fi\ifdim\dp0<#4\dp0=#4\fi%
 \@@@noderef{#1}{\box0}}%

\def\@@noderef#1#2{%
        \setbox0\hbox{#2}%
        \@noderefdep=\dp0%
        \@tempdima=\wd0%
        \ifMbspmode\else\dp0=0pt\fi%
        \setbox0\hbox{\@@@noderef{#1}{\box0}}%
        \ifdim\dp0<\@noderefdep\dp0=\@noderefdep\fi%
        \wd0=\@tempdima%
        \box0 %
}

\def\@@@noderef#1#2{%
\ifhypermode\@ifundefined{nr@#1}{\@hywarning{noderef `#1' on page \thepage \space undefined}}{}\ifmmode\global\setbox1\hbox{$\@ifstar{}{\displaystyle}#2$}%
\else\setbox1\hbox{#2}\fi%
\ifdim\wd1=\z@%
   \gdef\@eqnnum{\noderef{#1}{\rm (\theequation)}\hskip -4pt%
            \global\let\@eqnnum\@eqnnummem}%
\else\ifiMmark\ifMbspmode\@bsphack\setbox0\hbox{\strut\fbox{\box1}}%TOM
\else\@bsphack\setbox0\hbox{\strut\underline{\box1}}\fi%TOM
\else\@bsphack\setbox0\hbox{\strut\box1}\fi%ccr
\hyp@height=\ht0\hyp@depth=\dp0\hyp@width=\wd0%
\special{\@shsp\TRENNCHR\copy0\TRENNCHR#1\TRENNCHR\the\hyp@height \TRENNCHR\the\hyp@depth \TRENNCHR\the\hyp@width}%
\@esphack\box0 \fi\else\@ifstar{}{}#2\fi\let\ifhytexwarnings\@hyptmpd}

\def\shellref{%
\gdef\@shsp{shc}%
\let\@hyptmpd\ifhytexwarnings\global\hytexwarningsfalse\@noderef}

\def\xvref{%
\gdef\@shsp{xxv}%
\let\@hyptmpd\ifhytexwarnings\global\hytexwarningsfalse\@noderef}

\def\videoref{%
\gdef\@shsp{vid}%
\let\@hyptmpd\ifhytexwarnings\global\hytexwarningsfalse\@noderef}

\def\audioref{%
\gdef\@shsp{aud}%
\let\@hyptmpd\ifhytexwarnings\global\hytexwarningsfalse\@noderef}
%
% should insert this \let in case of `private' definition of the equationcounter
% to recover previous definition after use of \noderef in equation or eqnarray
% environment. 
%
\let\@eqnnummem\@eqnnum
%
% \putgiffile is a HyTeX command that puts a GIF graphic in current text.
% syntax : \putgiffile {<filename>} (<width>,<height>,<depth>)
% filname has to be the name of the file, without path; height, depth and width
% determine height, depth and width of the box for the graphic.
% \special command expands to {gif:<filename>:<width>:<depth>:<height>}
% created : 25-11-93            JH
% last changes : 26-11-93       JH
%
\def\putgiffile{%
 \@ifstar{\@@putgiffile}{\@putgiffile}}
\def\@putgiffile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putgiffile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{gif\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\hbox{\box1}\fi}
\def\@@putgiffile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putgiffile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{gif\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\fi}
%
%
\def\putxpmfile{%
 \@ifstar{\@@putxpmfile}{\@putxpmfile}}
\def\@putxpmfile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putxpmfile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{xpm\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\hbox{\box1}\fi}
\def\@@putxpmfile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putxpmfile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{xpm\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\fi}
%
%
\def\putxbmfile{%
 \@ifstar{\@@putxbmfile}{\@putxbmfile}}
\def\@putxbmfile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putxbmfile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{xbm\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\hbox{\box1}\fi}
\def\@@putxbmfile#1(#2,#3,#4){%
 \ifhypermode\ifvmode\noindent\fi
  \setbox0\hbox{$#1$}
  \ifdim\wd0=\z@
  \@hywarning{No file named for \string\putxbmfile{} on page \thepage}\fi
  \setbox0\hbox{}\ht0=#3\dp0=#4\wd0=#2\setbox1\hbox{\box0}
  \hyp@height=\ht1\hyp@depth=\dp1\hyp@width=\wd1%
  \special{xbm\TRENNCHR#1\TRENNCHR\the\hyp@height\TRENNCHR\the\hyp@depth\TRENNCHR\the\hyp@width}\fi}
%
\endinput
%% 
%% End of file `hypertex.sty'.
