Wikipedia:WikiProject Mathematics/Typography

Mathematical writing fundamentally involves formulas, whose typography is often quite complicated and difficult. This page hopes to serve as a central location for discussion of issues of mathematical typography on Wikipedia.

Current Issues
The sizing of texhtml (TeX code, rendered as HTML) and PNGs are often grossly inconsistent with the size of HTML text, and this varies between browser configurations.
 * Inconsistent sizing:

As a preliminary measure, a calibration Help page should be created (I’ll do this – Nils).

If texhtml is too big for some, it makes inline TeX unusable – the output is ugly and likely to be painstakingly corrected by other editors to better-rendering but hard-to-edit HTML, which is suboptimal for all.

If PNG is too big for some, it is often then hacked around using  which both messes with spacing, and renders too small for those whose PNG rendering is properly calibrated.

Compare: $$x+y$$ $$x+y\,$$ x&amp;nbsp;+&amp;nbsp;y which display as:
 * $$x+y$$
 * $$x+y\,$$
 * x + y

To my eye, the TeX code is much more readable, but (in my setup) renders more poorly simply due to being too large (forced PNG is acceptably sized, but suboptimal and a hack). This is more visible inline, with capitals: the expression $$X+Y$$ is too large, compared to $$X+Y\,$$ and X + Y.

For others the texhtml renders correctly, but the PNG is displayed too large.

Continuing on this line, \scriptstyle should never be necessary.

\scriptstyle is used in some places as a hack to produce smaller PNG output, due to PNG output being too large. This has several problems: It should not be necessary, and PNG rendering should be fixed instead.
 * the output is too small on some displays
 * it is verbose
 * it breaks spacing, notably super/sub-scripts

Inline equations should be set in \textstyle as in while displayed equations should be set in \displaystyle as in:
 * $$ defaults to \displaystyle:

However, by default all equations are set in \displaystyle and one must manually specify \textstyle for inline equations, which is verbose and rarely done, as in: Allowing a shorter way of doing this would be much better. Concretely, this could be done by adding another tag, as in ipsum 2^3 dolor 23 sit amet, consectetur a_i\, adipisicing a_i elit, ai sed do a_i^n\, eiusmod a_i^n tempor ain incididunt

Note that the vertically balanced formulas (sub and superscripts) have roughly correct baseline, though those with just sub- or super- scripts are significantly off. This is apparently very difficult to fix.

Linebreaks may be inserted between and trailing punctuation, such as:
 * Linebreak between $$ and trailing punctuation:
 * $$x+y$$

This can be fixed either by including the punctuation within math mode (which may result in ugly rendering, or using, which is verbose. Ideally this would not be necessary.

Goals
Math formulas should serve readers and editors, and accordingly should be:
 * Good typesetting: displayed legibly, correctly, and attractively both on-screen and in print
 * Easy writing: easy to write and edit for people from varied backgrounds – notably via TeX, HTML, and graphical equation editors
 * Able to be transformed into other forms (e.g., read by screen-readers).

Mathematical typesetting software can be difficult to write and maintain, and thus one also has the considerations of developers. Ideally, typography will "just work", but accommodations should be made if something is difficult to implement in software.

General issues
Some general issues to be aware of:
 * consistent display in both TeX-to-PNG and TeX-to-HTML rendering
 * consistent display in both TeX authoring and HTML authoring
 * formula size – legible size, consistent with normal text
 * both for texhtml and PNG display
 * inline formula alignment (PNGs may in particular be too low)
 * line spacing with inline formulas
 * serif vs. sans-serif – PNG rendering defaults to serif fonts, but the default skin uses sans-serif fonts, which creates a clash
 * users can change fonts and font sizes – how does rendering (esp. PNG) react?

Technical limitations
There are various limits on math typesetting due to: Please list here as relevant.
 * Different web browsers and different operating systems
 * Different fonts in the browser
 * limitations of texvc

Infrastructure
Math typesetting works as follows: …and MathML output.
 * Pure HTML rendering works as HTML
 * math renders the HTML in the texhtml CSS style
 * TeX rendering (using mode) uses:
 * texvc for PNG rendering
 * is put in a texhtml CSS style when rendered as HTML
 * There are also various Wikipedia templates used in some HTML rendering.

Rendering depends on: Safest way to test default rendering is to view a page while not logged in, on a fresh install or public computer, rather than on your own account & browser.
 * browser
 * operating system
 * wiki configuration – “My preferences → Appearance → Skin/Math”
 * browser configuration (font size and font face, notably)

Enhancements
Long-term desirable enhancements include: However, these likely would require significant development work.
 * A formula editor, to make it easier for novices to write equations.
 * Easier creation of commutative diagrams, ideally including:
 * Xy-pic support
 * A graphical editor (for simple equations)

Resources

 * Help:Displaying a formula
 * Manual of Style/Mathematics
 * Typographical conventions in mathematical formulae
 * MediaWiki:Common.css – defines .texhtml CSS style for all skins (see also Catalogue of CSS classes)
 * Rendering math – comparison of three conventional encodings of a formula in Wikipedia
 * texvc (discontinued in 2012)

Participants
To join and signal your interest, please:
 * watch this page
 * list yourself below, using  to sign your name,
 * and include particular interests, if any.

Participants:
 * Nils von Barth (nbarth) (talk) – interested in making it easy to write formula that are displayed acceptably (notably, easy to write in either TeX or HTML)
 * Michael Hardy (talk) 17:05, 15 April 2010 (UTC)
 * CRGreathouse (t | c) 19:42, 15 April 2010 (UTC)
 * <span style="font-family:'Trebuchet MS',sans-serif"> — Edokter  ( talk ) — CSS styling and typography
 * Richard Gill (talk) I'm playing with mathJax at the moment. I agree it could be the way of the future. 18:03, 21 August 2011 (UTC)
 * Matt Westwood 05:56, 22 August 2011 (UTC) I believe that universal use of mathJax is the way to go - but it means amending the LaTeX on many pages because of inconsistency between mathJax and MediaWiki interpreters.

Other rendering engines

 * MathJax
 * User:Nageh/mathJax
 * mw:Extension:Blahtex