12
Cahiers O m EXPERIENCES TYPESETTING OPENTYPE MATH WITH LUAL A T E X AND XEL A T E X P Ulrik Vieth Cahiers GUTenberg,n 56 (2011), p. 116-126. <http://cahiers.gutenberg.eu.org/fitem?id=CG_2011___56_116_0> © Association GUTenberg, 2011, tous droits réservés. L’accès aux articles des Cahiers GUTenberg (http://cahiers.gutenberg.eu.org/), implique l’accord avec les conditions générales d’utilisation (http://cahiers.gutenberg.eu.org/legal.html). Toute utilisation commerciale ou impression systématique est constitutive d’une infraction pénale. Toute copie ou impression de ce fichier doit contenir la présente mention de copyright.

Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Cahiers

O

m EXPERIENCES TYPESETTING OPENTYPEMATH WITH LUALATEX AND XELATEXP Ulrik Vieth

Cahiers GUTenberg n 56 (2011) p 116-126

lthttpcahiersgutenbergeuorgfitemid=CG_2011___56_116_0gt

copy Association GUTenberg 2011 tous droits reacuteserveacutes

Lrsquoaccegraves aux articles des Cahiers GUTenberg(httpcahiersgutenbergeuorg)implique lrsquoaccord avec les conditions geacuteneacuteralesdrsquoutilisation (httpcahiersgutenbergeuorglegalhtml)Toute utilisation commerciale ou impression systeacutematiqueest constitutive drsquoune infraction peacutenale Toute copie ou impressionde ce fichier doit contenir la preacutesente mention de copyright

Experiences Typesetting OpenType Math withLuaLATEX and XƎLATEXZkušenosti se sazbou matematiky ve formaacutetuOpenType math v LuaLATEXu a XƎLATEXu

Ulrik Vieth

Abstract When LuaTEX first provided support for OpenType math ty-pesetting in version 040 high-level macro support for math typesettingwas first developed for ConTEXt MkIV while support for LuaLATEX wasinitially limited to a very low-level or non-existent In the meantime thisgap has been closed by recent developments on macro packages such asluaotfload fontspec and unicode-math so LATEX users are now providedwith a unified high-level font selection interface for text and math fontsthat can be used equally well with both LuaLATEX and XƎLATEX Whilea unified high-level interface greatly improves document interchange andeases transitions between systems it does not guarantee that identicalinput will always produce identical output on different engines as thereare significant differences in the underlying implementations of math ty-pesetting algorithms While LuaTEX provides a full-featured implemen-tation of OpenType math XƎTEX has taken a more limited approachbased on a subset of OpenType parameters to provide the functionalityof traditional TEX engines

Given the possibility of running exactly the same test files on bothengines it now becomes feasible to study those differences in detail andto compare the results Hopefully this will allow to draw conclusionshow the quality of math typesetting is affected and could be improved bytaking advantage of a more sophisticated full-featured OpenType mathimplementationKey words LuaLATEX XƎLATEX OpenType math math typesettingfontspec package Cambria Asana XITS Neo Euler

Abstrakt Jelikož LuaTEX podporuje Open Type math až od verze 040byla podpora matematickeacute sazby na vyššiacute uacuterovni vytvořena nejprve proConTEXt MkIV zatiacutemco podpora pro LuaLATEX byla niacutezkaacute nebo nebylažaacutednaacute Dalšiacute vyacutevoj však tuto mezeru zacelil ndash uživateleacute LATEXu majiacute nyniacutek dispozici jednotneacute rozhraniacute pro připojeniacute fontů pro běžnyacute text i promatematickou sazbu pomociacute baliacutečků luaotfload fontspec a unicode-math

116 doi 1053002011-2-4116

obojiacute lze celkem stejně dobře využiacutet v LuaLATEXu i v XƎLATEXu I kdyžtoto jednotneacute rozhraniacute značně zjednodušuje vyacuteměnu dokumentů i přenosmezi různyacutemi systeacutemy nezaručuje že tentyacutež vstup vytvořiacute vždy tentyacutežvyacutestup na různyacutech počiacutetačiacutech kvůli vyacuteznamnyacutem odlišnostem v implemen-taci algoritmů pro matematickou sazbu Zatiacutemco LuaTEX poskytuje uacutepl-nou implementaci všech vlastnostiacute OpenType math XƎTEX převzal jenčaacutest z nich s ohledem na tradičniacute implementace TEXu

Maje možnost překlaacutedat stejneacute testovaciacute soubory v obou implemen-taciacutech bylo možneacute podrobně zkoumat jejich rozdiacutely a porovnat vyacuteslednoumatematickou sazbu Doufejme že toto přispěje k zjištěniacutem co ovlivňujekvalitu matematickeacute sazby a jak ji zlepšit implementaciacute vyacutehod komplet-niacuteho formaacutetu OpenType math

Kliacutečovaacute slova LuaLATEX XƎLATEX formaacutet OpenType math sazba ma-tematiky baliacuteček fontspec Cambria Asana XITS Neo Euler

117

Ulrik Vieth CONTEXT MEETING 2010 1

Experiences typesetting OpenTypemath with LuaLaTEX and XeLaTEXAbstractWhen LuaTEX first provided support for OpenType math typesetting in version 040 high-level macro support formath typesetting was first developed for ConTEXt MkIV while support for LuaLaTEX was initially limited to a verylow-level or non-existent In the meantime this gap has been closed by recent developments on macro packagessuch as luaotfload fontspec and unicode-math so LaTEX users are now provided with a unified high-level fontselection interface for text and math fonts that can be used equally well with both LuaLaTEX and XeLaTEXWhile a unified high-level interface greatly improves document interchange and eases transitions between systemsit does not guarantee that identical input will always produce identical output on different engines as there aresignificant differences in the underlying implementations of math typesetting algorithms While LuaTEX provides afull-featured implementation of OpenType math XeTEX has taken a more limited approach based on a subset ofOpenType parameters to provide the functionality of traditional TEX enginesGiven the possibility of running exactly the same test files on both engines it now becomes feasible to study thosedifferences in detail and to compare the results Hopefully this will allow to draw conclusions how the quality ofmath typesetting is affected and could be improved by taking advantage of a more sophisticated full-featuredOpenType math implementation

LuaTEX math

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1XeTEX math

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1Can you spot the difference

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1

TeX program = lualatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputluatex-fixesinputmath-test

enddocument

TeX program = xelatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputxetex-fixesinputmath-test

enddocument

TeX program = pdflatexdocumentclassarticleusepackagepdfpagesbegindocumentincludepdfmerge

[nup=2x1noautoscale=truedelta=-21cm 0]xelatex-testpdf1lualatex-testpdf1

enddocument

2 CONTEXT MEETING 2010 Ulrik Vieth

IntroductionIn this paper we will review the state of recent devel-opments of new TEX engines and corresponding macropackages to supportmath typesettingwith Unicode andOpenType math fonts based on our experiences fromtesting the TEX Live 2010 pretest distribution [1]

In the first part we will summarize the availablechoices of TEX engines and macro packages as well asthe available choices of math fonts which can be usedfor testing OpenType math typesetting

In the second part we will report our experiencestesting the various TEX engines macro packages andfonts and we will report our findings which kind ofproblems were encountered and how these problemswere resolved or circumvented

In the third part wewill analyze and compare the re-sults of running identical documents through differentTEX engines using different implementations of mathtypesetting algorithms and we will try to draw conclu-sions how the quality of math typesetting is affectedand could be improved

Reviewing the state of OpenTypemath support in TEX Live 2010In recent years many developments related to new TEXengines and corresponding macro packages and fontshave focused on providing support for Unicode andOpenType not just for text typesetting but also formath typesetting (which is still important as one of thetraditional strong-holds of TEX)

Unicode and OpenType math technologyWhile the pre-history of Unicode text support datesback to themid-1990s most activities related to Unicodemath support only became possible during the last fewyears after a suitable font technology was developed asan extensions to the OpenType font format

When the efforts to bring math into Unicode werestarted in the late 1990s by a consortium of scientificpublishers the original focus was on identifying mathsymbols and getting them accepted into Unicode [2 3]Once this was done the focus shifted to developing areference font implementation the so-called STIX fontsto provide the necessary glyph shapes [4]

While the STIX project was spending nearly a decadewaiting for fonts to be designed the lack of a suitablefont technology for math typesetting was overlookedfor a long time While traditional TEX font formats sup-portedmath typesetting in their ownway they sufferedfrom limitations and questionable design decisions [5]

On the other hand mainstream font formats such asOpenType did not provide any support for the seman-tics of math typesetting

Ironically the lack of a suitablemath font technologywas only resolved when Microsoft started to developsupport for MS Office 2007 Given their influence as avendor controlling the OpenType font specification [6]they simply went ahead and created an extension of theOpenType font format containing aMATH table [7] andcommissioned the design of Cambria Math as a refer-ence implementation of an OpenType math font [8 9]In addition they also developed a simplified math inputlanguage known as lsquolinear mathrsquo [10]

While there are sometimes strong reservations aboutaccepting a vendor-defined file format especially anunreleased one coming from Microsoft developers offont tools such as FontForge [11] as well as developersof TEX engines were willing to accept OpenType mathas a de facto standard because it filled a need and alsobecause it turned out to be well-designed

Upon closer analysis many concepts of OpenTypemath could be seen as obvious extensions or general-izations of traditional concepts of math typesetting inTEX [12] Moreover most OpenTypemath font parame-ters could be identified to have a direct correspondenceto TEX math font parameters [13] which had also beencarefully analyzed in previous studies [14 15]

OpenType math support in TEX enginesWhen XeTEX first added OpenType math support inversion 0997 as of 2007 [16] it kept TEXrsquos traditionalmath typesetting algorithms essentially unchanged andonly used a small subset of OpenType font parametersto initialize the required TEX font parameters

When LuaTEX also added OpenType math supportin version 040 as of 2009 [17 18 19] it introduceda number of extensions and generalizations to TEXrsquosmath typesetting algorithms aiming to provide a full-featured implementation of OpenType math

As of TEX Live 2010 both new TEX engines support-ing Unicode and OpenTypemath typesetting have beenadded to themainstream distributions and have becomewidely available for using and testing the new featuresHowever their acceptance also depends on providingadequate macro package and font support

OpenType math support in macro packagesWhen XeTEXwas first added to TEX distributions it waseasily accessible to LaTEX users with XeLaTEX A high-level font selection interface for text fonts was devel-oped with the fontspec package [20 21] which becamewidely used as a standard package for XeLaTEX

118

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3

When XeTEX added math support a correspondinghigh-level font selection interface for math fonts wasalso developedwith the unicode-math package [22] butunlike fontspec it wasnrsquot released until recently

When LuaTEX added math support high-level macrosupport was initially developed for ConTEXt MkIV [23]while macro support for LuaLaTEX (or Plain LuaTEX)was initially limited to the luaotfload package [24]which provided only a low-level interface

As of TEX Live 2010 LaTEX macro package supportfor Unicode and OpenType math typesetting has beenmuch improved as both the fontspec and unicode-math packages have undergone a complete rewriteadding support for LuaLaTEX (based on luaotfload) tothe code originally developed for XeLaTEX

As a result LaTEX users are now provided with aunified high-level font selection interface for text andmath fonts [25] that can be used equally well with bothXeLaTEX and LuaLaTEX

Given this interface selecting a different math font(such as Cambria Math) can be as easy as this

usepackagefontspecunicode-mathsetmainfont[ltoptionsgt]Cambriasetmathfont[ltoptionsgt]Cambria Math

Using the options of setmathfont a number of detailsof math typesetting can be easily configured includ-ing the behavior of math alphabets (such as upright vsitalic for normal and bold uppercase and lowercaseLatin and Greek) which will make it much easier tosupport the specific requirements of math typesettingin various fields of sciences [26]

OpenType math fontsRegardless of font technology developing math fontshas always been far from easy and choices ofmath fontshave always been severely limited In this respect thesituation of OpenType fonts today is not much differ-ent from the situation of PostScript fonts in the 1990sWhile there are countless choices of text fonts thereare only very few math fonts available and even fewerof them are freely available

As of mid-2010 we have the following choices ofOpenType math fonts at our disposal

Cambria Math [8] the original reference math fontcommissioned by Microsoft for Office 2007Asana Math [27] a Palatino-like math font derivedfrom a repackaging of the mathpazo fontsXITSMath [28] a Times-like math font derived froma repackaging of the STIX fonts [29]Neo Euler [30] an upright math font derived fromHermann Zapfrsquos redesign of AMS Euler fonts [31]

Except for Cambria Math all of these fonts all arefreely available either from CTAN (if already released)or from GitHub (if still under development)

As of TEX Live 2010 Asana Math and XITS Math areboth included in the distribution but Cambria Mathand Neo Euler have to be obtained separately and needto be installed manually in your texmf-local tree

Once installed each of the fonts can be used in thesameway but the range of symbols andmath alphabetsavailable may differ significantly between fonts

Experiences testing OpenTypemath support in TEX Live 2010Testing the functionality and quality of OpenTypemathtypesetting implies testing a complex system consist-ing of typesetting engines macro packages and fonts(with embedded intelligence) which have to interactproperly to produce the desired results

Given the inherent complexity there are a largenumber of problems which can occur and most likelywill occur so we have to consider the possibilities ofengine problems macro problems font problems andfont loading issues

Problems with TEX enginesProblems with TEX engines can be of several differ-ent kinds ranging from fatal ones (such as unexpectedcrashes or malfunctions) to more subtle ones (such ashidden bugs in themath typesetting algorithms produc-ing incorrect results)

Traditionally TEX engines have enjoyed a reputa-tion of being extremely robust and totally free of bugsUnfortunately such expectations no longer hold truewhen it comes to new TEX engines which are underactive development and which donrsquot have the luxury oftwo decades of time to eliminate all possible bugs

Engine problems of the fatal kind are therefore a veryreal possibility which may even prevent or delay fur-ther testing until the problems can be resolved

While testing the TEX Live 2010 pretest distributiona number of problems were encountered for XeTEXon some 64-bit Linux platforms resulting in crashesor malfunctions upon loading OpenType math fontswhich are likely to be caused by incompatibilities withexternal library dependencies

Unfortunately there was not enough time to debugthese problems before the deadline for the TEX Live 2010binaries so the problems remain unresolved for nowand need to be revisited eventually As a workaroundit may be possible to use 32-bit binaries on 64-bit Linuxplatforms which do not exhibit such problems

119

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 2: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Experiences Typesetting OpenType Math withLuaLATEX and XƎLATEXZkušenosti se sazbou matematiky ve formaacutetuOpenType math v LuaLATEXu a XƎLATEXu

Ulrik Vieth

Abstract When LuaTEX first provided support for OpenType math ty-pesetting in version 040 high-level macro support for math typesettingwas first developed for ConTEXt MkIV while support for LuaLATEX wasinitially limited to a very low-level or non-existent In the meantime thisgap has been closed by recent developments on macro packages such asluaotfload fontspec and unicode-math so LATEX users are now providedwith a unified high-level font selection interface for text and math fontsthat can be used equally well with both LuaLATEX and XƎLATEX Whilea unified high-level interface greatly improves document interchange andeases transitions between systems it does not guarantee that identicalinput will always produce identical output on different engines as thereare significant differences in the underlying implementations of math ty-pesetting algorithms While LuaTEX provides a full-featured implemen-tation of OpenType math XƎTEX has taken a more limited approachbased on a subset of OpenType parameters to provide the functionalityof traditional TEX engines

Given the possibility of running exactly the same test files on bothengines it now becomes feasible to study those differences in detail andto compare the results Hopefully this will allow to draw conclusionshow the quality of math typesetting is affected and could be improved bytaking advantage of a more sophisticated full-featured OpenType mathimplementationKey words LuaLATEX XƎLATEX OpenType math math typesettingfontspec package Cambria Asana XITS Neo Euler

Abstrakt Jelikož LuaTEX podporuje Open Type math až od verze 040byla podpora matematickeacute sazby na vyššiacute uacuterovni vytvořena nejprve proConTEXt MkIV zatiacutemco podpora pro LuaLATEX byla niacutezkaacute nebo nebylažaacutednaacute Dalšiacute vyacutevoj však tuto mezeru zacelil ndash uživateleacute LATEXu majiacute nyniacutek dispozici jednotneacute rozhraniacute pro připojeniacute fontů pro běžnyacute text i promatematickou sazbu pomociacute baliacutečků luaotfload fontspec a unicode-math

116 doi 1053002011-2-4116

obojiacute lze celkem stejně dobře využiacutet v LuaLATEXu i v XƎLATEXu I kdyžtoto jednotneacute rozhraniacute značně zjednodušuje vyacuteměnu dokumentů i přenosmezi různyacutemi systeacutemy nezaručuje že tentyacutež vstup vytvořiacute vždy tentyacutežvyacutestup na různyacutech počiacutetačiacutech kvůli vyacuteznamnyacutem odlišnostem v implemen-taci algoritmů pro matematickou sazbu Zatiacutemco LuaTEX poskytuje uacutepl-nou implementaci všech vlastnostiacute OpenType math XƎTEX převzal jenčaacutest z nich s ohledem na tradičniacute implementace TEXu

Maje možnost překlaacutedat stejneacute testovaciacute soubory v obou implemen-taciacutech bylo možneacute podrobně zkoumat jejich rozdiacutely a porovnat vyacuteslednoumatematickou sazbu Doufejme že toto přispěje k zjištěniacutem co ovlivňujekvalitu matematickeacute sazby a jak ji zlepšit implementaciacute vyacutehod komplet-niacuteho formaacutetu OpenType math

Kliacutečovaacute slova LuaLATEX XƎLATEX formaacutet OpenType math sazba ma-tematiky baliacuteček fontspec Cambria Asana XITS Neo Euler

117

Ulrik Vieth CONTEXT MEETING 2010 1

Experiences typesetting OpenTypemath with LuaLaTEX and XeLaTEXAbstractWhen LuaTEX first provided support for OpenType math typesetting in version 040 high-level macro support formath typesetting was first developed for ConTEXt MkIV while support for LuaLaTEX was initially limited to a verylow-level or non-existent In the meantime this gap has been closed by recent developments on macro packagessuch as luaotfload fontspec and unicode-math so LaTEX users are now provided with a unified high-level fontselection interface for text and math fonts that can be used equally well with both LuaLaTEX and XeLaTEXWhile a unified high-level interface greatly improves document interchange and eases transitions between systemsit does not guarantee that identical input will always produce identical output on different engines as there aresignificant differences in the underlying implementations of math typesetting algorithms While LuaTEX provides afull-featured implementation of OpenType math XeTEX has taken a more limited approach based on a subset ofOpenType parameters to provide the functionality of traditional TEX enginesGiven the possibility of running exactly the same test files on both engines it now becomes feasible to study thosedifferences in detail and to compare the results Hopefully this will allow to draw conclusions how the quality ofmath typesetting is affected and could be improved by taking advantage of a more sophisticated full-featuredOpenType math implementation

LuaTEX math

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1XeTEX math

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1Can you spot the difference

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1

TeX program = lualatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputluatex-fixesinputmath-test

enddocument

TeX program = xelatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputxetex-fixesinputmath-test

enddocument

TeX program = pdflatexdocumentclassarticleusepackagepdfpagesbegindocumentincludepdfmerge

[nup=2x1noautoscale=truedelta=-21cm 0]xelatex-testpdf1lualatex-testpdf1

enddocument

2 CONTEXT MEETING 2010 Ulrik Vieth

IntroductionIn this paper we will review the state of recent devel-opments of new TEX engines and corresponding macropackages to supportmath typesettingwith Unicode andOpenType math fonts based on our experiences fromtesting the TEX Live 2010 pretest distribution [1]

In the first part we will summarize the availablechoices of TEX engines and macro packages as well asthe available choices of math fonts which can be usedfor testing OpenType math typesetting

In the second part we will report our experiencestesting the various TEX engines macro packages andfonts and we will report our findings which kind ofproblems were encountered and how these problemswere resolved or circumvented

In the third part wewill analyze and compare the re-sults of running identical documents through differentTEX engines using different implementations of mathtypesetting algorithms and we will try to draw conclu-sions how the quality of math typesetting is affectedand could be improved

Reviewing the state of OpenTypemath support in TEX Live 2010In recent years many developments related to new TEXengines and corresponding macro packages and fontshave focused on providing support for Unicode andOpenType not just for text typesetting but also formath typesetting (which is still important as one of thetraditional strong-holds of TEX)

Unicode and OpenType math technologyWhile the pre-history of Unicode text support datesback to themid-1990s most activities related to Unicodemath support only became possible during the last fewyears after a suitable font technology was developed asan extensions to the OpenType font format

When the efforts to bring math into Unicode werestarted in the late 1990s by a consortium of scientificpublishers the original focus was on identifying mathsymbols and getting them accepted into Unicode [2 3]Once this was done the focus shifted to developing areference font implementation the so-called STIX fontsto provide the necessary glyph shapes [4]

While the STIX project was spending nearly a decadewaiting for fonts to be designed the lack of a suitablefont technology for math typesetting was overlookedfor a long time While traditional TEX font formats sup-portedmath typesetting in their ownway they sufferedfrom limitations and questionable design decisions [5]

On the other hand mainstream font formats such asOpenType did not provide any support for the seman-tics of math typesetting

Ironically the lack of a suitablemath font technologywas only resolved when Microsoft started to developsupport for MS Office 2007 Given their influence as avendor controlling the OpenType font specification [6]they simply went ahead and created an extension of theOpenType font format containing aMATH table [7] andcommissioned the design of Cambria Math as a refer-ence implementation of an OpenType math font [8 9]In addition they also developed a simplified math inputlanguage known as lsquolinear mathrsquo [10]

While there are sometimes strong reservations aboutaccepting a vendor-defined file format especially anunreleased one coming from Microsoft developers offont tools such as FontForge [11] as well as developersof TEX engines were willing to accept OpenType mathas a de facto standard because it filled a need and alsobecause it turned out to be well-designed

Upon closer analysis many concepts of OpenTypemath could be seen as obvious extensions or general-izations of traditional concepts of math typesetting inTEX [12] Moreover most OpenTypemath font parame-ters could be identified to have a direct correspondenceto TEX math font parameters [13] which had also beencarefully analyzed in previous studies [14 15]

OpenType math support in TEX enginesWhen XeTEX first added OpenType math support inversion 0997 as of 2007 [16] it kept TEXrsquos traditionalmath typesetting algorithms essentially unchanged andonly used a small subset of OpenType font parametersto initialize the required TEX font parameters

When LuaTEX also added OpenType math supportin version 040 as of 2009 [17 18 19] it introduceda number of extensions and generalizations to TEXrsquosmath typesetting algorithms aiming to provide a full-featured implementation of OpenType math

As of TEX Live 2010 both new TEX engines support-ing Unicode and OpenTypemath typesetting have beenadded to themainstream distributions and have becomewidely available for using and testing the new featuresHowever their acceptance also depends on providingadequate macro package and font support

OpenType math support in macro packagesWhen XeTEXwas first added to TEX distributions it waseasily accessible to LaTEX users with XeLaTEX A high-level font selection interface for text fonts was devel-oped with the fontspec package [20 21] which becamewidely used as a standard package for XeLaTEX

118

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3

When XeTEX added math support a correspondinghigh-level font selection interface for math fonts wasalso developedwith the unicode-math package [22] butunlike fontspec it wasnrsquot released until recently

When LuaTEX added math support high-level macrosupport was initially developed for ConTEXt MkIV [23]while macro support for LuaLaTEX (or Plain LuaTEX)was initially limited to the luaotfload package [24]which provided only a low-level interface

As of TEX Live 2010 LaTEX macro package supportfor Unicode and OpenType math typesetting has beenmuch improved as both the fontspec and unicode-math packages have undergone a complete rewriteadding support for LuaLaTEX (based on luaotfload) tothe code originally developed for XeLaTEX

As a result LaTEX users are now provided with aunified high-level font selection interface for text andmath fonts [25] that can be used equally well with bothXeLaTEX and LuaLaTEX

Given this interface selecting a different math font(such as Cambria Math) can be as easy as this

usepackagefontspecunicode-mathsetmainfont[ltoptionsgt]Cambriasetmathfont[ltoptionsgt]Cambria Math

Using the options of setmathfont a number of detailsof math typesetting can be easily configured includ-ing the behavior of math alphabets (such as upright vsitalic for normal and bold uppercase and lowercaseLatin and Greek) which will make it much easier tosupport the specific requirements of math typesettingin various fields of sciences [26]

OpenType math fontsRegardless of font technology developing math fontshas always been far from easy and choices ofmath fontshave always been severely limited In this respect thesituation of OpenType fonts today is not much differ-ent from the situation of PostScript fonts in the 1990sWhile there are countless choices of text fonts thereare only very few math fonts available and even fewerof them are freely available

As of mid-2010 we have the following choices ofOpenType math fonts at our disposal

Cambria Math [8] the original reference math fontcommissioned by Microsoft for Office 2007Asana Math [27] a Palatino-like math font derivedfrom a repackaging of the mathpazo fontsXITSMath [28] a Times-like math font derived froma repackaging of the STIX fonts [29]Neo Euler [30] an upright math font derived fromHermann Zapfrsquos redesign of AMS Euler fonts [31]

Except for Cambria Math all of these fonts all arefreely available either from CTAN (if already released)or from GitHub (if still under development)

As of TEX Live 2010 Asana Math and XITS Math areboth included in the distribution but Cambria Mathand Neo Euler have to be obtained separately and needto be installed manually in your texmf-local tree

Once installed each of the fonts can be used in thesameway but the range of symbols andmath alphabetsavailable may differ significantly between fonts

Experiences testing OpenTypemath support in TEX Live 2010Testing the functionality and quality of OpenTypemathtypesetting implies testing a complex system consist-ing of typesetting engines macro packages and fonts(with embedded intelligence) which have to interactproperly to produce the desired results

Given the inherent complexity there are a largenumber of problems which can occur and most likelywill occur so we have to consider the possibilities ofengine problems macro problems font problems andfont loading issues

Problems with TEX enginesProblems with TEX engines can be of several differ-ent kinds ranging from fatal ones (such as unexpectedcrashes or malfunctions) to more subtle ones (such ashidden bugs in themath typesetting algorithms produc-ing incorrect results)

Traditionally TEX engines have enjoyed a reputa-tion of being extremely robust and totally free of bugsUnfortunately such expectations no longer hold truewhen it comes to new TEX engines which are underactive development and which donrsquot have the luxury oftwo decades of time to eliminate all possible bugs

Engine problems of the fatal kind are therefore a veryreal possibility which may even prevent or delay fur-ther testing until the problems can be resolved

While testing the TEX Live 2010 pretest distributiona number of problems were encountered for XeTEXon some 64-bit Linux platforms resulting in crashesor malfunctions upon loading OpenType math fontswhich are likely to be caused by incompatibilities withexternal library dependencies

Unfortunately there was not enough time to debugthese problems before the deadline for the TEX Live 2010binaries so the problems remain unresolved for nowand need to be revisited eventually As a workaroundit may be possible to use 32-bit binaries on 64-bit Linuxplatforms which do not exhibit such problems

119

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 3: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

obojiacute lze celkem stejně dobře využiacutet v LuaLATEXu i v XƎLATEXu I kdyžtoto jednotneacute rozhraniacute značně zjednodušuje vyacuteměnu dokumentů i přenosmezi různyacutemi systeacutemy nezaručuje že tentyacutež vstup vytvořiacute vždy tentyacutežvyacutestup na různyacutech počiacutetačiacutech kvůli vyacuteznamnyacutem odlišnostem v implemen-taci algoritmů pro matematickou sazbu Zatiacutemco LuaTEX poskytuje uacutepl-nou implementaci všech vlastnostiacute OpenType math XƎTEX převzal jenčaacutest z nich s ohledem na tradičniacute implementace TEXu

Maje možnost překlaacutedat stejneacute testovaciacute soubory v obou implemen-taciacutech bylo možneacute podrobně zkoumat jejich rozdiacutely a porovnat vyacuteslednoumatematickou sazbu Doufejme že toto přispěje k zjištěniacutem co ovlivňujekvalitu matematickeacute sazby a jak ji zlepšit implementaciacute vyacutehod komplet-niacuteho formaacutetu OpenType math

Kliacutečovaacute slova LuaLATEX XƎLATEX formaacutet OpenType math sazba ma-tematiky baliacuteček fontspec Cambria Asana XITS Neo Euler

117

Ulrik Vieth CONTEXT MEETING 2010 1

Experiences typesetting OpenTypemath with LuaLaTEX and XeLaTEXAbstractWhen LuaTEX first provided support for OpenType math typesetting in version 040 high-level macro support formath typesetting was first developed for ConTEXt MkIV while support for LuaLaTEX was initially limited to a verylow-level or non-existent In the meantime this gap has been closed by recent developments on macro packagessuch as luaotfload fontspec and unicode-math so LaTEX users are now provided with a unified high-level fontselection interface for text and math fonts that can be used equally well with both LuaLaTEX and XeLaTEXWhile a unified high-level interface greatly improves document interchange and eases transitions between systemsit does not guarantee that identical input will always produce identical output on different engines as there aresignificant differences in the underlying implementations of math typesetting algorithms While LuaTEX provides afull-featured implementation of OpenType math XeTEX has taken a more limited approach based on a subset ofOpenType parameters to provide the functionality of traditional TEX enginesGiven the possibility of running exactly the same test files on both engines it now becomes feasible to study thosedifferences in detail and to compare the results Hopefully this will allow to draw conclusions how the quality ofmath typesetting is affected and could be improved by taking advantage of a more sophisticated full-featuredOpenType math implementation

LuaTEX math

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1XeTEX math

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1Can you spot the difference

Δ119916 minus 1119888

120597 119916120597119905 = 1

120576 120513120582 + 120583 120597119947120597119905

Δ119913 minus 1119888

120597 119913120597119905 = minus120583 rot 119947

1

Δ119916 minus1

11988810490001205971049000119916

1205971199051049000=

1

1205761048998120513120582 + 1205831048998

120597119947

120597119905

Δ119913 minus1

11988810490001205971049000119913

1205971199051049000= minus1205831048998 rot 119947

1

TeX program = lualatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputluatex-fixesinputmath-test

enddocument

TeX program = xelatexdocumentclass[fleqn]articleusepackagefontspecunicode-mathsetromanfontCambriasetmathfontCambria Mathbegindocumentinputxetex-fixesinputmath-test

enddocument

TeX program = pdflatexdocumentclassarticleusepackagepdfpagesbegindocumentincludepdfmerge

[nup=2x1noautoscale=truedelta=-21cm 0]xelatex-testpdf1lualatex-testpdf1

enddocument

2 CONTEXT MEETING 2010 Ulrik Vieth

IntroductionIn this paper we will review the state of recent devel-opments of new TEX engines and corresponding macropackages to supportmath typesettingwith Unicode andOpenType math fonts based on our experiences fromtesting the TEX Live 2010 pretest distribution [1]

In the first part we will summarize the availablechoices of TEX engines and macro packages as well asthe available choices of math fonts which can be usedfor testing OpenType math typesetting

In the second part we will report our experiencestesting the various TEX engines macro packages andfonts and we will report our findings which kind ofproblems were encountered and how these problemswere resolved or circumvented

In the third part wewill analyze and compare the re-sults of running identical documents through differentTEX engines using different implementations of mathtypesetting algorithms and we will try to draw conclu-sions how the quality of math typesetting is affectedand could be improved

Reviewing the state of OpenTypemath support in TEX Live 2010In recent years many developments related to new TEXengines and corresponding macro packages and fontshave focused on providing support for Unicode andOpenType not just for text typesetting but also formath typesetting (which is still important as one of thetraditional strong-holds of TEX)

Unicode and OpenType math technologyWhile the pre-history of Unicode text support datesback to themid-1990s most activities related to Unicodemath support only became possible during the last fewyears after a suitable font technology was developed asan extensions to the OpenType font format

When the efforts to bring math into Unicode werestarted in the late 1990s by a consortium of scientificpublishers the original focus was on identifying mathsymbols and getting them accepted into Unicode [2 3]Once this was done the focus shifted to developing areference font implementation the so-called STIX fontsto provide the necessary glyph shapes [4]

While the STIX project was spending nearly a decadewaiting for fonts to be designed the lack of a suitablefont technology for math typesetting was overlookedfor a long time While traditional TEX font formats sup-portedmath typesetting in their ownway they sufferedfrom limitations and questionable design decisions [5]

On the other hand mainstream font formats such asOpenType did not provide any support for the seman-tics of math typesetting

Ironically the lack of a suitablemath font technologywas only resolved when Microsoft started to developsupport for MS Office 2007 Given their influence as avendor controlling the OpenType font specification [6]they simply went ahead and created an extension of theOpenType font format containing aMATH table [7] andcommissioned the design of Cambria Math as a refer-ence implementation of an OpenType math font [8 9]In addition they also developed a simplified math inputlanguage known as lsquolinear mathrsquo [10]

While there are sometimes strong reservations aboutaccepting a vendor-defined file format especially anunreleased one coming from Microsoft developers offont tools such as FontForge [11] as well as developersof TEX engines were willing to accept OpenType mathas a de facto standard because it filled a need and alsobecause it turned out to be well-designed

Upon closer analysis many concepts of OpenTypemath could be seen as obvious extensions or general-izations of traditional concepts of math typesetting inTEX [12] Moreover most OpenTypemath font parame-ters could be identified to have a direct correspondenceto TEX math font parameters [13] which had also beencarefully analyzed in previous studies [14 15]

OpenType math support in TEX enginesWhen XeTEX first added OpenType math support inversion 0997 as of 2007 [16] it kept TEXrsquos traditionalmath typesetting algorithms essentially unchanged andonly used a small subset of OpenType font parametersto initialize the required TEX font parameters

When LuaTEX also added OpenType math supportin version 040 as of 2009 [17 18 19] it introduceda number of extensions and generalizations to TEXrsquosmath typesetting algorithms aiming to provide a full-featured implementation of OpenType math

As of TEX Live 2010 both new TEX engines support-ing Unicode and OpenTypemath typesetting have beenadded to themainstream distributions and have becomewidely available for using and testing the new featuresHowever their acceptance also depends on providingadequate macro package and font support

OpenType math support in macro packagesWhen XeTEXwas first added to TEX distributions it waseasily accessible to LaTEX users with XeLaTEX A high-level font selection interface for text fonts was devel-oped with the fontspec package [20 21] which becamewidely used as a standard package for XeLaTEX

118

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3

When XeTEX added math support a correspondinghigh-level font selection interface for math fonts wasalso developedwith the unicode-math package [22] butunlike fontspec it wasnrsquot released until recently

When LuaTEX added math support high-level macrosupport was initially developed for ConTEXt MkIV [23]while macro support for LuaLaTEX (or Plain LuaTEX)was initially limited to the luaotfload package [24]which provided only a low-level interface

As of TEX Live 2010 LaTEX macro package supportfor Unicode and OpenType math typesetting has beenmuch improved as both the fontspec and unicode-math packages have undergone a complete rewriteadding support for LuaLaTEX (based on luaotfload) tothe code originally developed for XeLaTEX

As a result LaTEX users are now provided with aunified high-level font selection interface for text andmath fonts [25] that can be used equally well with bothXeLaTEX and LuaLaTEX

Given this interface selecting a different math font(such as Cambria Math) can be as easy as this

usepackagefontspecunicode-mathsetmainfont[ltoptionsgt]Cambriasetmathfont[ltoptionsgt]Cambria Math

Using the options of setmathfont a number of detailsof math typesetting can be easily configured includ-ing the behavior of math alphabets (such as upright vsitalic for normal and bold uppercase and lowercaseLatin and Greek) which will make it much easier tosupport the specific requirements of math typesettingin various fields of sciences [26]

OpenType math fontsRegardless of font technology developing math fontshas always been far from easy and choices ofmath fontshave always been severely limited In this respect thesituation of OpenType fonts today is not much differ-ent from the situation of PostScript fonts in the 1990sWhile there are countless choices of text fonts thereare only very few math fonts available and even fewerof them are freely available

As of mid-2010 we have the following choices ofOpenType math fonts at our disposal

Cambria Math [8] the original reference math fontcommissioned by Microsoft for Office 2007Asana Math [27] a Palatino-like math font derivedfrom a repackaging of the mathpazo fontsXITSMath [28] a Times-like math font derived froma repackaging of the STIX fonts [29]Neo Euler [30] an upright math font derived fromHermann Zapfrsquos redesign of AMS Euler fonts [31]

Except for Cambria Math all of these fonts all arefreely available either from CTAN (if already released)or from GitHub (if still under development)

As of TEX Live 2010 Asana Math and XITS Math areboth included in the distribution but Cambria Mathand Neo Euler have to be obtained separately and needto be installed manually in your texmf-local tree

Once installed each of the fonts can be used in thesameway but the range of symbols andmath alphabetsavailable may differ significantly between fonts

Experiences testing OpenTypemath support in TEX Live 2010Testing the functionality and quality of OpenTypemathtypesetting implies testing a complex system consist-ing of typesetting engines macro packages and fonts(with embedded intelligence) which have to interactproperly to produce the desired results

Given the inherent complexity there are a largenumber of problems which can occur and most likelywill occur so we have to consider the possibilities ofengine problems macro problems font problems andfont loading issues

Problems with TEX enginesProblems with TEX engines can be of several differ-ent kinds ranging from fatal ones (such as unexpectedcrashes or malfunctions) to more subtle ones (such ashidden bugs in themath typesetting algorithms produc-ing incorrect results)

Traditionally TEX engines have enjoyed a reputa-tion of being extremely robust and totally free of bugsUnfortunately such expectations no longer hold truewhen it comes to new TEX engines which are underactive development and which donrsquot have the luxury oftwo decades of time to eliminate all possible bugs

Engine problems of the fatal kind are therefore a veryreal possibility which may even prevent or delay fur-ther testing until the problems can be resolved

While testing the TEX Live 2010 pretest distributiona number of problems were encountered for XeTEXon some 64-bit Linux platforms resulting in crashesor malfunctions upon loading OpenType math fontswhich are likely to be caused by incompatibilities withexternal library dependencies

Unfortunately there was not enough time to debugthese problems before the deadline for the TEX Live 2010binaries so the problems remain unresolved for nowand need to be revisited eventually As a workaroundit may be possible to use 32-bit binaries on 64-bit Linuxplatforms which do not exhibit such problems

119

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 4: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

2 CONTEXT MEETING 2010 Ulrik Vieth

IntroductionIn this paper we will review the state of recent devel-opments of new TEX engines and corresponding macropackages to supportmath typesettingwith Unicode andOpenType math fonts based on our experiences fromtesting the TEX Live 2010 pretest distribution [1]

In the first part we will summarize the availablechoices of TEX engines and macro packages as well asthe available choices of math fonts which can be usedfor testing OpenType math typesetting

In the second part we will report our experiencestesting the various TEX engines macro packages andfonts and we will report our findings which kind ofproblems were encountered and how these problemswere resolved or circumvented

In the third part wewill analyze and compare the re-sults of running identical documents through differentTEX engines using different implementations of mathtypesetting algorithms and we will try to draw conclu-sions how the quality of math typesetting is affectedand could be improved

Reviewing the state of OpenTypemath support in TEX Live 2010In recent years many developments related to new TEXengines and corresponding macro packages and fontshave focused on providing support for Unicode andOpenType not just for text typesetting but also formath typesetting (which is still important as one of thetraditional strong-holds of TEX)

Unicode and OpenType math technologyWhile the pre-history of Unicode text support datesback to themid-1990s most activities related to Unicodemath support only became possible during the last fewyears after a suitable font technology was developed asan extensions to the OpenType font format

When the efforts to bring math into Unicode werestarted in the late 1990s by a consortium of scientificpublishers the original focus was on identifying mathsymbols and getting them accepted into Unicode [2 3]Once this was done the focus shifted to developing areference font implementation the so-called STIX fontsto provide the necessary glyph shapes [4]

While the STIX project was spending nearly a decadewaiting for fonts to be designed the lack of a suitablefont technology for math typesetting was overlookedfor a long time While traditional TEX font formats sup-portedmath typesetting in their ownway they sufferedfrom limitations and questionable design decisions [5]

On the other hand mainstream font formats such asOpenType did not provide any support for the seman-tics of math typesetting

Ironically the lack of a suitablemath font technologywas only resolved when Microsoft started to developsupport for MS Office 2007 Given their influence as avendor controlling the OpenType font specification [6]they simply went ahead and created an extension of theOpenType font format containing aMATH table [7] andcommissioned the design of Cambria Math as a refer-ence implementation of an OpenType math font [8 9]In addition they also developed a simplified math inputlanguage known as lsquolinear mathrsquo [10]

While there are sometimes strong reservations aboutaccepting a vendor-defined file format especially anunreleased one coming from Microsoft developers offont tools such as FontForge [11] as well as developersof TEX engines were willing to accept OpenType mathas a de facto standard because it filled a need and alsobecause it turned out to be well-designed

Upon closer analysis many concepts of OpenTypemath could be seen as obvious extensions or general-izations of traditional concepts of math typesetting inTEX [12] Moreover most OpenTypemath font parame-ters could be identified to have a direct correspondenceto TEX math font parameters [13] which had also beencarefully analyzed in previous studies [14 15]

OpenType math support in TEX enginesWhen XeTEX first added OpenType math support inversion 0997 as of 2007 [16] it kept TEXrsquos traditionalmath typesetting algorithms essentially unchanged andonly used a small subset of OpenType font parametersto initialize the required TEX font parameters

When LuaTEX also added OpenType math supportin version 040 as of 2009 [17 18 19] it introduceda number of extensions and generalizations to TEXrsquosmath typesetting algorithms aiming to provide a full-featured implementation of OpenType math

As of TEX Live 2010 both new TEX engines support-ing Unicode and OpenTypemath typesetting have beenadded to themainstream distributions and have becomewidely available for using and testing the new featuresHowever their acceptance also depends on providingadequate macro package and font support

OpenType math support in macro packagesWhen XeTEXwas first added to TEX distributions it waseasily accessible to LaTEX users with XeLaTEX A high-level font selection interface for text fonts was devel-oped with the fontspec package [20 21] which becamewidely used as a standard package for XeLaTEX

118

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3

When XeTEX added math support a correspondinghigh-level font selection interface for math fonts wasalso developedwith the unicode-math package [22] butunlike fontspec it wasnrsquot released until recently

When LuaTEX added math support high-level macrosupport was initially developed for ConTEXt MkIV [23]while macro support for LuaLaTEX (or Plain LuaTEX)was initially limited to the luaotfload package [24]which provided only a low-level interface

As of TEX Live 2010 LaTEX macro package supportfor Unicode and OpenType math typesetting has beenmuch improved as both the fontspec and unicode-math packages have undergone a complete rewriteadding support for LuaLaTEX (based on luaotfload) tothe code originally developed for XeLaTEX

As a result LaTEX users are now provided with aunified high-level font selection interface for text andmath fonts [25] that can be used equally well with bothXeLaTEX and LuaLaTEX

Given this interface selecting a different math font(such as Cambria Math) can be as easy as this

usepackagefontspecunicode-mathsetmainfont[ltoptionsgt]Cambriasetmathfont[ltoptionsgt]Cambria Math

Using the options of setmathfont a number of detailsof math typesetting can be easily configured includ-ing the behavior of math alphabets (such as upright vsitalic for normal and bold uppercase and lowercaseLatin and Greek) which will make it much easier tosupport the specific requirements of math typesettingin various fields of sciences [26]

OpenType math fontsRegardless of font technology developing math fontshas always been far from easy and choices ofmath fontshave always been severely limited In this respect thesituation of OpenType fonts today is not much differ-ent from the situation of PostScript fonts in the 1990sWhile there are countless choices of text fonts thereare only very few math fonts available and even fewerof them are freely available

As of mid-2010 we have the following choices ofOpenType math fonts at our disposal

Cambria Math [8] the original reference math fontcommissioned by Microsoft for Office 2007Asana Math [27] a Palatino-like math font derivedfrom a repackaging of the mathpazo fontsXITSMath [28] a Times-like math font derived froma repackaging of the STIX fonts [29]Neo Euler [30] an upright math font derived fromHermann Zapfrsquos redesign of AMS Euler fonts [31]

Except for Cambria Math all of these fonts all arefreely available either from CTAN (if already released)or from GitHub (if still under development)

As of TEX Live 2010 Asana Math and XITS Math areboth included in the distribution but Cambria Mathand Neo Euler have to be obtained separately and needto be installed manually in your texmf-local tree

Once installed each of the fonts can be used in thesameway but the range of symbols andmath alphabetsavailable may differ significantly between fonts

Experiences testing OpenTypemath support in TEX Live 2010Testing the functionality and quality of OpenTypemathtypesetting implies testing a complex system consist-ing of typesetting engines macro packages and fonts(with embedded intelligence) which have to interactproperly to produce the desired results

Given the inherent complexity there are a largenumber of problems which can occur and most likelywill occur so we have to consider the possibilities ofengine problems macro problems font problems andfont loading issues

Problems with TEX enginesProblems with TEX engines can be of several differ-ent kinds ranging from fatal ones (such as unexpectedcrashes or malfunctions) to more subtle ones (such ashidden bugs in themath typesetting algorithms produc-ing incorrect results)

Traditionally TEX engines have enjoyed a reputa-tion of being extremely robust and totally free of bugsUnfortunately such expectations no longer hold truewhen it comes to new TEX engines which are underactive development and which donrsquot have the luxury oftwo decades of time to eliminate all possible bugs

Engine problems of the fatal kind are therefore a veryreal possibility which may even prevent or delay fur-ther testing until the problems can be resolved

While testing the TEX Live 2010 pretest distributiona number of problems were encountered for XeTEXon some 64-bit Linux platforms resulting in crashesor malfunctions upon loading OpenType math fontswhich are likely to be caused by incompatibilities withexternal library dependencies

Unfortunately there was not enough time to debugthese problems before the deadline for the TEX Live 2010binaries so the problems remain unresolved for nowand need to be revisited eventually As a workaroundit may be possible to use 32-bit binaries on 64-bit Linuxplatforms which do not exhibit such problems

119

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 5: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 3

When XeTEX added math support a correspondinghigh-level font selection interface for math fonts wasalso developedwith the unicode-math package [22] butunlike fontspec it wasnrsquot released until recently

When LuaTEX added math support high-level macrosupport was initially developed for ConTEXt MkIV [23]while macro support for LuaLaTEX (or Plain LuaTEX)was initially limited to the luaotfload package [24]which provided only a low-level interface

As of TEX Live 2010 LaTEX macro package supportfor Unicode and OpenType math typesetting has beenmuch improved as both the fontspec and unicode-math packages have undergone a complete rewriteadding support for LuaLaTEX (based on luaotfload) tothe code originally developed for XeLaTEX

As a result LaTEX users are now provided with aunified high-level font selection interface for text andmath fonts [25] that can be used equally well with bothXeLaTEX and LuaLaTEX

Given this interface selecting a different math font(such as Cambria Math) can be as easy as this

usepackagefontspecunicode-mathsetmainfont[ltoptionsgt]Cambriasetmathfont[ltoptionsgt]Cambria Math

Using the options of setmathfont a number of detailsof math typesetting can be easily configured includ-ing the behavior of math alphabets (such as upright vsitalic for normal and bold uppercase and lowercaseLatin and Greek) which will make it much easier tosupport the specific requirements of math typesettingin various fields of sciences [26]

OpenType math fontsRegardless of font technology developing math fontshas always been far from easy and choices ofmath fontshave always been severely limited In this respect thesituation of OpenType fonts today is not much differ-ent from the situation of PostScript fonts in the 1990sWhile there are countless choices of text fonts thereare only very few math fonts available and even fewerof them are freely available

As of mid-2010 we have the following choices ofOpenType math fonts at our disposal

Cambria Math [8] the original reference math fontcommissioned by Microsoft for Office 2007Asana Math [27] a Palatino-like math font derivedfrom a repackaging of the mathpazo fontsXITSMath [28] a Times-like math font derived froma repackaging of the STIX fonts [29]Neo Euler [30] an upright math font derived fromHermann Zapfrsquos redesign of AMS Euler fonts [31]

Except for Cambria Math all of these fonts all arefreely available either from CTAN (if already released)or from GitHub (if still under development)

As of TEX Live 2010 Asana Math and XITS Math areboth included in the distribution but Cambria Mathand Neo Euler have to be obtained separately and needto be installed manually in your texmf-local tree

Once installed each of the fonts can be used in thesameway but the range of symbols andmath alphabetsavailable may differ significantly between fonts

Experiences testing OpenTypemath support in TEX Live 2010Testing the functionality and quality of OpenTypemathtypesetting implies testing a complex system consist-ing of typesetting engines macro packages and fonts(with embedded intelligence) which have to interactproperly to produce the desired results

Given the inherent complexity there are a largenumber of problems which can occur and most likelywill occur so we have to consider the possibilities ofengine problems macro problems font problems andfont loading issues

Problems with TEX enginesProblems with TEX engines can be of several differ-ent kinds ranging from fatal ones (such as unexpectedcrashes or malfunctions) to more subtle ones (such ashidden bugs in themath typesetting algorithms produc-ing incorrect results)

Traditionally TEX engines have enjoyed a reputa-tion of being extremely robust and totally free of bugsUnfortunately such expectations no longer hold truewhen it comes to new TEX engines which are underactive development and which donrsquot have the luxury oftwo decades of time to eliminate all possible bugs

Engine problems of the fatal kind are therefore a veryreal possibility which may even prevent or delay fur-ther testing until the problems can be resolved

While testing the TEX Live 2010 pretest distributiona number of problems were encountered for XeTEXon some 64-bit Linux platforms resulting in crashesor malfunctions upon loading OpenType math fontswhich are likely to be caused by incompatibilities withexternal library dependencies

Unfortunately there was not enough time to debugthese problems before the deadline for the TEX Live 2010binaries so the problems remain unresolved for nowand need to be revisited eventually As a workaroundit may be possible to use 32-bit binaries on 64-bit Linuxplatforms which do not exhibit such problems

119

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 6: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

4 CONTEXT MEETING 2010 Ulrik Vieth

120574120572⎛⎜⎝

ℏipart120572 minus 119902119860120572

⎞⎟⎠120595 + 1198981048683119888 120595 = 0

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 1 Comparison of the size of delimiters in Asana Mathfor LuaTEX 060x and LuaTEX 061 Due to a bug in the mathtypesetting algorithms the extensible version of delimiters wasapplied too soon (The example shows the Dirac equation fromrelativistic quantum mechanics)

Engine problems of the more subtle kind were foundin LuaTEX when a bug was discovered for some mathfonts (such as Asana Math) which resulted in applyingthe extensible version of delimiters before exhaustingall available sizes of big delimiters (An example of theincorrect behavior is illustrated in Figure 1)

In the meantime this bug has already been fixed inLuaTEX 061 but again it was too late to include the fixin TEX Live 2010 which still uses LuaTEX 060x

Problems with OpenType font metricsProblems with OpenType fonts can also be of differentkinds ranging from fatal ones (such as containing mal-formed data structures causing TEX engines to crash) tomore subtle ones (such as providing incorrect values offont metric parameters causing TEX engines to produceincorrect results) In addition font problems can alsoinclude encoding issues or incorrect glyph shapes

Font problems of the fatal kind did not occur whiletesting OpenType math fonts but a similar kind ofproblemwas recently reported for some OpenType textfonts The problem was quickly addressed with a fix inLuaTEX 061 to make the font parsing algorithms morerobust about handling unexpected values

Font problems of the more subtle kind were foundwith incorrect parameter settings in the MATH table ofCambria Math and Asana Math which caused LuaTEXto produce incorrect results

The problem is related to the OpenType math pa-rameter DisplayOperatorMinHeight which is used inLuaTEX to determine the minimum size of displaystyleoperators If this parameter is incorrectly set too smallin the font displaystyle operators will appear in thesame size as textstyle operators (An example of theincorrect behavior is illustrated in Figure 2)

As it turned out the problem had already been foundearlier when OpenType math support in LuaTEX wasfirst tested with ConTEXt and a workaround had beenapplied but the same problem now reappeared whenLuaTEX was tested with LuaLaTEX

int10491371205761048998119916 sdot d119943 = int

1049153120582 d119881 int

1049137119913 sdot d119943 = 0

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

Figure 2 Comparison of the size of displaystyle operators inCambria Math for LuaTEX with incorrect parameter values ofDisplayOperatorMinHeight and with a correction applied at themacro level (The example shows the integral form of theMaxwell equations from electrodynamics)

In ConTEXt a patch for incorrect font parametershad been applied in the font loading code at the Lualevel in font-patlua but a similar patch was missingin luaotfload Until this is fixed a workaround to thesame effect can be applied at the macro level by settingUmathoperatorsizedisplaystyle=136pt

In any case such kinds of patches for specific fontparameter values only present a stop-gap solution untilthe actual fonts can be fixed Whether or not this willbe possible critically depends on the cooperation of thefont developer or distributor and may range betweenvery quickly (for some open source projects) and nextto impossible (for some commercial fonts)

Problems with OpenType font shapesFont problems of yet another kind can occur when theassignment of glyph shapes to Unicode slots does notmatch the expectations or when an incorrect font styleis used for some glyphs

One such problem was discovered for the partialdifferential symbol in Cambria Math and XITS MathSince Unicode math provides a separate slot for a mathitalic version (U+1D715) one would expect the defaultslot (U+2202) to be reserved for the upright version yetthe Unicode font tables incorrectly happen to show anitalic version in both slots and no upright version

Given the confusion in the Unicode font tables it isnot surprising that several OpenType math fonts haveinherited the same problem Unfortunately such fontproblems are unlikely to be fixed anytime soon

part 120597 120539 120655 Cambria Math

part 120597 120539 120655 XITS Math

part 120597 120539 120655 Asana Math

Figure 3 Comparison of different font shapes of the partialdifferential symbol (upright italic bold upright bold italic) asthey appear in Cambria Math XITS Math and Asana MathBesides the confusion of upright vs italic there are also someobvious problems for some of the bold italic versions

120

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 7: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 5

Problems with TEX macro packagesProblems with TEX (or Lua) macro packages are usuallyeasy to fix In the course of the TEX Live 2010 pretesta number of such issues were found in luaotfload andunicode-math which have already been fixed

Only one issue has remained unresolved which isrelated to the use of the hbar macro In a traditionalLaTEX setting hbar is a macro which overlays theitalic letter ℎ with a bar accent from cmr to produce ℎBy contrast hslash is a macro to access a ready-madeglyph from the AMS fonts to produce ℏ

In a Unicode math setting only hslash is assignedto a slot in an OpenTypemath font (U+210F) while thereis no equivalent assignment for hbar which has some-how retained its original macro definition and still usesa glyph from cmr to create the overlay For lack of abetter solution it would be better to define hbar as analias for hslash in unicode-math

Quite a different effect occurs in ConTEXt wherehbar is interpreted as a diacritic text character (ħ) inupright shape (U+0127) which may be appropriate intext typesetting but not necessarily in a math formulaAs in unicode-math it would be better to define hbaras an alias for hslash in ConTEXt as well

Problems caused by interactions betweenTEX macro packages and TEX enginesYet another kind of problem was discovered recentlywhich was caused by an interaction problem betweenmacro packages and TEX engines specifically betweenthe unicode-math package and the XeTEX engine

As it turned out unicode-math allocated a newmathfamily for the OpenType math font (such as family 4)while XeTEX (unlike LuaTEX) somehow still expectedcertain math font parameters to be taken from families2 and 3 (as in traditional TEX engines)

As a result the preloaded font metric parametersfrom cmsy and cmexwere incorrectly used to determinethe spacing of math instead of the font parameters fromthe OpenType math font

A fix for this problem is still pending but most likelyit would involve changing the unicode-math packageto account for different engine-specific behaviors ofLuaTEX and XeTEX As a workaround we can applya fix by reassigning the fonts in families 2 and 3 afterloading an OpenType math font in family 4

ifxetexeverymathtextfont3 = textfont4textfont2 = textfont4scriptfont2 = scriptfont4scriptscriptfont2 = scriptscriptfont4

fi

Font-loading problemsFont-loading problems are usually easy to fix or avoidonce the cause of the problem has been understoodNevertheless such kinds of problems present a frequentsource of frustration for unwary users so it may wellbe useful to discuss our experiences regarding the fontloading problems we encountered in the course of test-ing OpenType math with TEX Live 2010

What is important here is to understand that differ-ent mechanisms are used to locate OpenType fonts indifferent TEX engines and macro packages

In XeTEX the fontconfig library is used to locateOpenType fonts and this mechanism applies equallywell for system fonts installed in the system font pathas for fonts installed in your TEX Live distribution

Depending on your installation it may be necessaryto adjust the fontsconf config file to include the fontdirectories in your texmf-dist or texmf-local tree andto refresh the font cache with the fc-cache commandOnce a font directory has been added to the search pathall kinds of font files will be found there regardless ofwhere the font files are located

In LuaTEX the kpathsea path searching library isused to locate fonts which depends on the assignmentof file extensions (such as ttf or otf) to differentsearch paths As a result of this cambriattc will onlybe found in the fontstruetype tree while eulerotfwill only be found in the fontsopentype tree

In addition to that ConTEXt and luaotfload onLuaTEX use yet another font-loading mechanism basedon a file cache implemented in Lua which circumventsthe kpathsea library completely System fonts outsidethe TEXMF tree will be located using the fontsconfconfig file to look up the font directories but withoutusing the the fontconfig library Once a font directoryhas been added to the file cache all kinds of font fileswill be found there regardless of where the fonts arelocated similar to the fontconfig library

Comparing and testing the qualityof OpenType math typesettingTo proceed with a study the quality of OpenType mathfont support as of TEX Live 2010 we have the follow-ing choices of typesetting engines and macro packagesat our disposal (disregarding Plain LuaTEX and XeTEXwhich only provide low-level support)

LuaTEX with ConTEXt MkIVLuaTEX with LuaLaTEXXeTEX with XeLaTEX

121

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 8: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

6 CONTEXT MEETING 2010 Ulrik Vieth

While both LuaLaTEX and ConTEXt share the sameTEX engine and the same implementation of math type-setting algorithms they differ in their high-level userinterface and also in the intermediate levels of fontloading code (such as luaotfload)

While both LuaLaTEX and XeLaTEX share the sameuser interface of unicode-math and fontspec they arebased on different TEX engines LuaTEX and XeTEXwhich differ significantly in their implementations ofmath typesetting algorithms

Comparing the results of LuaLaTEX and ConTEXtshould not be expected to expose any differences in theoutput from identical math typesetting algorithms butif there are any differences a closer analysis should helpto detect bugs or inconsistencies in the different macropackages andor in the font loading code

Comparing the results of LuaLaTEX and XeLaTEXhowever should indeed be expected to expose somedifferences in the underlying typesetting algorithmsHopefully an analysis of these differences should allowto draw conclusions how the quality of math is affectedand could be improved by taking advantage of a full-featured implementation of OpenType math

Testing a sampling of OpenType mathWhen we began testing OpenType math support withTEX Live 2010 we didnrsquot have time to do systematic andcomprehensive testing which would have been a verytime-consuming and tedious task

Instead we wanted to get some quick impressionshow well OpenType math support worked and if itwould be ready for practical use so we concentratedon testing just a sampling of mathematical notationsGiven our personal background in typesetting mathe-matical physics we started by creating a sample testdocument containing a selection of famous equationsfrom various fields of physics sampling various kindsof mathematical notations

In addition to testing the available choices of TEXengines and macro packages we also wanted to test asampling of the available OpenType math fonts so weproceeded to typeset identical copies of our test fileswith different TEX engines and with different choicesof math fonts for each of Cambria Math XITS MathAsana Math and Neo Euler

Some examples of typesetting such test pages withdifferent fonts are shown in Figures 8ndash11 except thateach font sample was usually typeset at least twice withLuaLaTEX and XeLaTEX

In some cases we also tested an additional versionwith ConTEXt MkIV but unfortunately we had to use amodified version of our test files in such cases

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 4 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe definition of the Laplace operator in vector analysis)

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 5 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) using Cambria Math (The example showsthe Einstein field equation from general relativity)

Analyzing large-scale effectsComparing the different versions for the same fonttypeset with different engines or macro packages mayreveal significant differences at various scales

If there are any unexpected large-scale effects suchas using different sizes of delimiters or operators it isusually easy to spot them simply by visual inspectionIn most cases such obvious differences will turn out tobe unintentional and tend to indicate problems or bugssuch as those discussed earlier in this paper

Analyzing small-scale effectsOnce we have applied all the necessary workaroundsand bug fixes to eliminate the unexpected large-scaleeffects only small-scale effects should remain affectingtiny micro-typographic details which may be hard tosee without closer inspection

In order to the study the small-scale effects in moredetail we created another set of more sophisticated testfiles using PDF overlays between different versions ofthe same document using different colors

These overlays were generated with PDFLaTEX usingthe pdfpages package as follows

documentclass[a4paper]articleusepackagepdfpages

begindocumentincludepdfmerge[nup=2x1noautoscale=truedelta=-21cm 0] width of A4 paper

xelatex-testpdf1lualatex-testpdf1xelatex-testpdfnlualatex-testpdfn

enddocument

This setup will put each page of the LuaLaTEX test fileon top of the corresponding page of the XeLaTEX testfile For improved visibility colors should be chosen insuch a way that the darker colors (such as black or blue)will appear on top of the brighter colors (such as red)In our example illustrations we have usually used redfor XeLaTEX overlaid by blue for LuaLaTEX

122

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 9: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 7

Δ120601(119955) = 120597 120601120597119909 + 120597 120601

120597119910 + 120597 120601120597119911

1

Δ120601(119955) =1205971049000120601

1205971199091049000+

1205971049000120601

1205971199101049000+

1205971049000120601

1205971199111049000

1

Figure 6 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

119877 minus 12119877119892 + 120556119892 = minus8120587119866119888 119872

1

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

1

Figure 7 Comparison of math typesetting from XeLaTEX (red)and LuaLaTEX (blue) after applying a workaround for XeLaTEXto circumvent inconsistent placement of superscripts

Analyzing the results of overlaysOnce we have generated overlays of the results fromtypesetting the same equations with different enginesit is easy to detect if any differences occur Howeverit is far from easy to understand how these differencescome about and what their implications might be

In our first series of tests we originally noticed somevery significant differences in vertical spacing aroundfraction bars Once we detected the problem of XeTEXincorrectly using the preloaded set of font parametersand applied a workaround most differences in verticalspacing disappeared and only few remained

In our second series of tests only relatively fewdifferences remained Moreover the remaining effectsonly appeared for some fonts and not for others Whilethere were hardly any effects on vertical spacing forXITS Math there were some notable differences in theplacement of scripts for Asana Math or Cambria Mathas illustrated in Figures 4ndash5

Upon closer inspection we eventually found that thedifferences only affected some letters within an equa-tion but not all of them There were no differenceson letters without ascenders or descenders (as in 1199090or 1199092) while there were differences for superscripts onletters with ascenders (as in 1205972) and also for subscriptson letters with descenders (as in 1205830) The cause of thisproblem isnrsquot clear yet but it most likely indicates anunresolved engine problem in XeTEX

In our third series of tests the remaining effects onvertical spacing could be eliminated completely afterwe applied a workaround for the placement of scriptsand only some effects on horizontal spacing remainedas illustrated in Figures 6ndash7

The remaining effects on horizontal spacing are mostlikely related to different interpretations of OpenTypeglyph metrics in different TEX engines (such as italiccorrections and math kerning [18]) which certainlywill have an effect on the quality of math typesettingbut only on a very small scale

Summary and ConclusionsIn this paper we have reported our experiences find-ings and observations from testing OpenType mathsupport in TEX Live 2010 with different TEX enginesmacro packages and fonts

When we set out we expected to gain some insightshow the quality of math typesetting was affected by theuse of additional font parameters in a more sophisti-cated implementation of OpenType math support

In the end however it turned out that most of thedifferences were actually caused by unresolved bugs inboth macro packages and TEX engines while the use ofadditional math font parameters appears to be largelyirrelevant for our selection of test cases

It was only by direct comparison with LuaTEX thatsome long-standing bugs or inconsistencies in XeTEXengine and the unicode-math package could be foundWithout a suitable baseline reference it is obviouslyhard to tell if the spacing of math is exactly right orjust slightly wrong so it is not surprising that minorinconsistencies went unnoticed for a long time

Once we applied workarounds or fixes for the prob-lems we discovered the remaining differences betweendifferent TEX engines turned out to be much smallerthan expected and only affected the horizontal spacingbut no longer the vertical spacing

Given the scale of the remaining effects our studiesregarding the quality of math typesetting in differentTEX engines remain inconclusive for now Both enginescan produce very similar results but XeTEX will do soonly after applying a number of fixes and workaroundsto arrive at what LuaTEX will do by default

AcknowledgementsThe author would like to thank the developers involvedin math-related TEX engines macro packages and fontsfor their assistance and feedback during the testing ofOpenType math font support in TEX Live 2010

In particular Will Robertson (unicode-math) KhaledHosny (luaotfload) Taco Hoekwater (LuaTEX) HansHagen (ConTEXt) Jonathan Kew (XeTEX) Karl Berryand Peter Breitenlohner (TEX Live 64-bit Linux binaries)contributed to our testing and problem solving effortsin one way or another

Fortunately we were able to discover and eliminatea number of bugs before the deadline of TEX Live 2010pretest Unfortunately not all known issues could beresolved in time so some problems remain to be fixedin future releases While such fixes for macro packagesand fonts can be issued through the TEX Live updatemechanism at any time fixes for TEX engines may bedelayed until next yearrsquos TEX Live release

123

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 10: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

8 CONTEXT MEETING 2010 Ulrik Vieth

Cambria Math ExampleVector calculus

120513120601(119955) =part120601

part1199091199421049181 +

part120601

part1199101199421049182 +

part120601

part1199111199421049183

Δ120601(119955) =part1049000120601

part1199091049000+part1049000120601

part1199101049000+part1049000120601

part1199111049000

Maxwell equations (differential form)

div 1205761048998119916 = 120582 div119913 = 0

rot 119916 = minuspart119913

part119905 rot

119913

1205831048998= 119947 +

part1205761048998119916

part119905

Maxwell equations (integral form)

int1049137

1205761048998119916 sdot d119943 = int1049153

120582 d119881 int1049137

119913 sdot d119943 = 0

∮1049134

119916 sdot d119949 = minusd

d119905int1049137

119913 sdot d119943

∮1049134

119913

1205831048998sdot d119949 = int

1049137

(119947 +part1205761048998119916

part119905) sdot d119943

Electromagnetic wave equations

Δ119916 minus1

1198881049000part1049000119916

part1199051049000=

1

1205761048998120513120582 + 1205831048998

part119947

part119905

Δ119913 minus1

1198881049000part1049000119913

part1199051049000= minus1205831048998 rot 119947

Energy-mass equation (special relativity)

119864 =1198981048998119888

1049000

radic1 minus 11990710490001198881049000

Einstein 1048925ield equation (general relativity)

11987710492211049222 minus1

211987711989210492211049222 + 12055611989210492211049222 = minus

8120587119866

119888104900011987210492211049222

Schroumldinger equation (quantummechanics)

iℏpart120595

part119905= 1049636119867120595 =

1

2119898(ℏ

i120513 minus 119902119912)

1049000

120595 + 119902120601120595

Dirac equation (relativistic quantummechanics)

1205741049210(ℏ

ipart1049210 minus 1199021198601049210)120595 +1198981048998119888 120595 = 0

Figure 8 Sampling of equations typeset with LuaLaTEX usingCambria and Cambria Math

Asana Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part1048685120601part1199091048685

+part1048685120601part1199101048685

+part1048685120601part1199111048685

Maxwell equations (differential form)

div 1205761048683119916 = 120582 div119913 = 0

rot 119916 = minuspart119913part119905

rot1199131205831048683

= 119947 +part1205761048683119916part119905

Maxwell equations (integral form)

10491251198651205761048683119916 sdot d119943 = 1049125

119881120582d119881 1049125

119865119913 sdot d119943 = 0

1049072119862119916 sdot d119949 = minus

dd119905 1049125119865

119913 sdot d119943

1049072119862

1199131205831048683

sdot d119949 = 10491251198651049218 119947 +

part1205761048683119916part119905 1049221 sdot d119943

Electromagnetic wave equations

Δ119916 minus11198881048685

part1048685119916part1199051048685

=11205761048683

120513120582 + 1205831048683part119947part119905

Δ119913 minus11198881048685

part1048685119913part1199051048685

= minus1205831048683 rot 119947

Energy-mass equation (special relativity)

119864 =11989810486831198881048685

radic1 minus 11990710486851198881048685

Einstein field equation (general relativity)

119877120583120584 minus12119877119892120583120584 + 120556119892120583120584 = minus

81205871198661198881048685

119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 1049139119867 120595 =121198981049218

ℏi120513 minus 1199021199121049221

1048685

120595 + 119902120601120595

Dirac equation (relativistic quantum mechanics)

1205741205721049218ℏipart120572 minus 1199021198601205721049221120595 + 1198981048683119888 120595 = 0

Figure 9 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Asana Math

124

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 11: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

Experiences typesetting OpenType math with LuaLaTEX and XeLaTEX CONTEXT MEETING 2010 9

XITS Math ExampleVector calculus

120513120601(119955) =part120601part119909

119942119909 +part120601part119910

119942119910 +part120601part119911

119942119911

Δ120601(119955) =part2120601part1199092 +

part2120601part1199102 +

part2120601part1199112

Maxwell equations (differential form)

div 1205760119916 = 120582 div 119913 = 0

rot 119916 = minuspart119913part119905

rot 1199131205830

= 119947 +part1205760119916

part119905

Maxwell equations (integral form)

int1198651205760119916 sdot d119943 = int119881

120582 d119881 int119865119913 sdot d119943 = 0

∮119862119916 sdot d119949 = minus d

d119905 int119865119913 sdot d119943

∮119862

1199131205830

sdot d119949 = int119865 (119947 +part1205760119916

part119905 ) sdot d119943

Electromagnetic wave equations

Δ119916 minus 11198882

part2119916part1199052 = 1

1205760120513120582 + 1205830

part119947part119905

Δ119913 minus 11198882

part2119913part1199052 = minus1205830 rot 119947

Energy-mass equation (special relativity)

119864 =11989801198882

radic1 minus 11990721198882

Einstein field equation (general relativity)

119877120583120584 minus 12

119877119892120583120584 + 120556119892120583120584 = minus81205871198661198882 119872120583120584

Schroumldinger equation (quantum mechanics)

iℏpart120595part119905

= 120595 = 12119898(

ℏi

120513 minus 119902119912)

2120595 + 119902120601 120595

Dirac equation (relativistic quantum mechanics)

120574120572(

ℏi

part120572 minus 119902119860120572)120595 + 1198980119888 120595 = 0

Figure 10 Sampling of equations typeset with LuaLaTEX usingXITS and XITS Math

Neo Euler ExampleVector calculus

nablaϕ(119851) = partϕpartx 119838x +

partϕparty 119838y +

partϕpartz 119838z

Δϕ(119851) = part2ϕpartx2 + part

2ϕparty2 +

part2ϕpartz2

Maxwell equations (differential form)

div ε0119812 = λ div119809 = 0

rot 119812 = minuspart119809partt rot 119809μ0= 119843 + partε0119812partt

Maxwell equations (integral form)

intFε0119812 sdot d119839 = intV

λdV intF119809 sdot d119839 = 0

∮C119812 sdot d119845 = minus ddt intF

119809 sdot d119839

∮C119809μ0

sdot d119845 = intF(119843 + partε0119812partt )

sdot d119839

Electromagnetic wave equations

Δ119812 minus 1c2part2119812partt2 = 1

ε0nablaλ + μ0

part119843partt

Δ119809 minus 1c2part2119809partt2 = minusμ0 rot 119843

Energy-mass equation (special relativity)

E = m0c2

radic1minus v2c2

Einstein field equation (general relativity)

Rmicroν minus 12Rgmicroν +Λgmicroν = minus8πGc2 Mmicroν

Schroumldinger equation (quantum mechanics)

ihpartψpartt = Hψ =12m(

hi nabla minus q119808)

2ψ+ qϕψ

Dirac equation (relativistic quantum mechanics)

γα(hi partα minus qAα)

ψ+m0cψ = 0

Figure 11 Sampling of equations typeset with LuaLaTEX usingTEX Gyre Pagella and Neo Euler

125

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126

Page 12: Experiences typesetting OpenType math with LuaLaTeX and ...cahiers.gutenberg.eu.org/cg-bin/article/CG_2011___56_116_0.pdf · 1tT2`B2M+2b hvT2b2iiBM; PT2MhvT2 J i? rBi? Gm G h 1 s

10 CONTEXT MEETING 2010 Ulrik Vieth

References[ 1 ] TEX Users Group Testing TEX Live before release

httptugorgtexlivepretest[ 2 ] Barbara Beeton Asmus Freytag Murray Sargent III

Unicode Support for MathematicsUnicode Technical Report UTR25 2001httpwwwunicodeorgreportstr25

[ 3 ] Barbara Beeton Unicode and math a combinationwhose time has come TUGboat 21(3)174ndash185 2000Proceedings of TUG 2000 Oxford UKhttpwwwtugorgTUGboattb21-3tb68beetpdf

[ 4 ] Barbara Beeton The STIX Project ndash From Unicodeto fonts TUGboat 28(3)299ndash304 2007Proceedings of TUG 2007 San Diego CA USAhttpwwwtugorgTUGboattb28-3tb90beetpdf

[ 5 ] Ulrik Vieth Math Typesetting in TEX The GoodThe Bad The Ugly MAPS 26207ndash216 2001Proceedings of EuroTEX 2001 Kerkrade Netherlandshttpwwwntgnlmaps2627pdf

[ 6 ] OpenType Specification Version 16httpwwwmicrosoftcomtypographyotspec

[ 7 ] Murray Sargent III Math in Office Bloghttpblogsmsdncommurraysdefaultaspx

[ 8 ] John Hudson Ross Mills Mathematical TypesettingMathematical and scientific typesetting solutionsPromotional Booklet Microsoft 2006

[ 9 ] Daniel Rhatigan Three typefaces for mathematicsDissertation for the MA in typeface design 2007httpwwwtypeculturecomacademic_resourcearticles_essayspdfstc_article_47pdf

[ 10 ] Murray Sargent III Unicode Nearly Plain TextEncodings of MathematicsUnicode Technical Note UTN28 2006httpwwwunicodeorgnotestn28

[ 11 ] George Williams FontForge Math typesettinginformationhttpfontforgesourceforgenetmathhtml

[ 12 ] Ulrik Vieth Do we need a lsquoCorkacute math fontencoding TUGboat 29(3)426ndash434 2008Proceedings of TUG 2008 Cork IrelandhttpwwwtugorgTUGboattb29-3tb93viethpdf

[ 13 ] Ulrik Vieth OpenType Math Illuminated Reprintedin TUGboat 30(1)22ndash31 2009Proceedings of BachoTEX 2009 Bachotek PolandhttpwwwtugorgTUGboattb30-1tb94viethpdf

[ 14 ] Bogusław Jackowski Appendix G IlluminatedTUGboat 27(1)83ndash90 2006Proceedings of EuroTEX 2006 Debrecen HungaryhttpwwwtugorgTUGboattb27-1tb86jackowskipdf

[ 15 ] Ulrik Vieth Understanding the aeligsthetics of mathtypesetting Biuletyn GUST 5ndash12 2008Proceedings of BachoTEX 2008 Bachotek Polandhttpwwwgustorgplprojectse-foundrymath-supportvieth2008pdf

[ 16 ] Jonathan Kew XeTEX Live TUGboat 29(1)151ndash1562008Proceedings of BachoTEX 2007 Bachotek PolandhttpwwwtugorgTUGboattb29-1tb91kewpdf

[ 17 ] Taco Hoekwater LuaTEX Reference Manualhttpwwwluatexorgsvntrunkmanualluatexref-tpdf

[ 18 ] Taco Hoekwater Math in LuaTEX 040MAPS 3822ndash31 2009httpwwwntgnlmaps3804pdf

[ 19 ] Hans Hagen Unicode Math in ConTEXtMAPS 3832ndash46 2009httpwwwntgnlmaps3805pdf

[ 20 ] Will Robertson Advanced font features with XeTEXThe fontspec package TUGboat 26(3)215ndash223 2005httpwwwtugorgTUGboattb26-3tb84robertsonpdf

[ 21 ] Will Robertson The fontspec macro packagehttpwwwctanorgpkgfontspechttpgithubcomwsprfontspec

[ 22 ] Will Robertson The unicode-math macro packagehttpwwwctanorgpkgunicode-mathhttpgithubcomwsprunicode-math

[ 23 ] Aditya Mahajan Integrating Unicode and OpenTypemath in ConTEXt TUGboat 30(2)243ndash246 2009Proceedings of TUG 2009 Notre Dame IN USAhttpswwwtugorgmembersTUGboattb30-2tb95mahajan-cmathpdf

[ 24 ] Khaled Hosny et al The luaotfload macro packagehttpwwwctanorgpkgluaotfloadhttpgithubcomkhaledhosnyluaotfload

[ 25 ] Will Robertson Unicode mathematics in LaTEXadvantages and challengesTo appear in TUGboat 31(2)ndash 2010Proceedings of TUG 2010 San Francisco CA USAhttpswwwtugorgmembersTUGboattb31-2tb98robertsonpdf

[ 26 ] Ulrik Vieth Experiences typesetting mathematicalphysics MAPS 39166ndash178 2009Proceedings of EuroTEX 2009 Delft NetherlandshttpswwwtugorgmembersTUGboattb30-3tb96viethpdf

[ 27 ] Apostolos Syropoulos Asana Math Fonthttpwwwctanorgpkgasana-math

[ 28 ] Khaled Hosny XITS Fontshttpwwwctanorgpkgxitshttpgithubcomkhaledhosnyxits-math

[ 29 ] STIX Consortium STIX Fontshttpwwwstixfontsorghttpwwwctanorgpkgstix

[ 30 ] Khaled Hosny Neo Euler Fonthttpgithubcomkhaledhosnyeuler-otf

[ 31 ] Hans Hagen Taco Hoekwater Volker RW SchaaReshaping Euler A collaboration with HermannZapf TUGboat 29(3)283ndash287 2008httpwwwtugorgTUGboattb29-2tb92hagen-eulerpdf

Ulrik ViethVaihinger Straszlige 6970567 StuttgartGermanyulrik dot vieth (at) arcor dot de

126