CTAN Comprehensive TeX Archive Network

Direc­tory macros/latex/contrib/mathastext

        +                                           +
        +                mathastext                 +
        +                                           +
        +     'Use the text font in math mode'      +
        +                                           +

This Work may be dis­tributed and/or mod­i­fied un­der the con­di­tions of the LPPL1.3c

The Author of this Work is Jean-Fran­cois Burnol

Copy­right (C) 2011-2018 Jean-Fran­cois Burnol (jfbu at free dot fr)

  Source: mathastext.dtx 1.3t 2018/08/22
cu­mu­la­tive Change Log at bot­tom of this file.


Op­ti­mal ty­po­graph­i­cal re­sults for doc­u­ments con­tain­ing math­e­mat­i­cal sym­bols can only be hoped for with math fonts specif­i­cally de­signed to match a given text type­face. Although the list of freely avail­able math fonts (along­side the Com­puter Modern and AMS ex­ten­sion fonts) is slowly ex­pand­ing (fourier, kp­fonts, math­de­sign, px­fonts, tx­fonts, newpx, newtx, ...) it re­mains lim­ited, and the sit­u­a­tion is even worse with Uni­code fonts (/Lua). So if you can't find a math font which fits well with your fa­vorite text font, and wish to still be able to type­set math­e­mat­i­cal doc­u­ments, per­haps not of the high­est ty­po­graph­i­cal qual­ity, but at least not sub­jected to ob­vi­ous vi­sual in­com­pat­i­bil­i­ties be­tween your text font and the math fonts, try out math­as­text: it will sim­ply use the text font also for the math!


mathastext is a pack­age


The doc­u­ment will use in math mode the text font as con­fig­ured at pack­age load­ing time, for these char­ac­ters:


Main op­tions: italic, subdued, LGRgreek.

  • Use the italic op­tion to get the Latin let­ters in math mode be in ital­ics. Dig­its and log-like op­er­a­tor names (pre-de­fined as well as user-de­fined) will be in the same shape as the text font (usu­ally this means up­right).
  • each \Mathastext[<name>] in the pream­ble de­fines a math ver­sion to be later ac­ti­vated in the doc­u­ment body via the com­mand \MTversion{<name>}.
  • With the subdued op­tion, math­as­text will be ac­tive only in­side such math ver­sions.
  • For doc­u­ments need­ing Greek let­ters the fol­low­ing is pos­si­ble:
    • no op­tion: Greek let­ters de­fined by other pack­ages,
    • eulergreek: use the Euler font for the Greek let­ters,
    • symbolgreek: use the Postscript Sym­bol font for the Greek let­ters.
    • LGRgreek: use the doc­u­ment text font in LGR en­cod­ing. Fur­ther op­tions spec­ify the shape of the low­er­case and up­per­case Greek glyphs; start­ing with v1.15c it is pos­si­ble to use mul­ti­ple dis­tinct LGR fonts in the same doc­u­ment.
  • Com­mands are pro­vided to scale the Euler and Sym­bol fonts by an ar­bi­trary fac­tor to let them fit bet­ter with the doc­u­ment text font.
  • \MTsetmathskips al­lows to set up ex­tra spac­ings around let­ters.


Us­ing the man­ager of your in­stal­la­tion

math­as­text is in Live and Mik. Just use the pack­age man­ager to up­grade or in­stall it.

From mathastext.tds.zip

user in­stall in $HOME folder: unzip -d <destfolder> mathastext.tds.zip, where <destfolder> could be ~/texmf or on ma­cosx ~/Library/texmf.

From mathastext.dtx

  • with math­as­text.ins: run tex on math­as­text.ins to gen­er­ate the pack­age style file math­as­text.sty as well as math­as­text.tex and some test files.
  • with­out math­as­text.ins: run tex (or etex) on math­as­text.dtx to gen­er­ate the pack­age style file math­as­text.sty as well as math­as­text.tex and some test files. (and also math­as­text.ins)
  • Move the style file math­as­text.sty to a lo­ca­tion where can find it. In a TDS com­pli­ant hi­er­ar­chy this will be <TDS>:tex/la­tex/math­as­text/math­as­text.sty

Gen­er­at­ing doc­u­men­ta­tion and test files

Run tex (or etex) on math­as­text.dtx to gen­er­ate math­as­text.tex and some test files:


To gen­er­ate the doc­u­men­ta­tion (with source code):

latex mathastext.tex (thrice)
dvipdfmx mathastext.dvi

The file math­as­text.tex can be cus­tomized to change the font size or set other op­tions therein. Al­ter­na­tive: pdfla­tex math­as­text.dtx (thrice). This pro­duces the doc­u­men­ta­tion with­out the source code.

(One can­not use lu­ala­tex or xe­la­tex to com­pile the doc­u­men­ta­tion.)


1.3t [2018/08/22]

  • bug­fix: the 1.3s bug­fix about subdued com­pat­i­bil­ity with fontspec was de­fi­cient.
  • bug­fix: very old (v1.2, 2012/12/20) bug caus­ing low-level er­ror dur­ing pack­age load­ing (with pdfla­tex) when set­ting up the math mi­nus sign to be the text font en­dash char­ac­ter, in cases with \encodingdefault other than OT1, T1 or LY1, e.g. some­thing like T2A.
  • \imath and \jmath obey the subdued regime. And the mi­nus sign is now han­dled es­pe­cially to en­sure per­fect com­pat­i­bil­ity with the subdued op­tion.
  • break­ing change: mathastext does not re­de­fine any­more \i and \j to let them be us­able both in text and math mode.

1.3s [2018/08/21]

  • fix to an is­sue with subdued op­tion in a fontspec con­text.


1.3r [2016/11/06]

  • doc­u­men­ta­tion tweaks.

1.3q [2016/10/31]

  • new op­tion unicodeminus.
  • the Recent Changes sec­tion of the doc­u­men­ta­tion has been re­moved as it was a du­pli­cate of in­for­ma­tion avail­able in the Change Log.
  • some other changes in the doc­u­men­ta­tion, in par­tic­u­lar the use of straight quotes in ver­ba­tim.

1.3p [2016/05/13]

  • bug­fix: re­lease 1.3n had for­got­ten to ac­ti­vate by de­fault its new cus­tomiza­tion of the ams­math macro \newmcodes@ (it was done from us­ing \MTversion in the doc­u­ment body but not by de­fault at start of body.)
  • pub­lic name \MTfixmathfonts for a 1.3o macro.

1.3o [2016/05/03]

  • mathastext fixes an is­sue re­lated to a fea­ture of LuaLaTeX and luaotfload that OpenType fonts are de­clared in one of two modes: node and base, and only the lat­ter is func­tional in math mode. But by de­fault text fonts are de­clared in mode node. Thus mathastext now in­ter­venes to make it so that the font it de­clares in math mode will use mode base. This fixes is­sues with for ex­am­ple old style fig­ures be­ing used while the text font used lin­ing fig­ures (or vice versa, de­pend­ing on the font). But see the code com­ments for more.

1.3n [2016/04/22]

  • at long last, mathastext takes care prop­erly of an­noy­ing and per­plex­ing ams­math's \newmcodes@. The very re­cent change in amsopn.sty fi­nally made it com­pat­i­ble with Uni­code en­gines, but any­how, mathastext must do its own patch to use the cor­rect font. All of this tak­ing into ac­count the var­i­ous op­tions passed to the pack­age. Lots of trou­ble for a tiny thing.

1.3m [2016/04/02]

  • mi­nor code main­te­nance be­fore an­nual TL freeze.

1.3l [2016/01/29]

  • com­pat­i­bil­ity with fontspec's up­com­ing switch from EU1/EU2 to TU com­mon to both Uni­code en­gines.

1.3k [2016/01/24]

  • ty­pos fixed in the doc­u­men­ta­tion. In par­tic­u­lar, the README link to the pack­age home­page had re­mained bro­ken from day one of the pack­age re­leases: mathastext.html therein was mis­spelled as mathsastext.html! (but the pdf doc­u­men­ta­tion had the cor­rect link; as well as the CTAN cat­a­logue).

1.3j [2016/01/15]

  • re­named and mod­i­fied re­cent 1.3i's \MTactivemathoff into \MTeverymathoff. Added \MTeverymathdefault.
  • subdued mode is a bit stronger: also the as­ter­isk re­verts to the de­fault (if it was mod­i­fied due to op­tion asterisk), the added ex­tra \mskip's (use­ful with up­right fonts) for ', \exists, and \forall are sup­pressed rather than re-con­fig­ured to use 0mu. Re­lated new com­mands \MTexistsdoesskip, \MTforalldoesskip, \MTprimedoesskip, \MTnormalexists, \MTnormalforall, \MTnormalprime.
  • the tog­gle for us­ing math­e­mat­i­cally ac­tive let­ters is only emit­ted once dur­ing pack­age load­ing; the \Mathastext com­mand does not do it any­more; the use in the pream­ble of \MTmathstandardletters, or \MTnoicinmath and re­lated com­mands is not over­ruled by later use of \Mathastext.
  • quite a few doc­u­men­ta­tion im­prove­ments and rewrites, par­tic­u­larly in the de­scrip­tion of com­mands which are re­lated to the mod­i­fi­ca­tions of math­codes (mainly for math ac­ti­va­tion of char­ac­ters or let­ters) as done by math­as­text at \everymath or \everydisplay.

1.3i [2016/01/06]

  • \url from url.sty as well as \url and \nolinkurl from hyperref.sty use math mode and (by de­fault) the monospace text font. To avoid math­as­text over­writ­ing the spe­cial prepa­ra­tion done by {url,hyperref}.sty the com­mands \url/\nolinkurl are patched to do au­to­mat­i­cally \MTactivemathoff (now \MTeverymathoff) be­fore en­ter­ing math mode.
  • the ex­tra skips spec­i­fied by \MTsetmathskips are not in­serted around let­ters if in­side the ar­gu­ments of math al­pha­bet com­mands, or within op­er­a­tor names.
  • the added ex­plicit italic cor­rec­tions (for non-oblique fonts) were dis­abled within math al­pha­bet scopes, ex­cept mathnormal; they are now dis­abled within all math al­pha­bets, in­clu­sive of mathnormal.

1.3h [2015/10/31]

  • bug­fixes: since 1.3d 2014/05/23 the op­tion symbolgreek caused \ell to be­come un­de­fined, and, sim­i­larly but far worse, op­tions selfGreek, selfGreeks caused all low­er­case Greek let­ters \alpha, \beta, etc.. to be­come un­de­fined.

1.3g [2015/10/15]

  • fol­low­ing 2015/10/01 re­lease, re­moval of the "luatex" pre­fix from the names of the Lua math prim­i­tives. Com­pat­i­bil­ity main­tained with older for­mats.

1.3f [2015/09/12]

  • the re­place­ment of ams­math's \resetMathstrut@, when it is done, emits an Info rather than a Warn­ing as this could be po­ten­tially stress­ful to some users.
  • the README self-ex­tracts from the dtx source, as a text file README.md with Mark­down syn­tax.

1.3e [2015/09/10]

  • bug­fix: un­der op­tion nos­mall­de­lims, \lbrace and \rbrace were re­de­fined as math sym­bols and could not be used as de­lim­iters.

1.3d [2015/02/26]

  • the doc­u­men­ta­tion men­tions the im­proved com­pat­i­bil­ity of math­as­text with the lat­est (3.34) beamer re­lease: no more need for \usefonttheme{professionalfonts}.

1.3d [2014/05/23]

  • new com­mands \MTstandardgreek and \MTcustomgreek.
  • The Greek let­ters, in case of use of one of the pack­age re­lated op­tions, are left to their de­faults in the nor­mal and bold math ver­sions if the sub­dued op­tion was also used (this was so far the case only with op­tions LGR­greek/LGR­greeks).
  • \newmcodes@ of ams­math is left un­touched if pack­age lu­ala­tex-math is de­tected.

1.3c [2013/12/14]

  • added a starred vari­ant to \MTversion which tells math­as­text to only do the math set-up and not mod­ify the text fonts.
  • added sec­ond op­tional ver­sion name ar­gu­ment to \Mathastext and to \MTDeclareVersion, to trans­fer set­tings for things not oth­er­wise changed by math­as­text from a math ver­sion to the one de­clared. This is mainly for sym­bols and large sym­bols to be the bold ones when the user sets up the se­ries of a math­as­tex­ti­fied font to be bold in a math­as­text-de­clared ver­sion.
  • re­named \defaultprod to \MToriginalprod, \defaultsum to \MToriginalsum, (this is in case of op­tion sym­bol­misc).
  • changes to the dtx or­ga­ni­za­tion; op­tions for gen­er­at­ing the doc­u­men­ta­tion can be cus­tomized in gen­er­ated math­as­text.tex file.
  • 1.2d code for \#, \$, \%, and \& mod­i­fied er­ro­neously the ear­lier cor­rect 1.2c code and cre­ated a bug show­ing up with more than 16 math fam­i­lies (a pos­si­bil­ity only with lu­ala­tex or xe­la­tex).

1.3a [2013/09/04]

  • the some­what silly \string's are re­moved from the \MTsetmathskips com­mand of re­lease 1.3, thus al­low­ing its first ar­gu­ment to be a macro, or any ex­pand­able code, giv­ing a let­ter.
  • the ams­math \resetMathstrut@, which is in­com­pat­i­ble with a math­e­mat­i­cally ac­tive paren­the­sis ( is now mod­i­fied only if nec­es­sary (i.e. only when \MTnonlettersobeymathxx is is­sued) and is re­stored to its orig­i­nal value if not needed any­more (i.e. af­ter \MTnonlettersdonotobeymathxx, as for ex­am­ple when switch­ing to the nor­mal ver­sion un­der op­tion sub­dued).
  • im­proved doc­u­men­ta­tion.

1.3 [2013/09/02]

  • com­mands \MTsetmathskips and \MTunsetmathskips added.
  • com­mands \MTmathactiveletters and \MTmathstandardletters to gov­ern the math ac­ti­va­tion of let­ters in­de­pen­dently of its use for in­ser­tion of the italic cor­rec­tions (\MTicinmath and \MTnoicinmath cor­re­spond­ingly mod­i­fied).
  • the new \luatexUmathcodenum as avail­able since TL2013 al­lows iden­ti­cal treat­ment by math­as­text of = and - un­der both Lua and .
  • \newmcodes@ of ams­math is left un­touched in case of op­tion ba­sic.
  • a sen­tence con­tain­ing | which was writ­ten to the log dur­ing the load­ing caused a prob­lem if | was ac­tive (typ­i­cally if \MakeShortVerb{|} was added to the pream­ble prior to the load­ing of math­as­text).
  • some pre­emp­tive mea­sures taken re­gard­ing things such as \mid, \lbrace, and \rbrace, as some pack­ages de­fine these things in man­ners which made the re-def­i­ni­tions done by math­as­text is­sue er­rors.

1.2f [2013/01/21]

  • mi­nor code im­prove­ments. Change log added to the user man­ual.

1.2e [2013/01/10]

This ver­sion should be the last one in the 1.2 se­ries as it seems to cor­rect most of the main prob­lems which were in­tro­duced with the mas­sive use of math­e­mat­i­cally ac­tive char­ac­ters in ver­sions 1.2 and 1.2b.

  • It is in­deed a thorny point when one wants to mod­ify an ac­tive char­ac­ter in math mode only (with­out break­ing us­age in la­bel's and ref's for ex­am­ple). The pack­age now does that only if the ac­ti­va­tion orig­i­nated in the Ba­bel sys­tem as it is then pos­si­ble to mod­ify ap­pro­pri­ately the Ba­bel macros \user@active<char> and \normal@char<char>, at the time of en­ter­ing math mode (math­as­text does all its ac­ti­va­tion job at \everymath and \everydisplay).

The rel­e­vant is­sues are dis­cussed in sec­tion 2.10 of the user man­ual, in the test file math­as­texttestal­pha­bets.tex, and in the source code com­ments for macro \mst@mathactivate. The in­her­ent in­com­pat­i­bil­ity of Ba­bel with pack­ages hav­ing made math­e­mat­i­cally ac­tive the char­ac­ters it­self makes doc­u­ment ac­tive is cir­cum­vented by this in­ter­fer­ence of math­as­text. A gen­er­ally ap­pli­ca­ble Ba­bel patch could be de­rived from the method used by math­as­text.

For the non cat­code ac­tive char­ac­ters, math­e­mat­i­cal ac­ti­va­tion is used. This is done at the en­trance in math mode.

  • Sadly, the fea­ture of added italic cor­rec­tions in­tro­duced in ver­sion 1.2b did not be­have as de­scribed in the user man­ual, due to for­got­ten group braces. Fixed.
  • The com­mand \MTlowerast from the user man­ual of v1.2d was not the one im­ple­mented in the source code. Fixed.
  • The test files au­to­mat­i­cally ex­tracted from a la­tex run on the dtx file have been re­vised and ex­tended.
  • The code is bet­ter doc­u­mented.

1.2d [2013/01/02]

  • an in­com­pat­i­bil­ity with ams­math (its macro \resetMathstrut@), ex­ists since ver­sion 1.2 of the pack­age. This is fixed here.
  • var­i­ous im­prove­ments in deal­ing with the as­ter­isk and in the mech­a­nism of let­ting non-let­ter sym­bols obey the math al­pha­bet com­mands.
  • doc­u­men­ta­tion ex­tended and im­proved.

1.2c [2012/12/31]

  • math­as­text now in­serts au­to­mat­i­cally af­ter all (latin) let­ters in math mode their italic cor­rec­tions, if the font used is up­right (sic). This im­proves the spac­ings for the po­si­tion­ing of sub­scripts. The fea­ture is de-ac­ti­vated in­side the math al­pha­bets com­mands (apart from \mathnormal), so as to not pro­hibit the for­ma­tion of lig­a­tures.
  • the doc­u­men­ta­tion has been ex­tended to ex­plain in de­tail the is­sues which are rel­e­vant to the new fea­ture of added italic cor­rec­tions.
  • ver­sion 1.2 had some bad bugs when con­fronted to ac­tive char­ac­ters. This is cor­rected and ad­di­tion­ally \MTnonlettersdonotobeymathxx is made the de­fault, as the user in­put is too much con­strained in its ab­sence.
  • a less fa­tal, but still an­noy­ing, typo had made the dot in 1.2 of type \mathpunct rather than \mathord.
  • the in­ner names­pace has been ra­tio­nal­ized a bit.

1.2 [2012/12/20]

  • a new com­mand sets up the amount of space to be au­to­mat­i­cally in­serted be­fore the deriva­tive glyph (use­ful when us­ing an up­right font).
  • the scope of the math al­pha­bets has been ex­tended to ap­ply to the non-al­pha­bet­i­cal char­ac­ters, and also to op­er­a­tor names.
  • the for­mat of the dtx file has changed. The pack­age file is self-ex­tract­ing from the dtx, and four ad­di­tional test files are also pro­duced dur­ing latex mathastext.dtx.

1.15f and 1.15g [2012/10/25]

  • \$, \#, \&, and \% had been re-de­fined by math­as­text since its in­cep­tion in a rather strange (but work­ing) way, which could cause sur­prises to other pack­ages. Fixed.
  • the sub­dued mech­a­nism for the math al­pha­bets is im­ple­mented in a sim­pler and more ef­fi­cient man­ner than in 1.15e.
  • the defaultxx op­tions act a bit dif­fer­ently, and are more use­ful in case of a too many math alphabets sit­u­a­tion.
  • var­i­ous im­prove­ments in the doc­u­men­ta­tion.
  • gen­eral clean up and bet­ter com­ment­ing of the source code.

1.15e [2012/10/22]

  • new user com­mands to spec­ify skip or glue to be in­serted af­ter the math sym­bols \exists and \forall
  • com­plete (user trans­par­ent) rewrite of the code im­ple­ment­ing the sub­dued op­tion; and its ac­tion has been ex­tended to ap­ply also to the \mathbf, \mathit, \mathsf, \mathtt al­pha­bets and not only to \mathrm and \mathnormal as in the pre­vi­ous ver­sions.
  • im­prove­ments in the doc­u­men­ta­tion.

1.15d [2012/10/13]

  • the Uni­code sit­u­a­tion is now cor­rectly treated, through­out the code (this had been left in a half-done way from ver­sion 1.14 of April 2011).
  • this in­cludes an is­sue re­lated to ams­math and its De­clareMathOper­a­tor macro which has been fixed,
  • and the code re­lated to \relbar and \Relbar (and \models) has been re­vised.

1.15c [2012/10/05]

  • it is now pos­si­ble to use dis­tinct fonts in LGR en­cod­ing for the Greek let­ters ac­cord­ing to the cur­rent math ver­sion.
  • im­prove­ments to the doc­u­men­ta­tion.


  • cor­rected a 'fea­ture' of 1.15 which was back­ward-in­com­pat­i­ble
  • im­prove­ments to the pdf doc­u­men­ta­tion

1.15 [2012/09/26]

  • the sub­dued op­tion al­lows the math­as­tex­ti­fi­ca­tion to act only lo­cally.
  • some mea­sures taken to deal with ams­math re­lated is­sues when us­ing xe­tex or lu­a­tex.


  • a bug is fixed: the \Mathastext macro reini­tial­izes the fonts in the nor­mal and bold math ver­sions, but it also er­ro­neously re­de­clared the math al­pha­bet chang­ing com­mands which could have been set up in pre­vi­ously de­fined math ver­sions (via ear­lier calls to \Mathastext[ver­sionname]).

1.14b [2011/04/03]

  • there was a bug with \$, \#, \&, \% in math mode which showed up when ten or more math fam­i­lies had been de­clared. This bug af­fected also the mi­nus sign un­der the same cir­cum­stances, when Uni­code en­gines were used. Fixed.
  • the op­tions LGR­greek and self­Greek act now a bit dif­fer­ently, and new op­tions LGR­greeks and self­Greeks have been de­fined.
  • I also cleaned up a bit the code, for a more struc­tured names­pace.


  • math­as­text now mod­i­fies also the math al­pha­bets \mathit, \mathsf and \mathtt, thus mak­ing it a quite generic com­plete man­ner to adapt the math con­fig­u­ra­tion to fonts pro­vided with no math sup­port.


  • when the Sym­bol font is used for \prod and \sum this will be only for in­line math; dis­play math will use the de­fault glyphs

1.13 [2011/03/11]

  • the LGR­greek op­tion is added.
  • in­ter­nal changes for bet­ter read­abil­ity of the code.


  • var­i­ous bugs have been cor­rected.
  • the en­dash and allde­lims op­tions are ac­tive by de­fault.
  • the pack­age is more Uni­code aware.
  • the \Mathastext com­mand has been im­proved to fa­cil­i­tate the mech­a­nism of math ver­sions also when us­ing or Lua (with pack­age fontspec.)
  • the en-dash and dot­less i and j now work with all en­cod­ings, Uni­code in­clu­sive.

1.11 [2011/02/06]

  • op­tional ar­gu­ment to \Mathastext macro.

1.1 [2011/02/01]

  • op­tions italic and french­math.

1.0 [2011/01/25]

  • Ini­tial ver­sion.

Down­load the con­tents of this pack­age in one zip archive (583.2k).

math­as­text – Use the text font in maths mode

The pack­age uses a text font (usu­ally the doc­u­ment’s text font) for the let­ters of the Latin al­pha­bet needed when type­set­ting math­e­mat­ics. (Op­tion­ally, other char­ac­ters in the font may also be used). This fa­cil­ity makes pos­si­ble (for a doc­u­ment with sim­ple math­e­mat­ics) a far wider choice of text font, with lit­tle worry that no spe­cially de­signed ac­com­pa­ny­ing maths fonts are avail­able. The pack­age also of­fers a sim­ple mech­a­nism for us­ing many dif­fer­ent choices of (text hence, now, maths) font in the same doc­u­ment. Of course, us­ing one font for two pur­poses helps pro­duce smaller PDF files.

The pack­age, if run­ning un­der Lua, re­quires the live 2013 dis­tri­bu­tion (or later).

Home pagehttp://jf.burnol.free.fr/math­as­text.html
Ver­sion1.3t 2018-08-22
Li­censesThe Project Public Li­cense 1.3
Copy­right2011–2018 Jean-François Burnol
Main­tainerJean-François Burnol
TDS archivemathastext.tds.zip
Con­tained inTeX Live as math­as­text
MiKTeX as math­as­text
Maths Font
Font sel
Guest Book Sitemap Contact Contact Author