GetWiki:Custom Formulas

edit this, make it better, get wiki

GetWiki&OverviewCustom Messages/Links/Images/Formulas/Chars&Symbols1.0/2.0/InterWikiFeed/Web
table of contents 

Background

GetWiki allows TeX markup for mathematics and logic formulas. Instead of assuming complicated dependencies and server resources on all GetWiki-based wikis just to generate PNG images, GetWiki translates TeX into simple XHTML markup1, with LaTeX parsing and image rendering available as a deprecated option2. In the future, as browsers become even more XML capable, GetWiki could easily generate MathML instead, which is also a subset of XML.

Mathematics and Logic formulas are rendered by placing your TeX code inside interchangeable <formula>, <logic> or <math> tags. It is your personal, or philosophical, preference as to which of these tags you use. Line breaks and other wiki formatting within the tags are not rendered3.

Using this approach has many advantages:

Very complex formulas and matrices might very well fail to render correctly under this approach, so proofreading is necessary, and perhaps, further translation by the author(s) from TeX to plain text. Unfortunately, there is currently no perfect server-side solution to translating TeX for the web, so the approach in GetWiki is a compromise4, favouring standards and ease of setup: The advantages for a wiki outweigh the disadvantages5, and migration toward future developments in XML is trivial.


If you find a glaring omission of a symbol, function or argument which could be better represented using plain text entities, please post on the talk page for this article.


Formula Tags

feature syntax rendered
equivalent tags <formula>{r} is odd, \cos {s} \times {r}</formula> r is odd, cos sr
<logic>{p} \to {q}, {A} \iff {B}</logic> pq, AB
<math>({r} + {s}) = ({t} + {v})</math> (r + s) = (t + v)

Simple Formulas

feature syntax rendered
standard functions \sin x + \ln y + \operatorname{sgn} z sin x + ln y + sgn z
\sin {y} + \ln x + \cos z sin y + ln x + cos z
Modular Algorithm s_k \equiv 0 \pmod{m} sk ≡ 0 (modm
Derivatives \nabla \partial x dx \dot x \ddot y ∇ ∂ x dx deriv(⋅) x deriv(⋅⋅) y
Sets \forall x \not\in \varnothing \subseteq A \cap B \cup \exists \{x,y\} \times C ∀ x not∈ ∅ ⊃eq A ∩ B ∪ ∃ x,y ⋅ C
Logic p \land \bar{q} \to p\lor \lnot q \therefore p ∧ q → p∨ ˜ q therefore
Root \sqrt{2}\approx 1.4 2≈ 1.4
\sqrt[n]{x} √[n]x
Relations \sim \simeq \cong \le \ge \equiv \not\equiv \approx \ne ∼ ≅ ≅ ≤ ≥ ≡ ≠ ≈ ≠
Geometric \triangle \angle \perp \| 45^\circ Δ ∠ ⊥ || 45ο
Arrows
\leftarrow \rightarrow \leftrightarrow
\longleftarrow \longrightarrow
\mapsto \longmapsto
\nearrow \searrow \swarrow \nwarrow
\uparrow \downarrow \updownarrow
← → ↔ 
longleftarrow longrightarrow 
→ longmapsto 
nearrow searrow swarrow nwarrow 
↑ ⇓ updownarrow 
\Leftarrow \Rightarrow \Leftrightarrow
\Longleftarrow \Longrightarrow \Longleftrightarrow
\Uparrow \Downarrow \Updownarrow
⇐ ⇒ ⇔ 
Longleftarrow Longrightarrow Longleftrightarrow 
⇑ ↓ Updownarrow 
Special \oplus \otimes \pm \mp \hbar \dagger \ddagger \star \circ \cdot \times \bullet \infty ⊕ ⊗ ± ± hbar † ‡ * ο ⋅ ⋅ • ∞

Subscripts, Superscripts

feature syntax rendered
Superscript a^2 a2
Subscript a_2 a2
Grouping a^{2+2} a2+2
a_{i,j} ai,j
Combining sub & super x_2^3 x23
Derivative x' x'
x^\prime x
x\prime x′
Underlines & Overlines
(use \> to space)
\hat a \bar b \vec c \widehat {d e f} \overline {g h i} \underline {j k l} ^ a b c [^d] e f g h i j k l
\widehat {d\>e\>f} \overline {g\>h\>i} \underline {j\>k\>l} [^d e f] g h i j k l
Sum \sum_{k=1}^N k^2 Σk=1N k2
Product \prod_{i=1}^N x_i i=1N xi
Limit \lim_{n \to \infty}x_n limn → ∞xn
Integral \int_{-N}^{N} e^x\, dx ∈t-NN ex dx
Line Integral \oint_{C} x^3\, dx + 4y^2\, dy ointC x3 dx + 4y2 dy

Fractions, Matrices, Multilines

feature syntax rendered
Fractions \frac{2}{4} or {2\over4} 2/4 or 2/4
Binomial Coefficients n or k n or k
Matrices \begin{pmatrix} x & y \\ z & v \end{pmatrix} matrix( x & y z & v )
\begin{bmatrix} 0 & \cdots & 0 \\ \vdots &

\ddots & \vdots \\ 0 & \cdots &

0\end{bmatrix}
matrix[ 0 & ⋅s & 0 vdots & deriv(⋅⋅)s & vdots 0 & ⋅s & 0]
\begin{Bmatrix} x & y \\ z & v \end{Bmatrix} matrix{ x & y z & v }
\begin{vmatrix} x & y \\ z & v \end{vmatrix} matrix| x & y z & v |
\begin{Vmatrix} x & y \\ z & v \end{Vmatrix} matrix|| x & y z & v ||
\begin{matrix} x & y \\ z & v \end{matrix} matrix x & y z & v endmatrix
Case Distinctions f(n) = \left \{ \begin{matrix} n/2, & \mbox{if }n\mbox{ is

even} \\ 3n+1, & \mbox{if }n\mbox{ is odd}

\end{matrix} \right.
f(n) = (  matrix n/2, & if n is even 3n+1, & if n is odd endmatrix ).
Multiline Equations \begin{matrix}f(n+1) & = & (n+1)^2 \\ \ & = & n^2 + 2n + 1 \end{matrix} matrixf(n+1) & = & (n+1)2 & = & n2 + 2n + 1 endmatrix

Fonts

feature syntax rendered
Greek Letters \alpha \beta \gamma \Gamma \phi \Phi \Psi\ \tau \Omega α β γ Γ φ Φ Ψ τ Ω
Blackboard Bold x\in\mathbb{R}\sub\mathbb{C} x∈RC
Boldface (Vectors) \mathbf{x}\cdot\mathbf{y} = 0 xy = 0
Boldface (Greek) \boldsymbol{\alpha} + \boldsymbol{\beta} + \boldsymbol{\gamma} α + β + γ
Fraktur Typeface \mathfrak{a} \mathfrak{B} Fraktura FrakturB
Script \mathcal{ABC} ScriptABC
Hebrew Alphabet \aleph \beth \gimel \daleth aleph beth gimel daleth
Italics \mbox{abc} abc
\mbox{if} n \mbox{is even} if n is even
\mbox{if }n\mbox{ is even} if n is even

Parenthesizing Expressions

feature syntax rendered
Example ( \frac{1}{2} ) ( 1/2 )
Example ( {1}\over{2} ) ( 1/2 )
Example \left ( \frac{1}{2} \right ) ( ( 1/2 ) )

You can use various delimiters with \left and \right:

feature syntax rendered
Parentheses \left ( A \right ) ( ( A ) )
Brackets \left [ A \right ] ( [ A ) ]
Braces \left \{ A \right \} A )
Angle Brackets \left \langle A \right \rangle ( ⟨ A ) ⟩
Bars and Double Bars \left | A \right | and \left \| B \right \| ( | A ) | and ( || B ) ||

Delimiters can be mixed,
as long as \left and \right match

\left [ 0,1 \right )
\left \langle \psi \right |

( [ 0,1 ) )
( ⟨ ψ ) |

Use \left. and \right. if you don't
want a delimiter to appear:
\left . \frac{A}{B} \right \} \to X ( . A/B ) → X

Spacing

feature syntax rendered
Doubled-Double Space a \qquad b a      b
Double Space (quad) a \quad b a    b
Large Space a\;b a  b
Medium Space a\>b a b
Small Space (uses CSS) a\,b ab
No Space ab ab
Negative Space (uses CSS) a\!b ab

Legacy Code

Forcing PNG rendering2 is ignored, such as placing \,\! (small space and negative space, which cancel out) inside your tags. To turn on PNG rendering, the wiki administrator must toggle the setting in LocalSettings.php and ensure the dependency tree is installed and functioning (not recommended).

syntax rendered
a^{2+2} a2+2
a^{2+2} \,\! a2+2
\int_{-N}^{N} e^x\, dx ∈t-NN ex dx
\int_{-N}^{N} e^x\, dx \,\! ∈t-NN ex dx

Notes

  1. The PNG image generation is a great feature, but good only for a narrow use, and many developers are moving away from such solutions, toward standards-based XML, of which XHTML is a subset. The images certainly look nicer to the eye at first glance (on a white page, at least), but because their formulae cannot be indexed or searched, and because host systems sometimes cannot be configured correctly, the image-generation solution is neither standards-based nor accessible. In short, such solutions are behind the times.
  2. If you must, a toggle in LocalSettings.php will turn on the PNG rendering of formulae, assuming you have LaTeX, Divips, and Ghostscript installed, and only if their hidden and inconsistent dependencies are installed, which is different for each system. Also, download the texvc (+/- 400k) utility and place it in your installation directory. The related user options have been deprecated.
  3. This text approach has been tested with the formulas on this page, and seems to work perfectly for simple to intermediate formulas, but when your formulas become very complex, the text approach may not give the best results. This is, after all, a compromise. Consider typing our your fomulas using standard HTML/XHTML entities rather than using TeX, or adding an explanation for a complex formula.
  4. This was a problem on Wikinfo with this solution, where the host systems simply could not be configured correctly to support the assumptions built into MediaWiki. It was not only the image generation, but the very parsing of TeX with LaTeX, which was the problem. Weeks of testing resulted in having to lock out the settings from MediaWiki defaults (and eventually led to GetWiki).
  5. Unfortunately, along with problems with complex equations, some older browsers cannot display a few of the characters from the extended entity lists, and very old browsers cannot display the few CSS tweaks used, mentioned above. However, this has been kept to a minimum, and the character data is still indexable, searchable, and portable. CSS is used where actual characters are not available, such as negative spaces, or overlines.

GetWiki&OverviewCustom Messages/Links/Images/Formulas/Chars&Symbols1.0/2.0/InterWikiFeed/Web

External Links


Some content adapted from the MetaWikipedia article "MediaWiki User's Guide: Editing mathematical formulae" under the GNU Free Documentation License.


about GetWiki
recent changes
random page
xml news feed
wiki functions
GetWiki forums
site news
water cooler