A LaTeX package: mathastext
Copyright © 2011-2019, 2022-2024 Jean-François Burnol.
Current version is 1.4e (2024/10/26)
README,
README.html,
INSTALL.txt,
ChangeLog.md,
pdf,
sty,
dtx,
mathastext.tds.zip,
mathastexttestalphabets.tex,
mathastexttestalphabets.pdf,
showcase page,
CTAN page.
This Work may be distributed and/or modified under the conditions of the The LaTeX Project Public License 1.3c.
The package originates in some (even worse) macros I had been using many years ago to produce handouts as if done on a typewriter, or better said, to produce documents with a somewhat rough, but unified look, done by a real human and meaning to convey some message to real humans. The hope was to coerce the reader into making a real effort at assimilating the entirety of the material, text and math, not knowing in advance which piece would prove to be more important than the others.
\usepackage[T1]{fontenc} \usepackage[german]{babel} \usepackage[variablett]{lmodern} \renewcommand\familydefault\ttdefault \usepackage[LGRgreek]{mathastext} \MTgreekfont{lmtt}\Mathastext
In a well-crafted mathematical document, every single part is as important as any other one, or, rather, it is up to the reader to uncover the web of links between atoms.
The example above uses a typewriter font which well illustrates the purpose. But mathastext will work with all kinds of fonts and can produce less militant math: see the examples (be patient, this page with its embedded png images weighs circa 5 Mo!) A notable feature of mathastext is to give a simple interface to using many distinct math fonts in the same document: special example.
Optimal typographical results for documents containing mathematical symbols can only be hoped for with math fonts specifically designed to match a given text typeface. Although the list of freely available math fonts for (PDF)LaTeX is slowly expanding (Computer Modern, AMS fonts, PX fonts, TX fonts, Fourier-GUTenberg, Math Design, Kepler Project, newtx, mathabx, others ... ; and ([2012/10/27]) on the Unicode side (XeTeX/LuaTeX): Asana-Math, XITS, Latin Modern Math, TeX Gyre Pagella Math, TeX Gyre Termes Math) it remains limited. Chances are you will not find a math font which fits well with your favorite text font.
Try out mathastext: it will simply use the text font also for the math! (additionally to Latin letters, digits, punctuation signs, a few math symbols available in the ascii set, such as +,–,<,>,=, will also be picked up from the text font.) Often this gives quite satisfying results especially if, like the author, you aim at a very unified look for the document, and in particular prefer upright to slanted shapes for math (mathastext does have an option to maintain the usual slanted shape).
Examples (page last updated around 2018, examples last updated around 2012; be patient, the page with its embedded png images weighs circa 5 Mo! (wow...) It contains about 70 examples, as png images and/or as pdf files.)
lgrmath (use
LGR
-encoded fonts in math mode)
libgreek (Greek letters in math mode from Libertinus or Linux Libertine/Biolinum)
The original version of this package (2011/03/14) used the support files of the libertine LaTeX font package (which made Linux Libertine usable via pdfLaTeX). It got broken at the time of a 2018 release of libertine when the libertine-legacy got moved to the obsolete section of CTAN, and thus stopped being distributed by TeXLive (and presumably MikTeX).
The current version, 1.1 of 2022/11/11, uses the LGR-encoded font
files from the libertinus-type1
package by Bob Tennent which gives an interface for pdfLaTeX users to
the Libertinus
OpenType fonts. For perfect backwards compatibility, if executed on a
LaTeX system where libertine-legacy is
still installed, libgreek
will use it. Else (or if mandated by the libertinus
option)
it uses the font definition files from libertinus-type1.
In this context, note that libertinust1math by
Michael Sharpe provides complete math support to pdfLaTeX to use the
OpenType math part of Libertinus. But then
the simplest is for the document text to also use Libertinus via libertinus-type1 and
you presumably don't need mathastext
!
The sans-serif member of the document font family gives often good results when used in math-mode, in parallel with the text in serif.
\renewcommand{\familydefault}{\sfdefault}
\usepackage{mathastext}
\renewcommand{\familydefault}{\rmdefault}
It is then even less recommended to use the italic option (matter of taste!).
How get in math mode the upright Greek letters from Computer Modern? Include in your preamble:
\usepackage{my_nice_font}
\renewcommand{\familydefault}{cmr} % or cmss or cmtt for sans resp. mono
\usepackage[LGRgreek, further options]{mathastext}
\renewcommand{\familydefault}{\rmdefault}
\Mathastext
\begin{document}
The Greek letters will be from the LGR encoded CM font (and will be
in upright shape, except if italic was among the mathastext options).
italic
and frenchmath
; minus as endash.
\Mathastext
admits optional math version name.
LGRgreek
.
LGRgreeks
and selfGreeks
.
subdued
allowing the mathastext-ification to act locally.
subdued
; automatic spaces after \forall
and \exists
.
\#
, \&
, \$
, \%
;
code cleaned up and better documented.
\MTsetmathskips
.\MTversion
leaves untouched the text font.
\MTstandardgreek
and \MTcustomgreek
.
ldelims
badly redefined \lbrace
and \rbrace
).
amsmath
\resetMathstrut@
.
self extracting README.md with Markdown syntax.
LaTeX
2015/10/01 regarding LuaLaTeX
.
symbolgreek
/selfGreek
/selfGreeks
.
\url's
use of math mode.
fontspec
.
amsmath
.
LuaLaTeX+luaotfload
font issues in math mode.
unicodeminus
.
fontspec
relative to subdued option.
no more redefinitions of \i
and \j
, only \imath
and \jmath
.
LaTeX
2019-10-01
LaTeX+amsmath
bug regarding accents
ncccomma,
binarysemicolon
and frenchmath*.\...up
and \...it
variants for Greek letters\mathgreekup
/\mathgreekit
alphabets.selfGreek
option.
LGRgreek+
, documentation improvements.
frenchmath*
update, decimalcomma
, modified build logs, documentation.
\everymath
anymore.activedigits
.everymath
to revert to legacy behavior.babel-spanish
dot in math mode.LuaLaTeX
font related workaround.html5
(2024/07/21).nodigits
option.noletters
.everymath
warns about its removal at next major release.XeLaTeX
which caused a crash
during package loading if document had loaded
unicode-math
and used \setmathfont
.
f''
(except under option everymath
).
unimathaccents
option (which is not recommended anyhow).
\MTversion{normal}
cause breakage if with option LGRgreek
or LGRgreeks
(but not if subdued
).