Whitespace adjustments
[lhc/web/wiklou.git] / math / texutil.ml
index f9ebb25..7800c65 100644 (file)
@@ -57,7 +57,7 @@ let get_preface ()  = "\\nonstopmode\n\\documentclass[12pt]{article}\n" ^
               (if !modules_nonascii then get_encoding !modules_encoding else "") ^
               (if !modules_ams then "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n" else "") ^
               (if !modules_color then "\\usepackage[dvips,usenames]{color}\n" else "") ^
-              "\\pagestyle{empty}\n\\begin{document}\n$$\n"
+              "\\usepackage{cancel}\n\\pagestyle{empty}\n\\begin{document}\n$$\n"
 let get_footer  ()  = "\n$$\n\\end{document}\n"
 
 let set_encoding = function
@@ -80,7 +80,7 @@ let find = function
     | "\\Gamma"            -> LITERAL (HTMLABLEC (FONT_UF, "\\Gamma ", "Γ"))
     | "\\delta"            -> LITERAL (HTMLABLEC (FONT_UF,  "\\delta ", "δ"))
     | "\\Delta"            -> LITERAL (HTMLABLEC (FONT_UF, "\\Delta ", "Δ"))
-    | "\\epsilon"          -> LITERAL (HTMLABLEC (FONT_UF,  "\\epsilon ", "ε"))
+    | "\\epsilon"          -> LITERAL (TEX_ONLY "\\epsilon ")
     | "\\Epsilon"          -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
     "\\mathrm{E}", "Ε")))
     | "\\varepsilon"       -> LITERAL (TEX_ONLY "\\varepsilon ")
@@ -108,6 +108,10 @@ let find = function
     | "\\nu"               -> LITERAL (HTMLABLEC (FONT_UF,  "\\nu ", "ν"))
     | "\\Nu"               -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
     "\\mathrm{N}", "Ν")))
+    | "\\omicron"          -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
+    "\\mathrm{o}", "ο")))
+    | "\\Omicron"          -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
+    "\\mathrm{O}", "Ο")))
     | "\\pi"               -> LITERAL (HTMLABLEC (FONT_UF,  "\\pi ", "π"))
     | "\\Pi"               -> LITERAL (HTMLABLEC (FONT_UF, "\\Pi ", "Π"))
     | "\\varpi"            -> LITERAL (TEX_ONLY "\\varpi ")
@@ -115,7 +119,7 @@ let find = function
     | "\\Rho"              -> (tex_use_ams (); LITERAL (HTMLABLEC (FONT_UF,
     "\\mathrm{P}", "Ρ")))
     | "\\varrho"           -> LITERAL (TEX_ONLY "\\varrho ")
-    | "\\sim"              -> LITERAL (HTMLABLEC (FONT_UF,  "\\sim ", "˜"))
+    | "\\sim"              -> LITERAL (HTMLABLEC (FONT_UF,  "\\sim ", "∼"))
     | "\\sigma"            -> LITERAL (HTMLABLEC (FONT_UF,  "\\sigma ", "σ"))
     | "\\Sigma"            -> LITERAL (HTMLABLEC (FONT_UF, "\\Sigma ", "Σ"))
     | "\\varsigma"         -> LITERAL (TEX_ONLY "\\varsigma ")
@@ -124,7 +128,7 @@ let find = function
     "\\mathrm{T}", "Τ")))
     | "\\upsilon"          -> LITERAL (HTMLABLEC (FONT_UF,  "\\upsilon ", "υ"))
     | "\\Upsilon"          -> LITERAL (HTMLABLEC (FONT_UF, "\\Upsilon ", "Υ"))
-    | "\\phi"              -> LITERAL (HTMLABLEC (FONT_UF,  "\\phi ", "φ"))
+    | "\\phi"              -> LITERAL (TEX_ONLY "\\phi ")
     | "\\Phi"              -> LITERAL (HTMLABLEC (FONT_UF, "\\Phi ", "Φ"))
     | "\\varphi"           -> LITERAL (TEX_ONLY "\\varphi ")
     | "\\chi"              -> LITERAL (HTMLABLEC (FONT_UF,  "\\chi ", "χ"))
@@ -217,20 +221,20 @@ let find = function
     | "\\models"           -> LITERAL (TEX_ONLY "\\models ")
     | "\\vdash"            -> LITERAL (TEX_ONLY "\\vdash ")
     | "\\triangle"         -> LITERAL (TEX_ONLY "\\triangle ")
-       | "\\bowtie"           -> LITERAL (TEX_ONLY "\\bowtie ")
+    | "\\bowtie"           -> LITERAL (TEX_ONLY "\\bowtie ")
     | "\\wr"               -> LITERAL (TEX_ONLY "\\wr ")
     | "\\triangleleft"     -> LITERAL (TEX_ONLY "\\triangleleft ")
     | "\\triangleright"    -> LITERAL (TEX_ONLY "\\triangleright ")
     | "\\textvisiblespace" -> LITERAL (TEX_ONLY "\\textvisiblespace ")
-    | "\\ker"              -> LITERAL (TEX_ONLY "\\ker ")
+    | "\\ker"              -> LITERAL (HTMLABLEC(FONT_UFH,"\\ker ","ker"))
     | "\\lim"              -> LITERAL (TEX_ONLY "\\lim ")
     | "\\limsup"           -> LITERAL (TEX_ONLY "\\limsup ")
     | "\\liminf"           -> LITERAL (TEX_ONLY "\\liminf ")
     | "\\sup"              -> LITERAL (TEX_ONLY "\\sup ")
     | "\\Pr"               -> LITERAL (TEX_ONLY "\\Pr ")
-    | "\\hom"              -> LITERAL (TEX_ONLY "\\hom ")
-    | "\\arg"              -> LITERAL (TEX_ONLY "\\arg ")
-    | "\\dim"              -> LITERAL (TEX_ONLY "\\dim ")
+    | "\\hom"              -> LITERAL (HTMLABLEC(FONT_UFH,"\\hom ","hom"))
+    | "\\arg"              -> LITERAL (HTMLABLEC(FONT_UFH,"\\arg ","arg"))
+    | "\\dim"              -> LITERAL (HTMLABLEC(FONT_UFH,"\\dim ","dim"))
     | "\\inf"              -> LITERAL (TEX_ONLY "\\inf ")
     | "\\circ"             -> LITERAL (TEX_ONLY "\\circ ")
     | "\\hbar"             -> LITERAL (TEX_ONLY "\\hbar ")
@@ -240,7 +244,7 @@ let find = function
     | "\\hookrightarrow"   -> LITERAL (TEX_ONLY "\\hookrightarrow ")
     | "\\hookleftarrow"    -> LITERAL (TEX_ONLY "\\hookleftarrow ")
     | "\\mp"               -> LITERAL (TEX_ONLY "\\mp ")
-    | "\\approx"           -> LITERAL (TEX_ONLY "\\approx ")
+    | "\\approx"           -> LITERAL (HTMLABLE  (FONT_UF,  "\\approx ", "≈"))
     | "\\propto"           -> LITERAL (TEX_ONLY "\\propto ")
     | "\\flat"             -> LITERAL (TEX_ONLY "\\flat ")
     | "\\sharp"            -> LITERAL (TEX_ONLY "\\sharp ")
@@ -405,14 +409,20 @@ let find = function
     | "\\mod"              -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mod ", "mod")))
     | "\\Diamond"          -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\Diamond ", "◊")))
     | "\\dotsb"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsb ", "⋅⋅⋅")))
+    | "\\dotsc"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsc ", "...")))
+    | "\\dotsi"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsi ", "⋅⋅⋅")))
+    | "\\dotsm"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotsm ", "⋅⋅⋅")))
+    | "\\dotso"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UF, "\\dotso ", "...")))
     | "\\reals"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
     | "\\Reals"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
     | "\\R"                -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{R}", "<b>R</b>")))
+    | "\\C"                -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
     | "\\cnums"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
     | "\\Complex"          -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{C}", "<b>C</b>")))
     | "\\Z"                -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Z}", "<b>Z</b>")))
     | "\\natnums"          -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
     | "\\N"                -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{N}", "<b>N</b>")))
+    | "\\Q"                -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\mathbb{Q}", "<b>Q</b>")))
     | "\\lVert"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\lVert ", "||")))
     | "\\rVert"            -> (tex_use_ams (); LITERAL (HTMLABLE (FONT_UFH,"\\rVert ", "||")))
     | "\\nmid"             -> (tex_use_ams (); LITERAL (TEX_ONLY "\\nmid "))
@@ -466,6 +476,8 @@ let find = function
     | "\\left"             -> LEFT
     | "\\right"            -> RIGHT
     | "\\hat"              -> FUN_AR1 "\\hat "
+    | "\\hline"            -> LITERAL (TEX_ONLY "\\hline ")
+    | "\\vline"            -> LITERAL (TEX_ONLY "\\vline ")
     | "\\widehat"          -> LITERAL (TEX_ONLY "\\widehat ")
     | "\\overline"         -> LITERAL (TEX_ONLY "\\overline ")
     | "\\overbrace"        -> LITERAL (TEX_ONLY "\\overbrace ")
@@ -473,7 +485,7 @@ let find = function
     | "\\underbrace"       -> LITERAL (TEX_ONLY "\\underbrace ")
     | "\\overleftarrow"    -> LITERAL (TEX_ONLY "\\overleftarrow ")
     | "\\overrightarrow"   -> LITERAL (TEX_ONLY "\\overrightarrow ")
-    | "\\overleftrightarrow"->LITERAL (TEX_ONLY "\\overleftrightarrow ")
+    | "\\overleftrightarrow"-> (tex_use_ams(); LITERAL (TEX_ONLY "\\overleftrightarrow "))
     | "\\check"            -> FUN_AR1 "\\check "
     | "\\acute"            -> FUN_AR1 "\\acute "
     | "\\grave"            -> FUN_AR1 "\\grave "
@@ -499,11 +511,16 @@ let find = function
     | "\\cfrac"            -> (tex_use_ams (); FUN_AR2h ("\\cfrac ", fun num den -> Html.html_render [num], "<hr style=\"{background: black}\">", Html.html_render [den]))
     | "\\over"             -> FUN_INFIXh ("\\over ", fun num den -> Html.html_render num, "<hr style=\"{background: black}\"/>", Html.html_render den)
     | "\\sqrt"             -> FUN_AR1 "\\sqrt "
+    | "\\cancel"           -> FUN_AR1 "\\cancel "
+    | "\\bcancel"           -> FUN_AR1 "\\bcancel "
+    | "\\xcancel"           -> FUN_AR1 "\\xcancel "
+    | "\\cancelto"         -> FUN_AR2 "\\cancelto "
     | "\\pmod"             -> FUN_AR1hl ("\\pmod ", ("(mod ", ")"))
     | "\\bmod"             -> FUN_AR1hl ("\\bmod ", ("mod ", ""))
     | "\\emph"             -> FUN_AR1 "\\emph "
     | "\\texttt"           -> FUN_AR1 "\\texttt "
     | "\\textbf"           -> FUN_AR1 "\\textbf "
+    | "\\textsf"           -> FUN_AR1 "\\textsf "
     | "\\textit"           -> FUN_AR1hf ("\\textit ", FONTFORCE_IT)
     | "\\textrm"           -> FUN_AR1hf ("\\textrm ", FONTFORCE_RM)
     | "\\rm"               -> DECLh ("\\rm ", FONTFORCE_RM)
@@ -702,7 +719,13 @@ let find = function
     | "\\nLeftrightarrow"  -> (tex_use_ams (); LITERAL (TEX_ONLY "\\nLeftrightarrow "))
     | "\\mathit"           -> (tex_use_ams (); FUN_AR1hf ("\\mathit ", FONTFORCE_IT))
     | "\\mathrm"           -> (tex_use_ams (); FUN_AR1hf ("\\mathrm ", FONTFORCE_RM))
+    | "\\mathord"          -> (tex_use_ams (); FUN_AR1 "\\mathord ")
     | "\\mathop"           -> (tex_use_ams (); FUN_AR1 "\\mathop ")
+    | "\\mathbin"          -> (tex_use_ams (); FUN_AR1 "\\mathbin ")
+    | "\\mathrel"          -> (tex_use_ams (); FUN_AR1 "\\mathrel ")
+    | "\\mathopen"         -> (tex_use_ams (); FUN_AR1 "\\mathopen ")
+    | "\\mathclose"        -> (tex_use_ams (); FUN_AR1 "\\mathclose ")
+    | "\\mathpunct"        -> (tex_use_ams (); FUN_AR1 "\\mathpunct ")
     | "\\boldsymbol"       -> (tex_use_ams (); FUN_AR1 "\\boldsymbol ")
     | "\\bold"             -> (tex_use_ams (); FUN_AR1 "\\mathbf ")
     | "\\Bbb"              -> (tex_use_ams (); FUN_AR1 "\\mathbb ")
@@ -710,6 +733,7 @@ let find = function
     | "\\mathsf"           -> (tex_use_ams (); FUN_AR1 "\\mathsf ")
     | "\\mathcal"          -> (tex_use_ams (); FUN_AR1 "\\mathcal ")
     | "\\mathbb"           -> (tex_use_ams (); FUN_AR1 "\\mathbb ")
+    | "\\mathtt"           -> (tex_use_ams (); FUN_AR1 "\\mathtt ")
     | "\\mathfrak"         -> (tex_use_ams (); FUN_AR1 "\\mathfrak ")
     | "\\operatorname"     -> (tex_use_ams (); FUN_AR1 "\\operatorname ")
     | "\\text"             -> raise (Failure "malformatted \\text")
@@ -717,4 +741,6 @@ let find = function
     | "\\vbox"             -> raise (Failure "malformatted \\vbox")
     | "\\hbox"             -> raise (Failure "malformatted \\hbox")
     | "\\color"            -> (tex_use_color (); LITERAL (TEX_ONLY "\\color"))
+    | "\\pagecolor"        -> (tex_use_color (); LITERAL (TEX_ONLY "\\pagecolor"))
+    | "\\definecolor"      -> (tex_use_color (); LITERAL (TEX_ONLY "\\definecolor"))
     | s                    -> raise (Illegal_tex_function s)