% hevea macros for swp usage HTML TRANSLATION
% call hevea with
% hevea swp.hva -e tcilatex.tex myfile
% or the general cover function hhtml myfile

enable internal hevea support
\@primitives{sword}



% The \FRAME macro
% ================
%
% What happens is that the lexer extracts the base filename
% from arg 8 of FRAME, and then passes the result to a macro
% \swFRAME.
% \swFRAME is given below: you can alter it to suit.
% If you revise it you must make the definition using \renewcommand
% since the construct has already been defined in hevea.hva :
% if you use \def it will be ignored.
%
% The default SWP handling writes an IMG tag using the extension
% \swEXT, which you can also change.
%
\renewcommand{\swEXT}[1]{.gif}  %graphics extension
\renewcommand{\swFRAME}[1]{\@print{<IMG SRC="}#1\swEXT
\@print{" ALT="Graphic: }#1\swEXT\@nostyle{\@print{">}}}


% The \includegraphics macro (portable LaTeX)
% ===========================================
%
% We make the \includgraphics macro refer to \FRAME
% with 7 dummy arguments and one real one - the 8th
% the optional argument (in []) to includegraphics is ignored
% note that the last arg must be in single quotes
% because that's what \FRAME expects
\newcommand{\includegraphics}[2][xxx]{\FRAME{1}{2}{3}{4}{5}{6}{7}{'#2'}}


% The QTP macro
% =============
%
% This works only in Hevea 1.05+ and I'm not completely sure it's correct
%
% In a structure like
% \QTP{#1} #2
% the idea is that \QTP will define another macro, whose name
% is \#1. The new macro is supposed to see as its argument the
% following word, ie #2. This is a TeX-ism, and not a LaTeX macro:
% LaTeX would put the argument in braces. That's why it's delicate.
%
% Consider
%
% \QTP{preface} PREFACE
%
% (where "Preface" may be on the next line)
% We need to define a macro called \preface whose argument is to be
% the next word, ie PREFACE. The only way to define this macro is as follows:
%
% \def\preface#1#2 {\section*{#1#2}}
%
% (of course, \section* can be any LaTeX macro).
% THE SPACE FOLLOWING #2 IN THE DEFINITION IS VITAL -
% IT IS PRECISELY THIS WHICH MAKES THE DEFINITION WORK.
% If you omit it, you will get a peculiar result: only the
% first character of the following word is taken to be the argument
% So what you'd see is that the letter "P" would be a section heading
% and "REFACE" would be an ordinary word. If you get this, review the
% structure of your defining macro.
%
% OK, now's the formal definition of \QTP
\def\QTP#1#2{\csname #1\endcsname #2}


% Other macros
% ============


% some non-handled macros - you may want to change these
\def\negthinspace{}
\def\hfill{}
\def\hrulefill{}
\def\dotfill{}
\def\strut{}
\def\mathstrut{}
\def\allowbreak{}

%  these are from tcilatex.tex
\newcommand{\CustomNote}[3][]{\marginpar{#3}}
\def\TCIIcon#1#2#3#4{\relax}
\def\qExtProgCall#1#2#3#4#5#6{\relax}

\newenvironment{mathletters}{}{}
\def\tag#1{\quad{(#1)}}
\def\tag*#1{\quad{#1}}
\def\notag{}
\def\TCItag{}
\def\TCItag*{}
\def\frame{}

% a Style Editor document can insert the \BodyTextFont macro into the .aux file
\def\BodyTextFont{\relax}

% GENERALIZED BINOMIALS
% =====================
% \QOVERD is actually a generalized fraction in large deliminters
% \QATOPD is the generalized binomial with large delimiters
% There's no problem with displays: the difficulty is to get an acceptable
% inline representation, where tables aren't available.  I think the solution 
% here is reasonable, but you may want to make your own. 
% This solution will probably have problems with more complicated arguments.
% In not-display, note the space before #3 and after #4.
% also, note the use of entity 151 (ie &#151;) in the display generalized fraction.
\def\QOVERD#1#2#3#4{%
\ifdisplay
{%
\@print{<TABLE rows="3" cols="3"><tr><td rowspan="3"><font size="7">}#1%
\@print{</font></td><td align="center" >}#3%
\@print{</td><td rowspan=3 ><font size="7">}#2%
\@print{</font></td></tr><tr><td height="3">&#151;</td></tr><tr><td align="center">}#4%
\@print{</td></tr></table>}}
\else
{#1\@print{<sup>} #3\@print{</sup><sub>}#4 \@print{</sub>}#2}
\fi
}
\def\QATOPD#1#2#3#4{%
\ifdisplay
{%
\@print{<TABLE rows="2" cols="3"><tr><td rowspan="2"><font size="6">}#1%
\@print{</font></td><td align="center">}#3%
\@print{</td><td rowspan="2"><font size="6">}#2%
\@print{</font></td></tr><tr><td align="center">}#4%
\@print{</td></tr></table>}
}
\else
{#1\@print{<sup>} #3\@print{</sup><font size="+1">/</font><sub>}#4 \@print{</sub>}#2}
\fi
}

\def\binom#1#2{\QATOPD ( ) #1 #2}

% as of hevea 1.04, we understand the csname construction
\def\QTR#1#2{\csname#1\endcsname #2}

\let\RequirePackage\usepackage
\newcommand{\url}[1]{\texttt{#1}}

% this may not be the best solution
\renewcommand{\newline}{\@print{<BR>}}

\def\vert{|}

% this is a matter of taste
\def\thinspace{ }


% the problem with the "prime" in the symbol font
% is that it is very small. The alternative def tries to
% compensate by upping the size. You might also try +2 here
\def\prime{\ensuremath{'}}
%\def\prime{\@print{<font size=+1>}\ensuremath{'}\@print{</font>}}


\def\TEXTsymbol#1{\mbox{$#1$}}%
\def\text#1{\textrm{#1}}

\renewcommand\evensidemargin{}
\renewcommand\oddsidemargin{}
\def\textwidth{}

% the unit construct - just print the argument, but ensure text
% if you want it to look like SWP's screen you could make it print in green
\newcommand{\unit}[1]{\textrm{#1}}

% contructs mapped to footnotes
\let\marginpar\footnote

% dotless j to regular versions (dotless i is already provided)
\def\j{j}


% varepsilon - print it as epsilon - again you may want to
% change this, eg make it a different color
\let\varepsilon=\epsilon


% TCI's hyperref - Note that this is set up for SWP4 and must be changed to 
% define the \hyperref macro (no \msihyperref) for earlier versions
% note that we ignore the before and after text
\def\msihyperref#1#2#3#4{\@print{<A HREF="}#4\@print{">}#1\@print{</A>}}
\AtBeginDocument{\@ifundefined{hyperref}{\let\hyperref=\msihyperref}{}}


% two comment environments
\newenvironment{comment}{\begin{latexonly}}{\end{latexonly}}
\newenvironment{Comment}{\begin{latexonly}}{\end{latexonly}}

% blackboard-bold font: we handle this by making it sans-serif, red
% you may want to provide a different solution
\def\Bbb#1{\textsf{\red{#1}}}
\def\Bbbk{\textsf{\red{k}}}


% support for the SWP 2 TeXButton construct
% just ignore the name of the button and execute whatever's in
% the second argument.
\newcommand{\TeXButton}[2]{#2}

% UNICODE SUPPORT
% ========================================
%
% \UNICODE is internal to Hevea
% the \U macro adds "0x" as a prefix, and calls \UNICODE
\def\U#1{\UNICODE{0x#1}}

% \swUNICODE gives you (1) the unicode number in hex and (2) in decimal
% note that you need to format either appropriately. See below where
% we use only the decimal version since most browsers don't suppport hex
\newcommand{\swUNICODE}[2]{\@nostyle{\@print{&#}}#2;}

% SWP 40
% =================
%
% SWP40 seems to introduce macros for these constructs rather than handling them 
% as extended keyboard sequences
\newcommand\textquotedblleft{\@print{``}}
\newcommand\textquotedblright{\@print{''}}
\newcommand\textemdash{\@print{---}}

