1

I am trying to use the mathastext package to replace alphabet letters in math with the default fonts in the document, and gfsdidot (udidot) for greek. I can either get everything relevant except greek working, or get greek working but break latin.

I use pdfLaTeX, and I think I have enough math alphabets, so that shouldn't be the issue. I also know that GFS Didot comes in all desired weights and shapes. How does an alphabet in mathastext know that it is only meant for greek and why does it not contain \mathrm? What is its relation to \mathnormal (which currently is equally broken)?

\Mathrm may seem like a syntax error but it is defined internally in mathastext.sty, though I am not sure how (or if) to properly use it.

If it's any help to convey what I am looking to do: something akin to what unicode-range does in CSS, to use one font for one range of characters, and another font for another range. For pdfLaTeX this seems to get harder because fonts are not in unicode, but it should indeed be possible, because mathastext does so properly for the default math alphabet. How?

PDF output

\documentclass{article}
\usepackage[LGR,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ebgaramond}
\usepackage[LGRgreek,italic]{mathastext}

\DeclareSymbolFont{mycustom}{LGR}{udidot}{normal}{n}
\SetSymbolFont    {mycustom}{normal}{LGR}{udidot}{\rmdefault}{n}%
\DeclareSymbolFontAlphabet{\Mathrm}{mycustom}%%% disable this to break greek but fix latin

\MTgreekfont{udidot}
\MTitgreek
\MTitGreek
\Mathastext

\newcommand*{\GRALPH}{\alpha \beta \gamma \delta \epsilon
\zeta \eta \theta \iota \kappa \lambda \mu \nu \xi o \pi
\rho \sigma \tau \upsilon \phi \chi \psi \omega \varsigma}

\newcommand*{\gralph}{A B \Gamma \Delta E Z H \Theta I K
\Lambda M N \Xi O \Pi P \Sigma T \Upsilon \Phi X \Psi \Omega}

\begin{document}

\noindent
\( \GRALPH - \mathrm{\GRALPH} \)\\
\( \gralph - \mathrm{\gralph} \)\\
so far it looks good, but now also latin turns up as greek:\\
\( abcdefghijklmnopqrstuvwxyz - \mathrm{abcdefghijklmnopqrstuvwxyz} \)

\end{document}

1 Answer 1

2

I think you would like \mathrm to turn the Greek letters upright. The \Mathrm is a math alphabet defined by mathastext designed to use the text font (which is already used for the letters in math) in the default shape, which a priori is upright. (so this makes sense if the package received italic option). Then \mathrm is simply re-defined to be the macro with meaning \Mathrm (so option defaultmathalphabets is implemented by just not doing that definition).

In LaTeX NFSS, \mathrm means to use the text font in math. It doesn't mean to turn things upright. In particular it makes no sense, a priori, to expect it to turn Greek letters from italic to upright shape.

But you can define a math alphabet command \upgreek which will use a given font in LGR encoding having upright Greek letters. Indeed, mathastext makes sure the Greek letters obey math alphabet commands.

So, possibly, this achieves what you want:

\documentclass{article}
\usepackage[LGR,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{ebgaramond}
\usepackage[LGRgreek,italic]{mathastext}
\MTitgreek
\MTgreekfont{udidot}
\Mathastext

\DeclareSymbolFont{mycustom}{LGR}{udidot}{m}{n}
\DeclareSymbolFontAlphabet{\upgreek}{mycustom}

\newcommand*{\GRALPH}{\alpha \beta \gamma \delta \epsilon
\zeta \eta \theta \iota \kappa \lambda \mu \nu \xi o \pi
\rho \sigma \tau \upsilon \phi \chi \psi \omega \varsigma}

\newcommand*{\gralph}{A B \Gamma \Delta E Z H \Theta I K
\Lambda M N \Xi O \Pi P \Sigma T \Upsilon \Phi X \Psi \Omega}

\begin{document}

\noindent
\( \GRALPH - \upgreek{\GRALPH} \)\\
\( \gralph - \upgreek{\gralph} \)\\
so far it looks good.\\
\( abcdefghijklmnopqrstuvwxyz - \mathrm{abcdefghijklmnopqrstuvwxyz} \)

\meaning\mathrm
\end{document}

Unfortunately \mathrm{\upgreek{\alpha\beta ab}} will not work, because the \upgreek will override the exterior \mathrm. LaTeX math alphabets just don't nest.

If you need a macro \uprightlatinandgreek then it might be possible, but if you don't I can rest a bit ;-).

enter image description here

9
  • background: mathastext does not modify that in math mode textfont family "0" still refers to ComputerModern, as set-up by LaTeX. So it needs a custom \Mathrm to switch to the document text font, in contrast to Computer Modern (or whatever replaced it if some math font package was loaded). By default, it does \renewcommand\mathrm{\Mathrm}. But in "subdued" mode, the normal and bold math versions will recover the original meaning of \mathrm.
    – user4686
    Nov 15, 2017 at 22:37
  • You're right; I would like \mathrm to act similarly as \textrm, even though stacking doesn't work. (for that we have \boldsymbol) Could mathastext maybe be made to play nice with isomath? Or could the OT1(?) \mathrm family be extended with with the LGR characters?
    – gnucchi
    Nov 15, 2017 at 22:54
  • Traditional TeX works with font files having 256 slots. The math alphabets simply select a font. The command \alpha in math mode is declared to use a given slot in a given (math) font. mathastext, with option LGRgreek makes it slot number 97. It also tells TeX that \alpha is of "variable family type". So inside say \mathrm, \alpha will give the character at slot 97 in what ever font \mathrm command has been configured to use. In the case of mathastext, \mathrm gives \Mathrm, and \Mathrm is configured to use the text-font. Thus in 99% of cases slot 97 will give letter "a".
    – user4686
    Nov 16, 2017 at 7:28
  • This all means that "extending \mathrm with LGR characters" can not work with the LaTeX native mechanisms. However we can naturally define \alphaup etc... symbols, and let our macro \uprightletters do both of \mathrm and \let\alpha\alphaup etc... where \alphaup will have been defined as a symbol not reacting to math alphabets. This is possible approach. Is it really worthwile, in comparison to simply use directly \alphaup in mark-up? or for that matters \upgreek{\alpha} as in my answer? It is not clear to me what you mean by "play nice with isomath". Perhaps precisely this?
    – user4686
    Nov 16, 2017 at 7:34
  • So I take it then that the default math alphabet works differently? Because with mathastext it's clear that both latin and greek from separate fonts can be used with the same markup. Or do the \alpha \beta etc. commands automatically change math alphabet, even though seemingly using the default?
    – gnucchi
    Nov 16, 2017 at 8:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .