% $Id: tex4ht-jsmath.tex 77 2011-01-28 11:45:59Z cvr $ % compile 3 times: latex tex4ht-jsmath % or xhlatex tex4ht-jsmath "html,3,sections+" % % Copyright (C) 2009-2010 TeX Users Group % Copyright (C) 2005-2009 Eitan M. Gurari % Released under LPPL 1.3c+. % See tex4ht-cpright.tex for license text. % % CDATA support: % http://planetmath.org/encyclopedia/ % % }\par}% } \Configure{!BODY}{ class="tex2math_ignore" } >>> \<<< \HCode{\Hnewline \Hnewline} >>> \<<< \Hnewline >>> %%%%%%%%%%%%% \subsection{Links} %%%%%%%%%%%%% \<<< \def\Hbrakets<#1>{\ifmathltx \ifmtext @(#1)\else \string\hbox{@(#1)}\fi \else <#1>\fi} \def\EndLink{\ifmathltx \ifmtext |% \egroup \HCode{\%\Hnewline\%}\Endmtxt:link \HCode{\string\end{ref}\Hnewline}|% \else \HCode{\Hbrakets}\fi \else \expandafter\M:EndLink\fi} \LinkCommand\msp:link{a, href, id, \mml:class="label",,} >>> \<<< \def\Link{\M:Link} \def\EndLink{\M:EndLink} >>> ``The contents of an \verb=\hbox{}= are not rendered by jsMath, but instead are used as plain text in the browser. JsMath allows you to include HTML commands through the (rather awkward) means of using @(...) in place of \verb=<...>=. For example, \verb=\hbox{@(tt)= monospaced \verb=text@(/tt)= would get the enclosed text in the TT font.'' The above also holds for \verb=\text= instead of \verb=\hbox=. %%%%%%%%%%%%% \subsection{Core} %%%%%%%%%%%%% \<<< \Configure{over} {\Send{GROUP}{0}{\l:brace\space}} {\HCode{\string\over\space}\Send{EndGROUP}{0}{\r:brace\space}} \Configure{atop} {\Send{GROUP}{0}{\l:brace\space}} {\HCode{\string\atop\space}\Send{EndGROUP}{0}{\r:brace\space}} >>> %%%%%%%%%%%%%%%%%% \section{LaTeX} %%%%%%%%%%%%%%%%%% \marginpar{Anchors need fixing} \<<< \def\set:label#1{\ifmathltx % \HCode{\%\Hnewline\%\string\begin{label}}% % {\ht:special{t4ht@, }\let\:newlnch\space \mathltxfalse #1}% % \HCode{\string\end{label}\Hnewline}% \else #1\fi } >>> \<<< \Configure{frac} {\HCode{\l:brace}} {\HCode{\string\over\space}\Configure{over}{}{}} {} {\HCode{\r:brace}} >>> \<<< \Configure{[]} {\Configure{@math}{div}\csname a:mathltx[]\endcsname \DviMath$$\DisplayMathtrue } {$$\EndDviMath\csname b:mathltx[]\endcsname} \Configure{()} {\Configure{@math}{span}\csname a:mathltx()\endcsname \DviMath$} {$\EndDviMath\csname b:mathltx()\endcsname} >>> \<<< \Configure{mfenced}{\langle}{\string\langle\space} \Configure{mfenced}{\rangle}{\string\rangle\space} \def\:tempc{\HCode{\string\langle\space}} \HLet\langle\:tempc \def\:tempc{\HCode{\string\rangle\space}} \HLet\rangle\:tempc \def\:tempc{\HCode{\string\vert\space}} \HLet\vert\:tempc \def\:tempc{\HCode{\string\Vert\space}} \HLet\Vert\:tempc \def\:tempc{\HCode{\string\||}} \HLet\||\:tempc \def\:tempc{\HCode{\string\big\space}} \HLet\big\:tempc \def\:tempc{\HCode{\string\bigg\space}} \HLet\bigg\:tempc \def\:tempc{\HCode{\string\Big\space}} \HLet\Big\:tempc \def\:tempc{\HCode{\string\Bigg\space}} \HLet\Bigg\:tempc >>> \<<< | >>> \<<< | >>> \<<< \Configure{array} {%\expandafter\tmp:toks\expandafter{\Clr}% \HCode{\string\array\l:brace\Hnewline}} {\ifvmode \IgnorePar\fi \HCode{\r:brace}} {\ifnum \HRow> 1\HCode{\string\cr\Hnewline}\fi} {} {|} {} >>> \<<< \Configure{emph} {\ifmmode \Configure{@mtext}{\string\mathit}\fi} {}% >>> %%%%%%%%%%%%%%%%%% \section{AMS Math} %%%%%%%%%%%%%%%%%% \<<< \expandafter\def\csname genfrac \endcsname#1#2#3#4{% \def\:tempa{#1}\ifx\:tempa\empty\else \HCode{\string\left}#1\fi \def\:tempa{#2}\ifx\:tempa\empty\else \def\:tempa{\HCode{\string\right}#2}\fi \edef\@tempb{\@nx\@genfrac\@mathstyle{#4}% \expandafter\noexpand\csname @@\ifx @#3@over\else above\fi \endcsname}% \@tempb{#3}} \def\:tempc#1#2#3#4#5{{\a:genfrac#1\b:genfrac{\c:genfrac#4#2#3\relax {\d:genfrac#5\e:genfrac}}\f:genfrac}\:tempa} \HLet\@genfrac\:tempc >>> \<<< \ifx \mathdisplay@@pop\:UnDef \ifx \emdf@La\:UnDef | \else | \fi \else | \fi >>> \<<< \Configure{equation$$} {\Configure{$$} {\IgnorePar \Configure{@math}{div}\EndP\DviMath} {\EndDviMath\EndP} {\DisplayMathtrue}% } >>> \<<< \Configure{tmspace} {\HCode{\string\kern \space \textspace\space}} \def\lvert{\HCode{\string\vert\space}} \def\rvert{\HCode{\string\vert\space}} \def\lVert{\HCode{\string\Vert\space}} \def\rVert{\HCode{\string\Vert\space}} >>> % CVR: 2011-01-28 Changes to fix bugs reported by Rob Beezer's \texttt{}: Configuration for \verb=\intertext= introduced. \<<< \Configure{intertext} {\IgnorePar %\ifinalign@ \HCode{\string\cr }% \AA:text{intertext}} {\BB:text \ifvmode \IgnorePar \fi %\EndP \HCode{\string\cr }} >>> \<<< \ConfigureEnv{multline} {\bgroup \Configure{$$} {\Configure{@math}{}\IgnorePar \EndP\DviMath } {\EndDviMath\ShowPar\csname par\endcsname {\csname HCondtrue\endcsname\noindent}} {\DisplayMathtrue}% } {\egroup} {}{} \Configure{multline} {\HCode{
}} {\HCode{
}} {\ifnum \HRow> 1\HCode{\Hnewline }\fi} {\gdef\mult:amp{\gdef\mult:amp{\HCode{ }}}} {\csname mult:amp\endcsname \HCode{\ifnum 1<\HMultispan % \string\multicolumn\l:brace\HMultispan\r:brace %\string\multispan ?span/multispan-in-jsmath? \space\HMultispan\space \fi}% } {} \Css{table.multline td {text-align:left; vertical-align:middle; padding-left: 2em; }} \Css{table.multline td.eq-no { text-align:center; }} \Css{table.multline { width:100\%; }} >>> \<<< \ConfigureEnv{multline} {\bgroup |} {\egroup} {}{} \Configure{multline} {\HCode{\string\begin\l:brace array\r:brace \l:brace lp{10mm}r\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\space}\qquad\fi} {\gdef\mult:amp{\gdef\mult:amp{\HCode{\a:math:amp}\qquad}}} {\csname mult:amp\endcsname \HCode{\ifnum 1<\HMultispan % \string\multicolumn\l:brace\HMultispan\r:brace | \space\HMultispan\space \fi}% } {} >>> \<<< \ConfigureEnv{multline*} {\bgroup |} {\egroup} {}{} \Configure{multline*} {\HCode{\string\begin\l:brace array\r:brace \l:brace lr\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} >>> \<<< \Configure{$$} {\Configure{@math}{div}\IgnorePar \EndP\DviMath } {\EndDviMath\ShowPar\csname par\endcsname {\csname HCondtrue\endcsname\noindent}} {\DisplayMathtrue}% >>> \<<< \Configure{subarray} {\HCode{\string\begin\l:brace array\r:brace \l:brace \Hlcr\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} \Configure{smallmatrix} {\HCode{\string\begin\l:brace matrix\r:brace}} {\HCode{\string\end \l:brace matrix\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} {\HCode{\ifnum \HCol>1 \a:math:amp\fi \scriptstyle \ifnum 1<\HMultispan % \string\multicolumn\l:brace\HMultispan\r:brace | \space\HMultispan\space \fi}% } {} >>> \<<< \Configure{aligned} {\HCode{\string\begin\l:brace array\r:brace \l:brace rlrlrl\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {} {\HCode{\string\cr\space}} {} {\HCode{\a:math:amp\space}} \Configure{alignedat} {\HCode{\string\begin\l:brace array\r:brace \l:brace rlrl\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {} {\HCode{\string\cr\space}} {} {\HCode{\a:math:amp\space}} >>> \<<< \Configure{equation} {\ifvmode \IgnorePar\fi\EndP \HCode{
}% |% |% } {\ifvmode \IgnorePar\fi\EndP \HCode{}% } {\ifvmode \IgnorePar\fi\EndP \HCode{
}% \ShowPar\IgnoreIndent\par} \Configure{equation*} {\ifvmode \IgnorePar\fi\EndP \HCode{
}% |% |% } {\ifvmode \IgnorePar\fi\EndP \HCode{
}% \ShowPar\IgnoreIndent\par} >>> \<<< \csname a:equation\string$\string$\endcsname >>> \<<< \Configure{gather} {\HCode{\string\begin\l:brace array\r:brace \l:brace lp{10mm}r\r:brace}\IgnorePar |} {\HCode{\string\end\l:brace array\r:brace}} {} {} {\ifnum\HCol=2 \IgnorePar \HCode{\a:math:amp}\fi } {} >>> \<<< \Configure{gather*} {\HCode{\string\begin\l:brace array\r:brace \l:brace lp{10mm}r\r:brace}\IgnorePar |} {\HCode{\string\end\l:brace array\r:brace}} {} {} {\ifnum\HCol=2 \IgnorePar \HCode{\a:math:amp}\fi } {} >>> \<<< \Configure{split} {\HCode{\string\begin\l:brace array\r:brace \l:brace rl\r:brace}} {\ifvmode\IgnorePar\fi \HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} {|} {} >>> \<<< \Configure{math:amp}{\string&} >>> \<<< \HCode{\ifnum \HCol>1 \a:math:amp\fi \ifnum 1<\HMultispan % \string\multicolumn\l:brace\HMultispan\r:brace | \space\HMultispan\space \fi}% >>> \<<< %\string\multispan ?span/multispan-in-jsmath? >>> \<<< \ConfigureEnv{gather} {\bgroup |} {\egroup} {}{} \Configure{gather} {\HCode{\string\begin\l:brace array\r:brace \l:brace cl\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} {|} {} \ConfigureEnv{gather*} {\bgroup |} {\egroup} {}{} \Configure{gather*} {\HCode{\string\begin\l:brace array\r:brace \l:brace cl\r:brace}} {\HCode{\string\end \l:brace array\r:brace}} {\ifnum \HRow> 1\HCode{\string\\\Hnewline}\fi} {} {|} {} >>> % CVR 2011-01-28 \verb=\HtmlParOff= added to \verb=\Configure{#1}=. \verb=\HCode{<--tex4ht:inline-->}= commented out as it interfered with parsing. \verb=\HtmlParOn= added after \verb=\end:mathalign=. Before cell and after cell configurations have been rewritten to solve the problems reported by Rob Beezer's \texttt{}. % \<<< % \def\:tempc#1#2{% % \ConfigureEnv{#1} % {\def\end:al:env{}\ifmmode\else % \ifvmode\else \def\end:al:env{\par\ShowPar\IgnoreIndent} % \fi\fi} % {\end:al:env } % {}{}% % \Configure{#1} % {\IgnorePar\HtmlParOff % \ifvmode \EndP \else \EndP\fi % \ifmathltx % \Tg\def\end:mathalign{\Tg}% % \else % \Configure{@math}{div}\DviMath % \def\end:mathalign{\EndDviMath \DisplayMathfalse}% % \DisplayMathtrue % \fi % \HCode{\string\matrix\l:brace}} % {\HCode{\r:brace}\end:mathalign\HtmlParOn} % {\ifnum \HRow> 1\HCode{\string\cr\Hnewline}\fi} % {} % {\HCode{\ifnum \HCol>1 \a:math:amp\fi % \ifnum 1<\HMultispan % ?span/multispan-in-jsmath? % \space\HMultispan\space\fi}}% % {} % % } % \:tempc{align}{align} % \:tempc{alignat}{alignat} % \:tempc{xalignat}{xalignat} % \:tempc{xxalignat}{xxalignat} % \:tempc{flalign}{flalign} % \:tempc{align*}{align*} % \:tempc{alignat*}{alignat*} % \:tempc{xalignat*}{xalignat*} % \:tempc{flalign*}{flalign*} % >>> jsMath doesn't support hfil... hence the following \<<< \ifodd\HCol\space\else \string\kern \space 2em\space \fi >>> Yet another venue through eqalign \<<< \def\:tempc#1#2{% \ConfigureEnv{#1} {\def\end:al:env{}\ifmmode\else \ifvmode\else \def\end:al:env{\par\ShowPar\IgnoreIndent} \fi\fi} {\end:al:env } {}{}% \Configure{#1} {\IgnorePar\HtmlParOff \ifvmode \EndP \else \EndP \fi \ifmathltx \Tg\def\end:mathalign{\Tg}% \else \Configure{@math}{div}\DviMath \def\end:mathalign{\EndDviMath \DisplayMathfalse}% \DisplayMathtrue \fi \HCode{\string\eqalignno\l:brace}} {\HCode{\r:brace}\end:mathalign\HtmlParOn} {\ifnum \HRow> 1\HCode{\string\cr\Hnewline}\fi} {} {\HCode{\ifnum \HCol>1 \a:math:amp\fi \ifnum 1<\HMultispan ?span/multispan-in-jsmath? \space\HMultispan\space\fi}}% {} % } \:tempc{align}{align} \:tempc{alignat}{alignat} \:tempc{xalignat}{xalignat} \:tempc{xxalignat}{xxalignat} \:tempc{flalign}{flalign} \:tempc{align*}{align*} \:tempc{alignat*}{alignat*} \:tempc{xalignat*}{xalignat*} \:tempc{flalign*}{flalign*} >>> %%%%%%%%%%%%%%%%%% \section{Over and Under} %%%%%%%%%%%%%%%%%% \<<< | >>> \<<< | >>> \<<< \Configure{overrightarrow} {\HCode{\string\overrightarrow\l:brace}\:gobble} {\HCode{\r:brace}} \Configure{overleftarrow} {\HCode{\string\overleftarrow\l:brace}\:gobble} {\HCode{\r:brace}} >>> \<<< \Configure{underrightarrow} {\HCode{\string\mathop\l:brace}\:gobble} {\HCode{\r:brace\string\limits \string_\string\longrightarrow\space}} \Configure{underleftarrow} {\HCode{\string\mathop\l:brace}\:gobble} {\HCode{\r:brace\string\limits \string_\string\longleftarrow\space}} >>> \<<< \Configure{overleftrightarrow} {\HCode{\string\mathop\l:brace}\:gobble} {\HCode{\r:brace\string\limits \string^\string\longleftrightarrow\space}} \Configure{underleftrightarrow} {\HCode{\string\mathop\l:brace}\:gobble} {\HCode{\r:brace\string\limits \string_\string\longleftrightarrow\space}} >>> \<<< \def\:tempc#1{ {\HCode{\string\mathop\l:brace}#1% \HCode{\r:brace\string\limits \string^\l:brace\hbox\l:brace....\r:brace\r:brace}}} \HLet\ddddot\:tempc \def\:tempc#1{ {\HCode{\string\mathop\l:brace}#1% \HCode{\r:brace\string\limits \string^\l:brace\hbox\l:brace...\r:brace\r:brace}}} \HLet\dddot\:tempc >>> \<<< \def\:tempc#1#2{% \HCode{\string\mathop\l:brace}#2% \HCode{\r:brace\string\limits \string^\l:brace}#1\HCode{\r:brace}} \HLet\overset\:tempc \def\:tempc#1#2{% \HCode{\string\mathop\l:brace}#2% \HCode{\r:brace\string\limits \string_\l:brace}#1\HCode{\r:brace}} \HLet\underset\:tempc \def\:tempc#1#2#3{% \HCode{\l:brace\l:brace\r:brace}#1% \HCode{\l:brace}#3% \HCode{\r:brace}#2\HCode{\r:brace}} \HLet\sideset\:tempc >>> \<<< \renewcommand{\xrightarrow}[2][]{% \HCode{\string\mathop\l:brace \string\longrightarrow \r:brace\string\limits \string_\l:brace}#1\HCode{\r:brace\string^\l:brace}% #2\HCode{\r:brace}} \renewcommand{\xleftarrow}[2][]{% \HCode{\string\mathop\l:brace \string\longleftarrow \r:brace\string\limits \string_\l:brace}#1\HCode{\r:brace\string^\l:brace}% #2\HCode{\r:brace}} >>> The following definition is needed because \verb=\multispan= is not recognized by jsMath \<<< \def\hdots@for#1#2{% \tmp:cnt=#2\relax \ifnum \tmp:cnt>0 .% \loop \advance\tmp:cnt by -1\relax \ifnum \tmp:cnt>0 \HCode{\string&}.% \repeat \fi } >>> %%%%%%%%%%%%%%%%%% \section{Symbols} %%%%%%%%%%%%%%%%%% \<<< \def\:tempc#1{\HCode{\kern18mu {\string\rm\space mod}\string\,\string\,}#1} \HLet\mod=\:tempc \def\:tempc#1{\HCode{\kern18mu }(#1)} \HLet\pod=\:tempc \def\:tempc#1{\HCode{\kern18mu \string\mathbin{\string\rm\space mod}\string\,\string\,}#1} \HLet\bmod\:tempc \def\:tempc#1{\HCode{\kern18mu }(\HCode{{\string\rm\space mod}\kern6mu\space} #1)} \HLet\pmod=\:tempc >>> %%%%%%%%%%%%%%%%%% \section{Boxed} %%%%%%%%%%%%%%%%%% \<<< \Configure{boxed} {\ifmathltx \HCode{\string\class\l:brace boxed\r:brace\l:brace}% \else \HCode{}\IgnorePar\fi} {\ifmathltx \HCode{\r:brace}% \else \HCode{}\fi} \Css{.boxed{border: 1px solid black; padding-left:2px; padding-right:2px;}} >>> \<<< \Configure{boxed} {\ifmathltx \HCode{\string\class\l:brace boxed\r:brace\l:brace}% \else \HCode{}\IgnorePar\fi} {\ifmathltx \HCode{\r:brace}% \else \HCode{}\fi} \Css{.boxed{border: 1px solid black; padding-left:2px; padding-right:2px;}} >>> %%%%%%%%%%%%%%%%%% \endinput %%%%%%%%%%%%%%%%%%