%%%% Une précaution.
\ifhtml\else\warning{html/hevea is for html mode !!!}\endinput\fi
%%%% package used by all packages
\input{plain.hva}
\newif\ififthen\ifthenfalse
\input{ifthen.hva}
%% Packages
\input{packages.hva}
%%%%%% Spacing
\input{spaces.hva}
%%% \... symbols renderered with iso-latin1
\input{iso-symb.hva}
\renewcommand{\&}{\ifraw\@print{&}\else\@print{&amp;}\fi}
\input{latexcommon.hva}
%%% Logos
\def\TeX{\@print{TeX}}
\def\LaTeX{\@print{L<sup>A</sup>T<sub>E</sub>X}}
\def\LaTeXe{\mbox{\@print{L<sup>A</sup>T<sub>E</sub>X}~$2\epsilon$}}
\newcommand{\hevea}{\@print{H}{\@incsize{-1}\@print{<sup>E</sup>}}\@print{V}%
{\@incsize{-1}\@print{<sup>E</sup>}}\@print{A}}
\newcommand{\hacha}{\@print{H}{\@incsize{-1}\@print{<sup>A</sup>}}\@print{C}%
{\@incsize{-1}\@print{<sup>H</sup>}}\@print{A}}
\newcommand{\html}{HTML}
%%% HTML related stuff (TEX equivalents are in the hevea.sty file)
\newcommand{\@doaelement}[2]
{{\@nostyle\@print{<A }\@getprint{#1}\@print{>}}{#2}{\@nostyle\@print{</A>}}}
\newcommand{\@nestedaelement}[2]{\warning{Suppressing nested A element}#2}
\newcommand{\@aelement}[2]
{\bgroup\let\@aelement\@nestedaelement\@doaelement{#1}{#2}\egroup}
\newcommand{\ahref}[2]{\@aelement{HREF="#1"}{#2}}
\def\ahrefurl#1{\@aelement{HREF="#1"}{\texttt{#1}}}
\let\footahref\ahref
\newcommand{\mailto}[1]{\@aelement{HREF="mailto:#1"}{#1}}
\newcommand{\imgsrc}[2][]
{\@print{<IMG SRC="}\@getprint{#2}\ifpedantic\@print{" ALT="}\@getprint{#2}\fi
\ifthenelse{\equal{#1}{}}{\@print{"}}{\@print{" }\@getprint{#1}}\@print{>}}
%% Hyper-text references inside the document, internal usage
\newcommand{\@locref}[2]{\@aelement{HREF="\@print{#}#1"}{#2}}
\newcommand{\@locname}[2]{\@aelement{NAME="#1"}{#2}}
\newcommand{\@locnameref}[3]{\@aelement{NAME="#1" HREF="\@print{#}#2"}{#3}}
%% Two exported commands
\let\ahrefloc\@locref
\let\aname\@locname
\newcommand{\anchor}[1]{\@locname{#1}{}}
%% Html footer, header and prefix for titles
\newsavebox{\@htmlhead}
\newsavebox{\@htmlfoot}
\newsavebox{\@htmlprefix}
\newcommand{\htmlhead}[1]{\sbox{\@htmlhead}{#1}}
\newcommand{\htmlfoot}[1]{\sbox{\@htmlfoot}{#1}}
\newcommand{\htmlprefix}[1]{\sbox{\@htmlprefix}{#1}}
\AtEndDocument
{{\@nostyle\@print{<!--HTMLFOOT-->
}}%
\usebox{\@htmlfoot}%
{\@nostyle\@print{<!--ENDHTML-->
}}}
%%%%% Footnotes, html dependant part
\newcommand{\@noteref}[4]{\@locnameref{#2#3}{#1#3}{#4}}
\newcommand{\@notetextstyle}[1]
  {{\@clearstyle\normalfont$^{\mbox{#1}}$}}
\newcommand{\@notenotestyle}[1]
  {{\@clearstyle\Large{}#1}}
\newenvironment{thefootnotes}[1]
  {{\@nostyle\@print{<!--BEGIN NOTES }#1\@print{-->
}}\footnoterule\begin{list}[]{}{\renewcommand{\makelabel}[1]{##1}}}
  {\end{list}{\@nostyle\@print{
<!--END NOTES-->
}}}
%%% for HaChA
\newcounter{cuttingdepth}
\setcounter{cuttingdepth}{1}
\newcommand{\cutdef}[2][]{%
{\@nostyle\@print{<!--CUT DEF }#2\@print{ }#1\@print{ -->
}}}%
\newcommand{\cutend}{%
{\@nostyle\@print{<!--CUT END }\@print{-->
}}%
}
\newcommand{\@secend}{%
\@saveclosed{\@nostyle\@print{<!--SEC END }\@print{-->
}\@restoreclosed}%
}
\newcommand{\cuthere}[2]{%
\@footnoteflush{#1}%
{\@nostyle\@print{<!--TOC }\@getprint{#1}\@print{ }}%
\begin{@norefs}#2\end{@norefs}{\@nostyle\@print{-->
}}}
\newcommand{\@hacha@arg}[2]
  {{\@nostyle\@print{<ARG }\@getprint{#1}\@print{>}{#2}\@print{</ARG>}}}
\newenvironment{cutflow}[1]
  {\@printnostyle{<!--FLOW }%
  \@hacha@arg{TITLE}{#1}%
  \@printnostyle{-->
}}
{\@printnostyle{<!--END FLOW-->
}}
\newcommand{\cutname}[1]
  {{\@nostyle\@print{<!--NAME }\@getprint{#1}\@print{-->
}}}
\newcommand{\@link@arg}[2]
  {\ifthenelse{\equal{#2}{}}{}
  {\@hacha@arg{#1}{#2}}}
\newsavebox{\@toplinks}
\newcommand{\toplinks}[3]
  {\sbox{\@toplinks}
    {\@printnostyle{<!--LINKS }%
    \@link@arg{PREV}{#1}%
    \@link@arg{UP}{#2}%
    \@link@arg{NEXT}{#3}%
    \@printnostyle{-->
}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Echoing to the image file %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\@iopt@def{!*!}
\newcommand{\@imageopt}[1][!*!]
{\def\@itmp{#1}\ifx\@itmp\@iopt@def\else\begin{toimage}[#1]\end{toimage}\fi}
\newcommand{\@imagearg}[1]
  {\begin{toimage}{#1}\end{toimage}}
\newcommand{\@imagecommand}[2]
  {\newcommand{#1}{\begin{toimage}#1\end{toimage}#2}}

%%%%%%%%%%%%%
% Maketitle %
%%%%%%%%%%%%%
\newcommand{\maketitle}{%
{\newcommand{\checkbox}[2]
  {\ifthenelse{\equal{\usebox{##2}}{}}
    {}
    {\@open{##1}{ALIGN=center}\usebox{##2}\@close{##1}}}%
\checkbox{H1}{\@title}
\checkbox{H3}{\@author}
\checkbox{H3}{\@date}}}

%%%%%%%%%
% Maths %
%%%%%%%%%
\ifmathml
\else
\ifsymb
\ifentities\input{html/symb-ent.hva}
\else\input{html/symb.hva}
\fi
\else
\input{html/symb-text.hva}
\fi
\fi
%% Maths fonts
%%%%%%%%%%%
\def\bullet{{\@incsize{1}\@bullet}}
\def\textsqsubset{\mbox{sqsubset}}
\def\sqsubset{%
\ifdisplay\@itemdisplay\@sqsubset\@itemdisplay\else
\textsqsubset\fi}
\def\textsqsupset{\mbox{sqsupset}}
\def\sqsupset{%
\ifdisplay\@itemdisplay\@sqsupset\@itemdisplay\else
\textsqsupset\fi}
\def\textdoteq{=^{\cdot}}
\def\doteq{%
\ifdisplay\@itemdisplay\@print{<FONT SIZE=7>·</FONT><BR>}=\@itemdisplay\else
\textdoteq\fi}
\ifmathml
\input{html/symb-mathml.hva}
\fi
\input{mathop.hva}
%%%%%%%%%%%% Bibliography
\newcommand{\@bibref}[2]{\@locref{#1}{#2}}
\newsavebox{\@bibbox}
\newcommand{\@biblabel}[1]
{\@locname{#1}{\purple[\@bibread{#1}]}}
%%% Environment document.
\newcommand{\@bodyargs}{}
\newcommand{\@meta}
{\begin{rawhtml}
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea \end{rawhtml}\usebox{\@heveaversion}\@print{">
}}
\newenvironment{document}{%
\@end{document}
\@atbegindocument
\@restartoutput\unskip
\@print{<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
            "http://www.w3.org/TR/REC-html40/loose.dtd">
}\@print{<HTML>
}%
\@print{<HEAD><TITLE>}%
\@notags{\usebox{\@title}}%
\@print{</TITLE>
}\@meta%
\ifmathml\@print{<STYLE type="text/css">
  math.centered { text-align: center}
</STYLE>
}%
\fi
\@print{</HEAD>
}%
\@print{<BODY }\@notags{\@bodyargs}\@print{>
}%
\@print{<!--HEVEA command line is: }\usebox{\@heveacomline}\@print{-->
}%
\iffrench\@print{<!--FRENCH-->
}\fi
{\@nostyle\@print{<!--HTMLHEAD-->
}}%
\usebox{\@htmlhead}%
{\@nostyle\@print{<!--ENDHTML-->
}}%
\@printnostyle{<!--PREFIX }%
\@hacha@arg{}{\usebox{\@htmlprefix}}%
\@printnostyle{-->
}%
\usebox{\@toplinks}%
\cutdef[\thecuttingdepth]{\cuttingunit}%
}{%
\@clearstyle\@footnoteflush{document}%
\@atenddocument%
\@final@footer%
\@clearstyle%
\@print{</BODY>
</HTML>
}\@raise@enddocument}
\newenvironment{center}{\@open{DIV}{ALIGN=center}}{\@close{DIV}}
\newenvironment{flushleft}{\@open{DIV}{ALIGN=left}}{\@close{DIV}}
\newenvironment{flushright}{\@open{DIV}{ALIGN=right}}{\@close{DIV}}
\newcommand{\centerline}[1]{\begin{center}#1\end{center}}
\newenvironment{quote}{\@close{}\@open{BLOCKQUOTE}{}}{\@close{BLOCKQUOTE}\@open{}{}}
\newenvironment{quotation}{\@open{BLOCKQUOTE}{}}{\@close{BLOCKQUOTE}}
\newcommand{\centering}{\@insert{DIV}{ALIGN=center}}
\newcommand{\raggedleft}{\@insert{DIV}{ALIGN=right}}
\newcommand{\raggedright}{\@insert{DIV}{ALIGN=left}}

\newcommand{\rule}[3][]{\@printHR{}{}}%
%%%%%%%%%%%%%%%% LaTeX 2.09 style declarations
\newenvironment{tt}{\@style{TT}}{}
\newenvironment{bf}{\@style{B}}{}
\newenvironment{em}{\@style{EM}}{}
\newenvironment{it}{\@style{I}}{}
\newenvironment{rm}{\@anti{\sf,\tt}}{}
\newenvironment{tiny}{\@fontsize{1}}{}
\newenvironment{footnotesize}{\@fontsize{2}}{}
\newenvironment{scriptsize}{\@fontsize{2}}{}
\newenvironment{small}{\@fontsize{3}}{}
\newenvironment{normalsize}{\@fontsize{3}}{}
\newenvironment{large}{\@fontsize{4}}{}
\newenvironment{Large}{\@fontsize{5}}{}
\newenvironment{LARGE}{\@fontsize{5}}{}
\newenvironment{huge}{\@fontsize{6}}{}
\newenvironment{Huge}{\@fontsize{7}}{}
%%%%%% Colors
\newenvironment{purple}{\@fontcolor{purple}}{}
\newenvironment{black}{\@fontcolor{black}}{}
\newenvironment{silver}{\@fontcolor{silver}}{}
\newenvironment{gray}{\@fontcolor{gray}}{}
\newenvironment{white}{\@fontcolor{white}}{}
\newenvironment{maroon}{\@fontcolor{maroon}}{}
\newenvironment{red}{\@fontcolor{red}}{}
\newenvironment{fuchsia}{\@fontcolor{fuchsia}}{}
\newenvironment{green}{\@fontcolor{green}}{}
\newenvironment{lime}{\@fontcolor{lime}}{}
\newenvironment{olive}{\@fontcolor{olive}}{}
\newenvironment{yellow}{\@fontcolor{yellow}}{}
\newenvironment{navy}{\@fontcolor{navy}}{}
\newenvironment{blue}{\@fontcolor{blue}}{}
\newenvironment{teal}{\@fontcolor{teal}}{}
\newenvironment{aqua}{\@fontcolor{aqua}}{}
\def\cal{\ifmath\ifmathml\@style{font-family: cursive }%
\else\red\fi\else\red\fi}
\def\sf{\ifmath\ifmathml\@style{font-family: sans-serif }%
\else\purple\fi\else\purple\fi}
\def\sc{\ifmath\ifmathml\@style{font-family: monospace }%
\else\navy\fi\else\navy\fi}
\def\sl{\ifmath\ifmathml\@style{font-family: fantasy; font-style: italic }%
\else\it\maroon\fi\else\it\maroon\fi}
%%%% LaTeX2e verbose declarations
\newenvironment{mdseries}{\@anti{\bf}}{}
\newenvironment{bfseries}{\bf}{}
\newenvironment{rmfamily}{\rm}{}
\newenvironment{sffamily}{\@anti{\tt}\sf}{}
\newenvironment{ttfamily}{\@anti{\sf}\tt}{}
\newenvironment{upshape}{\@anti{\it,\sl,\sc}}{}
\newenvironment{itshape}{\@anti{\sl,\sc}\it}{}
\newenvironment{slshape}{\@anti{\it,\sc}\sl}{}
\newenvironment{scshape}{\@anti{\it,\sl}\sc}{}
\newenvironment{normalfont}{\rm\mdseries\upshape}{}
%%%%%%%%%%%%%%%%
\def\textrm#1{\mbox{\rmfamily#1}}
\def\textup#1{\mbox{\upshape#1}}
\def\textmd#1{\mbox{\mdseries#1}}
\def\textnormal#1{\mbox{\normalfont#1}}
\def\texttt#1{\mbox{\ttfamily#1}}
\def\textit#1{\mbox{\itshape#1}}
\def\textbf#1{\mbox{\bfseries#1}}
\def\textsf#1{\mbox{\sffamily#1}}
\def\textsl#1{\mbox{\slshape#1}}
\def\textsc#1{\mbox{\scshape#1}}
\newcommand{\emph}[1]{\mbox{\em#1}}
%%%%%%%%%%%%%%% Multicolumns index formating
\newcommand{\setindexpos}[2]
{\providesavebox{\csname indexpos#1\endcsname}%
\sbox{\csname indexpos#1\endcsname}{\@nostyle #2}}
\newcommand{\getindexpos}[1]{\usebox{\csname indexpos#1\endcsname}}
\newcounter{indexcols}\setcounter{indexcols}{2}
\newcounter{indexcount}\newcounter{indexdepth}
\newcounter{indexbox}
\newcommand{\indexitem}
{\stepcounter{indexcount}%
\end{lrbox}%
\setindexpos{\theindexbox}{\theindexcount}%
\stepcounter{indexbox}%
\providesavebox{\csname indexbox\theindexbox\endcsname}%
\begin{lrbox}{\csname indexbox\theindexbox\endcsname}}
\newcommand{\indexspace}{\indexitem}
{\stepcounter{indexcount}}
\newenvironment{indexenv}
{\stepcounter{indexdepth}
\ifthenelse{\value{indexdepth}>1}
{\begin{itemize}%
\renewcommand{\indexitem}{\stepcounter{indexcount}\item}%
\renewcommand{\indexspace}{\stepcounter{indexcount}\vspace*{2ex}}}
{\setcounter{indexbox}{0}\setcounter{indexcount}{0}%
\providesavebox{\csname indexbox0\endcsname}%
\begin{lrbox}{\csname indexbox0\endcsname}}}
{\ifthenelse{\value{indexdepth}>1}
{\end{itemize}\addtocounter{indexdepth}{-1}}
{\end{lrbox}%
\setindexpos{\theindexbox}{\theindexcount}%
\stepcounter{indexbox}%
\addtocounter{indexdepth}{-1}\printindexboxes}}
\newcounter{indexwork}\newcounter{indexlimit}
\newcounter{indexlines}
\newboolean{spaceallowed}
\newcounter{indexclines}\newcounter{indexprev}\newcounter{indexnow}%
\newcommand{\printindexboxes}
{\setcounter{indexwork}{1}%
\setcounter{indexlimit}{(\value{indexcount}+\value{indexcols}-1)/\value{indexcols}}
\setcounter{indexclines}{0}%
\setcounter{indexprev}{0}%
\setcounter{indexnow}{0}%
\begin{tabular}{*{\value{indexcols}}{X}}
\begin{itemize}
\whiledo{\value{indexwork}<\value{indexbox}}
{\setcounter{indexnow}{\pushint{\getindexpos{\theindexwork}}}%
\addtocounter{indexclines}{\value{indexnow}-\value{indexprev}}%
\ifthenelse{\equal{\usebox{\csname indexbox\theindexwork\endcsname}}{}}
{\ifthenelse{\boolean{spaceallowed}}{\vspace*{2ex}}{}}
{\item}%
\setboolean{spaceallowed}{true}%
\usebox{\csname indexbox\theindexwork\endcsname}%
\ifthenelse{\value{indexclines}>\value{indexlimit}}
{\end{itemize}&\begin{itemize}\setboolean{spaceallowed}{false}%
\setcounter{indexclines}{0}}{}%
\stepcounter{indexwork}\setcounter{indexprev}{\value{indexnow}}}%
\end{itemize}\end{tabular}}
%%%%%% Default TABLE attribute for array and tabular
\newcommand{\@table@attributes}{CELLSPACING=2 CELLPADDING=0}
\newcommand{\@table@attributes@border}{CELLSPACING=0 CELLPADDING=1}
%%%%%% Do not load hevea.hva again !
\def\csname hevea@loaded\endcsname{}