From 2b81f7ddfedb4859cc4d545bc0aafed3f48c8cb8 Mon Sep 17 00:00:00 2001
From: milde
Date: Thu, 20 May 2021 12:22:27 +0000
Subject: MathML: support more functions and symbols.
- Support emellished identifiers,
- support more functions and symbols from "amsmath",
- map HYPHEN-MINUS -> MINUS SIGN and COLON -> RATIO im math context,
- simplify doctests with starred import,
- dont wrap content in when it is inferred by an element
(let these elements inherit from "mrow").
- tex2unichar: Fix/extend character mappings.
git-svn-id: https://svn.code.sf.net/p/docutils/code/trunk@8748 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
---
docutils/docutils/utils/math/latex2mathml.py | 392 +++++++++++++--------
docutils/docutils/utils/math/tex2unichar.py | 53 +--
.../functional/expected/math_output_mathml.html | 230 ++++++------
.../input/data/comprehensive-math-test.txt | 200 +++++++----
4 files changed, 508 insertions(+), 367 deletions(-)
(limited to 'docutils')
diff --git a/docutils/docutils/utils/math/latex2mathml.py b/docutils/docutils/utils/math/latex2mathml.py
index 5a3bce492..769ced771 100644
--- a/docutils/docutils/utils/math/latex2mathml.py
+++ b/docutils/docutils/utils/math/latex2mathml.py
@@ -22,7 +22,7 @@
#
# Usage:
#
-# >>> import latex2mathml as l2m
+# >>> from latex2mathml import *
import collections
import re
@@ -54,12 +54,17 @@ greek_capitals = {
functions = ['arccos', 'arcsin', 'arctan', 'arg', 'cos', 'cosh',
'cot', 'coth', 'csc', 'deg', 'det', 'dim',
'exp', 'gcd', 'hom', 'inf', 'ker', 'lg',
- 'lim', 'liminf', 'limsup', 'ln', 'log', 'max',
- 'min', 'Pr', 'sec', 'sin', 'sinh', 'sup',
- 'tan', 'tanh', 'injlim', 'varinjlim', 'projlim',
- 'varlimsup', 'varliminf', 'varprojlim']
-
-# font selection ->
+ 'lim', 'ln', 'log', 'max', 'min', 'Pr',
+ 'sec', 'sin', 'sinh', 'sup', 'tan', 'tanh']
+functions = dict((name, name) for name in functions)
+functions.update({# functions with a space in the name
+ 'liminf': u'lim\u202finf', 'limsup': u'lim\u202fsup',
+ 'injlim': u'inj\u202flim', 'projlim': u'proj\u202flim',
+ # embellished function names (see handle_keyword() below)
+ 'varlimsup': 'lim', 'varliminf': 'lim',
+ 'varprojlim': 'lim', 'varinjlim': 'lim'})
+
+# math font selection -> or
math_alphabets = {# 'cmdname': 'mathvariant value' # package
'boldsymbol': 'bold',
'mathbb': 'double-struck', # amssymb
@@ -79,19 +84,6 @@ math_alphabets = {# 'cmdname': 'mathvariant value' # package
# bold-sans-serif
}
-# blackboar bold (Greek characters not working with "mathvariant" (Firefox 78)
-mathbb = {u'Γ': u'\u213E', # ℾ
- u'Π': u'\u213F', # ℿ
- u'Σ': u'\u2140', # ⅀
- u'γ': u'\u213D', # ℽ
- u'π': u'\u213C', # ℼ
- r'\Gamma': u'\u213E', # ℾ
- r'\Pi': u'\u213F', # ℿ
- r'\Sigma': u'\u2140', # ⅀
- r'\gamma': u'\u213D', # ℽ
- r'\pi': u'\u213C', # ℼ
- }
-
# operator, fence, or separator ->
operators = tex2unichar.mathbin # Binary symbols
@@ -101,24 +93,58 @@ operators.update(tex2unichar.mathop) # Variable-sized symbols
operators.update(tex2unichar.mathopen) # Braces
operators.update(tex2unichar.mathclose) # Braces
operators.update(tex2unichar.mathfence)
-
-# >>> '{' in l2m.operators.values()
+operators.update({# negated symbols without pre-composed Unicode character
+ 'nleqq': u'\u2266\u0338', # ≦̸
+ 'ngeqq': u'\u2267\u0338', # ≧̸
+ 'nleqslant': u'\u2a7d\u0338', # ⩽̸
+ 'ngeqslant': u'\u2a7e\u0338', # ⩾̸
+ 'nsubseteqq': u'\u2AC5\u0338', # ⫅̸
+ 'nsupseteqq': u'\u2AC6\u0338', # ⫆̸
+ })
+
+# >>> '{' in operators.values()
# True
# special cases
+thick_operators = {# style='font-weight: bold;'
+ 'thicksim': u'\u223C', # ∼
+ 'thickapprox':u'\u2248', # ≈
+ }
+
+small_operators = {# mathsize='75%'
+ 'shortmid': u'\u2223', # ∣
+ 'shortparallel': u'\u2225', # ∥
+ 'nshortmid': u'\u2224', # ∤
+ 'nshortparallel': u'\u2226', # ∦
+ 'smallfrown': u'\u2322', # ⌢ FROWN
+ 'smallsmile': u'\u2323', # ⌣ SMILE
+ 'smallint': u'\u222b', # ∫ INTEGRAL
+ }
+
+left_delimiters = {# rspace='0', lspace='0.22em'
+ 'lvert': '|',
+ 'lVert': u'\u2016' # ‖ DOUBLE VERTICAL LINE
+ }
+
+right_delimiters = {# lspace='0', rspace='0.22em'
+ 'rvert': '|',
+ 'rVert': u'\u2016', # ‖ DOUBLE VERTICAL LINE
+ }
+
sumintprod = ''.join([operators[symbol] for symbol in
['sum', 'int', 'oint', 'prod']])
-# >>> print(l2m.sumintprod)
+# >>> print(sumintprod)
# ∑∫∮∏
-#
+# pre-composed characters for negated symbols
+# see https://www.w3.org/TR/xml-entity-names/#combining
negatables = {'=': u'\u2260',
r'\in': u'\u2209',
r'\equiv': u'\u2262'}
-# cmds/characters allowed in left/right cmds
+# extensible delimiters allowed in left/right cmds
stretchables = {'(': '(',
')': ')',
'[': '[',
@@ -147,7 +173,7 @@ for (key, value) in tex2unichar.mathclose.items():
# **tex2unichar.mathfence}.items():
# stretchables['\\'+key] = value
-# >>> print(' '.join(sorted(set(l2m.stretchables.values()))))
+# >>> print(' '.join(sorted(set(stretchables.values()))))
# ( ) / [ \ ] { | } ‖ ↑ ↓ ↕ ⇑ ⇓ ⇕ ⌈ ⌉ ⌊ ⌋ ⌜ ⌝ ⌞ ⌟ ⟅ ⟆ ⟦ ⟧ ⟨ ⟩ ⟮ ⟯ ⦇ ⦈
@@ -171,33 +197,53 @@ spaces = {'qquad': '2em', # two \quad
# accents ->
# TeX spacing combining
-over = {'acute': u'\u00B4', # u'\u0301',
- 'bar': u'\u00AF', # u'\u0304',
- 'breve': u'\u02D8', # u'\u0306',
- 'check': u'\u02C7', # u'\u030C',
- 'dot': u'\u02D9', # u'\u0307',
- 'ddot': u'\u00A8', # u'\u0308',
- 'dddot': u'\u20DB',
+over = {'acute': u'´', # u'\u0301',
+ 'bar': u'-', # u'\u0304',
+ 'breve': u'˘', # u'\u0306',
+ 'check': u'ˇ', # u'\u030C',
+ 'dot': u'·', # u'\u0307',
+ 'ddot': u'··', # u'\u0308',
+ 'dddot': u'···', # u'\u20DB',
'grave': u'`', # u'\u0300',
'hat': u'^', # u'\u0302',
- 'mathring': u'\u02DA', # u'\u030A',
- 'overleftrightarrow': u'\u20e1',
- # 'overline': # u'\u0305',
- 'tilde': u'\u02DC', # u'\u0303',
- 'vec': u'\u20D7'}
+ 'mathring': u'°', # u'\u030A',
+ 'tilde': u'\u223C', # u'\u0303',
+ 'vec': u'\u20D7',
+ }
+
+wideover = {'overbrace': u'\u23DE', # TOP CURLY BRACKET
+ 'overleftarrow': u'\u2190',
+ 'overleftrightarrow': u'\u2194',
+ 'overline': u'¯',
+ 'overrightarrow': u'\u2192',
+ 'widehat': u'^',
+ 'widetilde': u'~'}
+wideunder = {'underbrace': u'\u23DF',
+ 'underleftarrow': u'\u2190',
+ 'underleftrightarrow': u'\u2194',
+ 'underline': u'_',
+ 'underrightarrow': u'\u2192'}
+
+# Character translations
+# ----------------------
+# characters with preferred alternative in mathematical use
+anomalous_chars = {'-': u'\u2212', # HYPHEN-MINUS -> MINUS SIGN
+ ':': u'\u2236', # COLON -> RATIO
+ }
+# blackboard bold (Greek characters not working with "mathvariant" (Firefox 78)
+mathbb = {u'Γ': u'\u213E', # ℾ
+ u'Π': u'\u213F', # ℿ
+ u'Σ': u'\u2140', # ⅀
+ u'γ': u'\u213D', # ℽ
+ u'π': u'\u213C', # ℼ
+ r'\Gamma': u'\u213E', # ℾ
+ r'\Pi': u'\u213F', # ℿ
+ r'\Sigma': u'\u2140', # ⅀
+ r'\gamma': u'\u213D', # ℽ
+ r'\pi': u'\u213C', # ℼ
+ }
-# all supported math-characters:
-#mathcharacters = dict(letters)
-#mathcharacters.update(operators)
-#mathcharacters.update(tex2unichar.space)
-#
-## >>> l2m.mathcharacters['alpha']
-## 'α'
-## >>> l2m.mathcharacters['{']
-## '{'
-## >>> l2m.mathcharacters['pm']
-## '±'
# MathML element classes
# ----------------------
@@ -205,8 +251,10 @@ over = {'acute': u'\u00B4', # u'\u0301',
class math(object):
"""Base class for MathML elements."""
- nchildren = 1000000
- """Required/Supported number of children"""
+ nchildren = None
+ """Expected number of children or None"""
+ parent = None
+ """Parent node in MathML DOM tree."""
_level = 0 # indentation level (static class variable)
def __init__(self, children=None, inline=None, **kwargs):
@@ -216,7 +264,7 @@ class math(object):
self.children = []
if children is not None:
- if not isinstance(children, list):
+ if not isinstance(children, (list, tuple)):
children = [children]
for child in children:
self.append(child)
@@ -226,7 +274,6 @@ class math(object):
self.attributes['xmlns'] = 'http://www.w3.org/1998/Math/MathML'
if inline is False:
self.attributes['display'] = 'block'
- # self.attributes['displaystyle'] = 'true'
# sort kwargs for predictable functional tests
# as self.attributes.update(kwargs) does not keep order in Python < 3.6
for key in sorted(kwargs.keys()):
@@ -242,8 +289,8 @@ class math(object):
def full(self):
"""Room for more children?"""
-
- return len(self.children) >= self.nchildren
+ return (self.nchildren is not None
+ and len(self.children) >= self.nchildren)
def append(self, child):
"""append(child) -> element
@@ -255,7 +302,7 @@ class math(object):
self.children.append(child)
child.parent = self
node = self
- while node.full():
+ while node is not None and node.full():
node = node.parent
return node
@@ -310,42 +357,55 @@ class math(object):
last_child = child
return xml
-# >>> l2m.math(l2m.mn(2))
+# >>> math(mn(2))
# math(mn(2))
-# >>> l2m.math(l2m.mn(2)).xml()
+# >>> math(mn(2)).xml()
# ['']
#
-# >>> l2m.math(id='eq3')
+# >>> math(id='eq3')
# math(id='eq3')
-# >>> l2m.math(id='eq3').xml()
+# >>> math(id='eq3').xml()
# ['']
#
# use CLASS to get "class" in XML
-# >>> l2m.math(CLASS='test')
+# >>> math(CLASS='test')
# math(CLASS='test')
-# >>> l2m.math(CLASS='test').xml()
+# >>> math(CLASS='test').xml()
# ['']
-# >>> l2m.math(inline=True)
+# >>> math(inline=True)
# math(xmlns='http://www.w3.org/1998/Math/MathML')
-# >>> l2m.math(inline=True).xml()
+# >>> math(inline=True).xml()
# ['']
-# >>> l2m.math(inline=False)
+# >>> math(inline=False)
# math(xmlns='http://www.w3.org/1998/Math/MathML', display='block')
-# >>> l2m.math(inline=False).xml()
+# >>> math(inline=False).xml()
# ['']
-class mrow(math): pass
+class mrow(math):
+ """Group sub-expressions as a horizontal row.
+ """
+ def __init__(self, children=None, nchildren=None, **kwargs):
+ self.nchildren = nchildren
+ math.__init__(self, children)
+ self.attributes = kwargs
-# >>> l2m.mrow(displaystyle='false')
+# >>> mrow(displaystyle='false')
# mrow(displaystyle='false')
class mtable(math): pass
-# >>> l2m.mtable(displaystyle='true')
+# >>> mtable(displaystyle='true')
# mtable(displaystyle='true')
-# >>> l2m.math(l2m.mtable(displaystyle='true')).xml()
+# >>> math(mtable(displaystyle='true')).xml()
# ['']
+
+
+# The elements , , , , , ,
+# , , and
-
-
-
- a
-
- ´
-
-
+
+
+ a
+
+ ´
+
\acute{a} |
-
-
-
- t
-
- ˙
-
-
+
+
+ t
+
+ ·
+
\dot{t} |
-
-
-
- γ
-
- ^
-
-
+
+
+ γ
+
+ ^
+
\hat{\gamma} |
-
-
-
- a
-
- `
-
-
+
+
+ a
+
+ `
+
\grave{a} |
-
-
-
- t
-
- ¨
-
-
+
+
+ t
+
+ ··
+
\ddot{t} |
-
-
-
- α
-
- ˜
-
-
+
+
+ α
+
+ ∼
+
\tilde{\alpha} |
-
-
-
- x
-
- ˘
-
-
+
+
+ x
+
+ ˘
+
\breve{x} |
-
-
-
- t
-
- ⃛
-
-
+
+
+ t
+
+ ···
+
\dddot{t} |
-
-
-
- ı
-
- ⃗
-
-
+
+
+ ı
+
+ ⃗
+
\vec{\imath} |
-
-
-
- a
-
- ˇ
-
-
+
+
+ a
+
+ ˇ
+
\check{a} |
-
-
-
- a
-
- ¯
-
-
+
+
+ a
+
+ -
+
\bar{a} |
-
-
-
- R
-
- ⃗
-
-
+
+
+ R
+
+ ⃗
+
\vec{R} |
@@ -403,7 +371,7 @@ physical system changes in time.
∫
- -∞
+ −∞
∞
@@ -432,7 +400,7 @@ physical system changes in time.
∫
- -∞
+ −∞
∞
@@ -480,7 +448,7 @@ physical system changes in time.
sδ
- (x-x')
+ (x−x')
@@ -498,7 +466,7 @@ physical system changes in time.
sδ
- (x-x')dx'
+ (x−x')dx'
@@ -516,7 +484,7 @@ physical system changes in time.
- -1
+ −1
x<0
diff --git a/docutils/test/functional/input/data/comprehensive-math-test.txt b/docutils/test/functional/input/data/comprehensive-math-test.txt
index 4324709f1..a696789ef 100644
--- a/docutils/test/functional/input/data/comprehensive-math-test.txt
+++ b/docutils/test/functional/input/data/comprehensive-math-test.txt
@@ -136,23 +136,35 @@ Accents
.. class:: colwidths-auto
=========== ============= =========== ============= ============== ================
- `\acute{x}` ``\acute{x}`` `\dot{x}` ``\dot{x}`` `\hat{H}` ``\hat{H}``
- `\bar{v}` ``\bar{v}`` `\ddot{x}` ``\ddot{x}`` `\mathring{x}` ``\mathring{x}``
- `\breve{x}` ``\breve{x}`` `\dddot{x}` ``\dddot{x}`` `\tilde{n}` ``\tilde{n}``
- `\check{x}` ``\check{x}`` `\grave{x}` ``\grave{x}`` `\vec{R}` ``\vec{R}``
+ `\acute{x}` ``\acute{x}`` `\dot{t}` ``\dot{t}`` `\hat{H}` ``\hat{H}``
+ `\bar{v}` ``\bar{v}`` `\ddot{t}` ``\ddot{t}`` `\mathring{x}` ``\mathring{x}``
+ `\breve{x}` ``\breve{x}`` `\dddot{t}` ``\dddot{t}`` `\tilde{n}` ``\tilde{n}``
+ `\check{x}` ``\check{x}`` `\grave{x}` ``\grave{x}`` `\vec{x}` ``\vec{x}``
=========== ============= =========== ============= ============== ================
When adding an accent to an i or j in math, dotless variants can be
obtained with ``\imath`` and ``\jmath``: `\bar \imath`, `\hat{\jmath}`
+(MathML drops the dot automatically).
+
+For adornment that span multiple symbols, see `top and bottom
+embellishments`_.
+
+Font switches
+-------------
+
+TeX’s *math alphabets* correspond to the
+:t:`mathematical alphanumeric symbols` block in Unicode and the
+"mathvariant" `style attribute`__ in MathML. They are “to be used for
+mathematical variables where style variations are important
+semantically”.
+
+__ https://developer.mozilla.org/en-US/docs/Web/MathML/Attribute
-alphabets
----------
.. class:: colwidths-auto
=============== ============================ ==========================
command example result
=============== ============================ ==========================
- ``\boldsymbol`` ``\boldsymbol{\alpha + 3}`` `\boldsymbol{\alpha + 3}`
``\mathbf`` ``\mathbf{r}^2=x^2+y^2+z^2`` `\mathbf{r}^2=x^2+y^2+z^2`
``\mathbb`` ``\mathbb{R \subset C}`` `\mathbb{R \subset C}`
``\mathcal`` ``\mathcal{F}f(x)`` `\mathcal{F}f(x)`
@@ -160,14 +172,40 @@ alphabets
``\mathit`` ``\mathit{\Gamma}`` `\mathit{\Gamma}`
``\mathrm`` ``s_\mathrm{out}`` `s_\mathrm{out}`
``\mathsf`` ``\mathsf x`` `\mathsf x`
- ``\mathtt`` ``\mathtt{0.12}`` `\mathtt{0.12}`
+ ``\mathtt`` ``\mathtt{0.12}`` `\mathtt{0.12}`
=============== ============================ ==========================
-.. with isomath:
- 'mathbfit': 'bold-italic', # isomath
- 'mathsfit': 'sans-serif-italic', # isomath
- 'mathsfbfit': 'sans-serif-bold-italic', # isomath
- with mathrsfs, ... 'mathscr'
+Additional alphabets are defined in LaTeX packages, e.g.
+
+.. class:: colwidths-auto
+
+ =========== ============= ======================
+ TeX command LaTeX package MathML "mathvariant"
+ =========== ============= ======================
+ mathbfit isomath_ bold-italic
+ mathsfit isomath_ sans-serif-italic
+ mathsfbfit isomath_ sans-serif-bold-italic
+ mathscr mathrsfs_ script
+ =========== ============= ======================
+.. _isomath: https://www.ctan.org/pkg/isomath
+.. _mathrsfs: https://www.ctan.org/pkg/mathrsfs
+
+This can be used to typeset vector symbols in **bold** *italic*
+in line with the International Standard [ISO-80000-2].
+``\mathbfit{r}^2=x^2+y^2+z^2`` becomes
+
+.. math:: \mathbfit{r}^2=x^2+y^2+z^2.
+
+
+
+In contrast to the math alphabet selectors, ``\boldsymbol`` only changes
+the *font weight*. In LaTeX, it can be used to get a bold version of any
+mathematical symbol (for other output formats, results are mixed):
+
+.. math::
+ \boldsymbol{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}
+
+
Arrows
@@ -201,27 +239,26 @@ Binary operators
.. class:: colwidths-auto
================== ==================== ================= =================== ================== ====================
- `*` ``*`` `\circledast` ``\circledast`` `\odot` ``\odot``
- `+` ``+`` `\circledcirc` ``\circledcirc`` `\ominus` ``\ominus``
- `-` ``-`` `\circleddash` ``\circleddash`` `\oplus` ``\oplus``
- `:` ``:`` `\cup` ``\cup`` `\oslash` ``\oslash``
- `\Cap` ``\Cap`` `\curlyvee` ``\curlyvee`` `\otimes` ``\otimes``
- `\Cup` ``\Cup`` `\curlywedge` ``\curlywedge`` `\pm` ``\pm``
- `\amalg` ``\amalg`` `\dagger` ``\dagger`` `\rightthreetimes` ``\rightthreetimes``
- `\ast` ``\ast`` `\ddagger` ``\ddagger`` `\rtimes` ``\rtimes``
- `\bigcirc` ``\bigcirc`` `\diamond` ``\diamond`` `\setminus` ``\setminus``
- `\bigtriangledown` ``\bigtriangledown`` `\div` ``\div`` `\smallsetminus` ``\smallsetminus``
- `\bigtriangleup` ``\bigtriangleup`` `\divideontimes` ``\divideontimes`` `\sqcap` ``\sqcap``
- `\boxdot` ``\boxdot`` `\dotplus` ``\dotplus`` `\sqcup` ``\sqcup``
- `\boxminus` ``\boxminus`` `\doublebarwedge` ``\doublebarwedge`` `\star` ``\star``
- `\boxplus` ``\boxplus`` `\gtrdot` ``\gtrdot`` `\times` ``\times``
- `\boxtimes` ``\boxtimes`` `\intercal` ``\intercal`` `\triangleleft` ``\triangleleft``
- `\bullet` ``\bullet`` `\leftthreetimes` ``\leftthreetimes`` `\triangleright` ``\triangleright``
- `\cap` ``\cap`` `\lessdot` ``\lessdot`` `\uplus` ``\uplus``
- `\cdot` ``\cdot`` `\ltimes` ``\ltimes`` `\vee` ``\vee``
- `\centerdot` ``\centerdot`` `\mp` ``\mp`` `\veebar` ``\veebar``
- `\circ` ``\circ`` `\wedge` ``\wedge``
- .. `\wr` ``\wr``
+ `*` ``*`` `\circledast` ``\circledast`` `\ominus` ``\ominus``
+ `+` ``+`` `\circledcirc` ``\circledcirc`` `\oplus` ``\oplus``
+ `-` ``-`` `\circleddash` ``\circleddash`` `\oslash` ``\oslash``
+ `:` ``:`` `\cup` ``\cup`` `\otimes` ``\otimes``
+ `\Cap` ``\Cap`` `\curlyvee` ``\curlyvee`` `\pm` ``\pm``
+ `\Cup` ``\Cup`` `\curlywedge` ``\curlywedge`` `\rightthreetimes` ``\rightthreetimes``
+ `\amalg` ``\amalg`` `\dagger` ``\dagger`` `\rtimes` ``\rtimes``
+ `\ast` ``\ast`` `\ddagger` ``\ddagger`` `\setminus` ``\setminus``
+ `\bigcirc` ``\bigcirc`` `\diamond` ``\diamond`` `\smallsetminus` ``\smallsetminus``
+ `\bigtriangledown` ``\bigtriangledown`` `\div` ``\div`` `\sqcap` ``\sqcap``
+ `\bigtriangleup` ``\bigtriangleup`` `\divideontimes` ``\divideontimes`` `\sqcup` ``\sqcup``
+ `\boxdot` ``\boxdot`` `\dotplus` ``\dotplus`` `\star` ``\star``
+ `\boxminus` ``\boxminus`` `\doublebarwedge` ``\doublebarwedge`` `\times` ``\times``
+ `\boxplus` ``\boxplus`` `\gtrdot` ``\gtrdot`` `\triangleleft` ``\triangleleft``
+ `\boxtimes` ``\boxtimes`` `\intercal` ``\intercal`` `\triangleright` ``\triangleright``
+ `\bullet` ``\bullet`` `\leftthreetimes` ``\leftthreetimes`` `\uplus` ``\uplus``
+ `\cap` ``\cap`` `\lessdot` ``\lessdot`` `\vee` ``\vee``
+ `\cdot` ``\cdot`` `\ltimes` ``\ltimes`` `\veebar` ``\veebar``
+ `\centerdot` ``\centerdot`` `\mp` ``\mp`` `\wedge` ``\wedge``
+ `\circ` ``\circ`` `\odot` ``\odot`` `\wr` ``\wr``
================== ==================== ================= =================== ================== ====================
@@ -264,7 +301,7 @@ Letterlike symbols
`\mho` ``\mho`` `\complement` ``\complement`` `\gimel` ``\gimel`` `\hslash` ``\hslash``
`\Bbbk` ``\Bbbk`` `\Finv` ``\Finv`` `\daleth` ``\daleth`` `\imath` ``\imath``
`\ell` ``\ell`` `\Game` ``\Game`` `\nabla` ``\nabla`` `\partial` ``\partial``
-`\wp` ``\wp``
+`\wp` ``\wp``
======= ========== ============= =============== ========= =========== ========== ============
@@ -365,7 +402,18 @@ Use ``.`` for "empty" delimiters:
Top and bottom embellishments
-----------------------------
-TODO
+Visually similar to accents_ but generally applied to multiple symbols.
+
+.. class:: colwidths-auto
+
+ ========================== ============================ =========================== =============================
+ `\widetilde{abi}` ``\widetilde{abi}`` `\widehat{abi}` ``\widehat{abi}``
+ `\overline{abi}` ``\overline{abi}`` `\underline{abi}` ``\underline{abi}``
+ `\overbrace{abi}` ``\overbrace{abi}`` `\underbrace{abi}` ``\underbrace{abi}``
+ `\overleftarrow{abi}` ``\overleftarrow{abi}`` `\underleftarrow{abi}` ``\underleftarrow{abi}``
+ `\overrightarrow{abi}` ``\overrightarrow{abi}`` `\underrightarrow{abi}` ``\underrightarrow{abi}``
+ `\overleftrightarrow{abi}` ``\overleftrightarrow{abi}`` `\underleftrightarrow{abi}` ``\underleftrightarrow{abi}``
+ ========================== ============================ =========================== =============================
Extensible arrows
-----------------
@@ -416,47 +464,65 @@ internal LaTeX2MathML
* Shorthands for combined named operators
- =============== =================
- `\liminf` ``\liminf``
- `\limsup` ``\limsup``
- `\injlim` ``\injlim``
- `\projlim` ``\projlim``
- `\varinjlim` ``\varinjlim``
- `\varliminf` ``\varliminf``
- `\varlimsup` ``\varlimsup``
- `\varprojlim` ``\varprojlim``
- =============== =================
+ ========== ============ ============= =============== ==================
+ `\liminf` ``\liminf`` `\varliminf` ``\varliminf`` `\underline{\lim}`
+ `\limsup` ``\limsup`` `\varlimsup` ``\varlimsup`` `\overline{\lim}`
+ `\injlim` ``\injlim`` `varinjlim` ``\varinjlim``
+ `\projlim` ``\projlim`` `varprojlim` ``\varprojlim``
+ ========== ============ ============= =============== ==================
* Implement ``\circledS``? (in short-math-guide.pdf but not in mathematical Unicode characters)
- ``\widetilde{xxx}``
- ``\widehat{xxx}``
-
Tests
==========
+Font changes
+------------
-LICR macros in different alphabets:
+Math alphabet macros change the default alphabet ("mathvariant" in
+MathML), leaving some symbols unchanged:
-.. math::
+:normal: `abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R`
+:mathrm: `\mathrm{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
+:mathit: `\mathit{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
+:mathsf: `\mathsf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
+:mathbb: `\mathbb{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
+:mathbf: `\mathbf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R`
- \text{normal: } &
- abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar \\
- \text{mathrm: } &
- \mathrm{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar} \\
- \text{mathit: } &
- \mathit{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar} \\
- \text{mathsf: } &
- \mathsf{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar} \\
- \text{mathbb: } &
- \mathbb{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar} \\
- \text{mathbf: } &
- \mathbf{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar} \\
- \text{boldsymbol: } &
- \boldsymbol{abs(x) \pm \alpha \approx \Gamma \forall x \in R \bigstar}
-
-All blackboard-bold characters:
+Unicode supports the following blackboard-bold characters:
`\mathbb{a \ldots z A \ldots Z 0 \ldots 9
\mathbb\Gamma \mathbb{\Pi} \mathbb {\Sigma}\mathbb\gamma \mathbb\pi}`.
+The package mathrsfs_ (and some drop-in replacements) define the ``\mathscr``
+macro that selects a differently shaped "script" alphabet.
+Compare `\mathscr{A, B, …, Z, a, b, …, z}`
+with `\mathcal{A, B, …, Z, a, b, …, z}`.
+
+.. _rsfs: https://ctan.org/pkg/mathrsfs
+
+Inferred s in MathML
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The elements , , , , , ,
+, and treat their contents as a single inferred mrow
+formed from all their children.
+
+.. math:: a = \sqrt 2, b = \sqrt{1+x^2}, c = \sqrt\frac{sin(x)}{23}
+
+inline: :math:`a = \sqrt 2, b = \sqrt{1+x^2}, c = \sqrt\frac{sin(x)}{23}`.
+
+Accents vs. embellishments
+--------------------------
+
+MathML drops dots on "i" and "j" with accents:
+
+.. math:: \vec i \ne \overrightarrow i
+ \text{ and } \vec\lim \ne \overrightarrow\lim.
+
+Accents should be nearer to the base (in Firefox 78, it's vice versa!):
+
+.. math:: \vec a \vec l \ne \overrightarrow a \overrightarrow l
+
+ \bar a \bar l \ne \overline a \overline l
+
--
cgit v1.2.1