] > pmathx.modes: Additional constructs for p-MathML

pmathx.modes: Additional constructs for p-MathML

These modes provide additional mathematics constructs and their representation in p-MathML.

1 Synopsis

The p-MathML extension module pmathx.modes in the directory GLOSS/mv/pmath/ contains code for quick authoring of much standard mathematics. These look rather like p-MathML constructs, but they are all unofficial and synthetic, hence they live in this module.

2 Some details

I'll just give examples here. See the source for how the code was generated.

2.1 Tokens

n!=supf(x):xS, 28, log9(27)=32, ln=1.

expπi=-1, sin2(x)+cos2(x)=1. trig=sincostan, htrig=sinhcoshtanh.

minXinfX, maxXsupX, infY=limY.

2.2 Constructs

Quick subscript, superscript, under, over, etc: x2=a0, n=1an, limnan. Also x12=y21, n=1an, f(x)x, 12f(x)x, etc.

Quick fractions, 12, x+y7.

Quantifiers, x x=x, x<2 x=1.

Constructions with fences, 1234x, x:x2=1=-11, ε>0 δ>0 x(a-δ,a+δ) f(x)-f(a)<ε.

Overline and underline, x+y¯, 2-x̲.

Series and products, n=11n=, nPrimes1n2.

3 The code

!declare-prefix @prefix[x] @uri[http://gloss.bham.ac.uk/mv/pmath/pmathx] {
!declare-prefix @prefix[m] @uri[http://gloss.bham.ac.uk/mv/pmath/pmathml] {
!mode @name[x:mrow-item] @template[m:mrow-item] @type[execute]
  !hook @mode[m:mrow-item] @action[execute]

Quick infix sup, sup, under, over operators, etc: eg x2=a0, nan, n=0an.

  !elt @fullname[$sub||sup||under||over]
    !infix @name[$\{m:pref\}m$q] 
      !process-tokens @mode[m:math-object]
  !elt @fullname[$subsup||underover]
    !infix @name[$\{m:pref\}m$q]
      !process-tokens @mode[m:math-object]
      !process-tokens @mode[m:math-object]

Quick fractions eg 12.

  !elt @fullname[by]
    !infix @name[$\{m:pref\}mfrac] !process-tokens @mode[m:math-object]

Quantifiers.

  fa 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}mrow]
        !element @name[$\{m:pref\}mo] !entity-reference @name[#x02200];
        !process-tokens @mode[m:math-object]
      !element @name[$\{m:pref\}mo] !entity-reference @name[#x000A0];
      !process-tokens @mode[m:math-object]
  ex 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}mrow]
        !element @name[$\{m:pref\}mo] !entity-reference @name[#x02203];
        !process-tokens @mode[m:math-object]
      !element @name[$\{m:pref\}mo] !entity-reference @name[#x000A0];
      !process-tokens @mode[m:math-object]

Constructions that use fences.

  setl
    !element @name[$\{m:pref\}mfenced] 
      !attribute @name[open][\{]
      !attribute @name[close][\}]
      !process-tokens @mode[m:mrow-content]
  setp
    !element @name[$\{m:pref\}mfenced]
      !attribute @name[open][\{]
      !attribute @name[close][\}]
      !element @name[$\{m:pref\}mrow] 
        !process-tokens @mode[m:math-object]
        !element @name[$\{m:pref\}mo] 
          !attribute @name[form] [infix]
          [:]
        !process-tokens @mode[m:math-object]
  abs
    !element @name[$\{m:pref\}mfenced]
      !attribute @name[open][|]
      !attribute @name[close][|]
      !element @name[$\{m:pref\}mrow] !process-tokens @mode[m:math-object]

Overline, underline, etc.

  overline 
    !element @name[$\{m:pref\}mover] @accent[true]
      !process-tokens @mode[m:math-object]
      !element @name[$\{m:pref\}mo] !entity-reference @name[#x000AF] ; TO DO: should this be 000AF 00304 or 00305?
  underline 
    !element @name[$\{m:pref\}munder] @accent[true]
      !process-tokens @mode[m:math-object]
      !element @name[$\{m:pref\}mo] !entity-reference @name[#x00332] ; TO DO: should this be 0005F 00331 or 00332?

Summations, products etc.

  series 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}munderover]
        !element @name[$\{m:pref\}mo] !entity-reference @name[#x02211] 
        !process-tokens @mode[m:math-object] ; underscript
        !process-tokens @mode[m:math-object] ; overscript
      !element @name[$\{m:pref\}mrow]
        !process-tokens @mode[m:mrow-content] ; content
  product 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}munderover]
        !element @name[$\{m:pref\}mo] !entity-reference @name[#x0220F] 
        !process-tokens @mode[m:math-object] ; underscript
        !process-tokens @mode[m:math-object] ; overscript
      !element @name[$\{m:pref\}mrow]
        !process-tokens @mode[m:mrow-content] ; content
  div 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}mo]!entity-reference @name[#x02207]
      !element @name[$\{m:pref\}mo]!entity-reference @name[#x000B7]
      !element @name[$\{m:pref\}mrow]
        !process-tokens @mode[m:math-object]
  grad 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}mo]!entity-reference @name[#x02207]
      !element @name[$\{m:pref\}mrow]
        !process-tokens @mode[m:math-object]
  curl 
    !element @name[$\{m:pref\}mrow]
      !element @name[$\{m:pref\}mo]!entity-reference @name[#x02207]
      !element @name[$\{m:pref\}mo]!entity-reference @name[#x000D7]
      !element @name[$\{m:pref\}mrow]
        !process-tokens @mode[m:math-object]
  !include @mode[m:mrow-item] @hook[execute]

!mode @name[x:token-dictionary] @template[m:token-dictionary] @type[execute]
  !hook @mode[m:token-dictionary] @action[execute] 

Some other stuff I have added.

  factorial ${m:token-type}="mo" ${m:form}="postfix" ${m:text}="!"
  supremum ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="sup"
  infimum ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="inf"
  divides ${m:token-type}="mo" ${m:form}="infix" ${ref}="#02223"
  log ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="log"
  ln ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="ln"
  exp ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="exp"
  sin ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="sin"
  cos ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="cos"
  tan ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="tan"
  sinh ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="sinh"
  cosh ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="cosh"
  tanh ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="tanh"
  max ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="max"
  min ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="min"
  lim ${m:token-type}="mo" ${m:form}="prefix" ${m:text}="lim"
  !include @mode[m:token-dictionary] @hook[execute]

}; !declare-prefix
}; !declare-prefix

This file is part of the GLOSS system, Copyright Richard Kaye http://gloss.bham.ac.uk/. Usage permitted under the GPL. No Warranty.

This page is copyright. Web page design and creation by GLOSS.