[Tex/LaTex] Italic greek letters become latin letters in math mode

greekmath-mode

I'm using the mathastext package in order not to have italic everywhere in maths formulas, in particular for function names or vectors and matrices letters.

But this leads to strange behavior with greek letters as the following MWE shows:

\documentclass{report}
\usepackage{amsmath}
\usepackage[LGRgreek,defaultmathsizes]{mathastext}
\begin{document}

\begin{equation}
\mathit{y} = \mathit{X\beta} + \mathit{\epsilon}
\end{equation}

\begin{equation}
\mathit{y} = \mathit{X}{\beta} + \epsilon
\end{equation}

\end{document}

Which gives:
ital greek letters are latin

How could I locally (i.e. within any particular equation) force some letter to be italic, especially greek letters?

Best Answer

The OP indicates in a comment that "99% of them are upright? I do not wish to mark them all individually." Thus, while there are many reasons not to do it this way, I use the inverse of the solution at Upright Greek font fitting to Computer Modern, and introduced the macro \slant, which (in pdflatex) can be applied to any particular argument.

\documentclass{report}
\usepackage{amsmath}
\usepackage[LGRgreek,defaultmathsizes]{mathastext}
\newsavebox{\foobox}
\newcommand{\slantbox}[2][0]{\mbox{%
        \sbox{\foobox}{#2}%
        \hskip\wd\foobox
        \pdfsave
        \pdfsetmatrix{1 0 #1 1}%
        \llap{\usebox{\foobox}}%
        \pdfrestore
}}
\newcommand\slant[2][.25]{\slantbox[#1]{$#2$}}
\begin{document}

\begin{equation}
\mathit{y} = \mathit{X\beta} + \slant\epsilon
\end{equation}

\begin{equation}
\mathit{y} = \mathit{X}{\beta} + \epsilon
\end{equation}

\centering
$\alpha\beta\gamma\delta\epsilon\eta\mu\phi\sigma\tau\omega\xi\psi\zeta$\par
\slant\alpha\slant\beta\slant\gamma\slant\delta\slant\epsilon%
\slant\eta\slant\mu\slant\phi\slant\sigma\slant\tau\slant\omega%
\slant\xi\slant\psi\slant\zeta

\end{document}

enter image description here