Comprehensive TeX Archive Network

Direc­tory tex-archive/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-2016 Jean-Fran­cois Burnol (jfbu at free dot fr)

  Source: mathastext.dtx 1.3l 2016/01/29
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 (XTeX/LuaTeX). 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 LaTeX 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.


From mathastext.tds.zip

This is the fastest way: unzip -d <destfolder> mathastext.tds.zip, where <destfolder> could be ~/texmf or (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 TeX 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/xe­la­tex to com­pile the doc­u­men­ta­tion.)


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 LaTeX re­lease, re­moval of the "luatex" pre­fix from the names of the LuaLaTeX math prim­i­tives. Com­pat­i­bil­ity main­tained with older LaTeX 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 LuaTeX and XTeX.
  • \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 only in math mode how an ac­tive char­ac­ter acts, with­out break­ing things. The pack­age now does that /only/ if the ac­ti­va­tion ap­pears to orig­i­nate 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>. 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 to the 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.
  • The tech­nique of math­e­mat­i­cal ac­ti­va­tion is main­tained only for the char­ac­ters which are not cat­code ac­tive (at the en­trance in math mode, as math­as­text does all its ac­ti­va­tion job at \everymath and \everydisplay).
  • 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 XTeX or LuaTeX (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.


Name Size Date Notes
README.md 18631 2016-01-29 09:19
math­as­text.dtx 336141 2016-01-29 09:19
math­as­text.ins 2323 2016-01-29 09:19
math­as­text.pdf 427591 2016-01-29 09:19
math­as­texttestal­pha­bets.pdf 41900 2016-01-29 09:19

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

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, run­ning un­der LuaTeX, re­quires the TeX live 2013 dis­tri­bu­tion (or later).

Pack­age De­tailsmath­as­text
Home pagehttp://jf.burnol.free.fr/math­as­text.html
Ver­sion1.3l 2016-01-29
Li­censeThe LaTeX Project Public Li­cense 1.3
Main­tainerJean-François Burnol
TDS archivemathastext.tds.zip
Con­tained inTeX Live as math­as­text
MiKTeX as math­as­text
Topics fonts for use in math­e­mat­ics
fonts them­selves
font se­lec­tion schemes
Guest Book Sitemap Contact Contact Author