3

I'm using the mathastext package to make math contents consist with the text. The package offers a \MTgreekfont command to change the font of greek letters. Current I use the lmtt font but its size does not match that of Courier, thus I would like to switch to the one native to Courier. However I cannot find the internal name of Courier (like lmtt for Latin Modern), \MTgreekfont{courier} does not work. How can I find this internal name? Or, is there a way to change the scale of current greek letters?

Moreover, what if I use Menlo font with xelatex? The font itself apparently offers greek letters, How could I use them with mathastext?

Below is a MWE.

%! TEX program = xelatex
\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage{courierten}% Courier
% \usepackage[no-math]{fontspec}% These two lines require xelatex
% \setmonofont[Mapping=tex-text]{Menlo}% Menlo
\renewcommand{\familydefault}{\ttdefault}
\usepackage[italic,LGRgreek]{mathastext}
\MTgreekfont{lmtt} % What should I put here respectively, for Courier and Menlo?
\Mathastext
\begin{document}
\noindent Text\\
$\alpha\beta\gamma\epsilon$
\end{document}
4
  • looking at the fd files seems to be CourierOneZeroPitch-TLF Jan 30, 2021 at 14:32
  • ... but that font has no Greek LaTeX Font Warning: Font shape 'LGR/CourierOneZeroPitch-TLF/m/it' undefined Jan 30, 2021 at 14:34
  • @DavidCarlisle I chose courierten for pdflatex, but in practice I use \setmonofont[Mapping=tex-text]{Courier} with xelatex, which I think contains Greek letters.
    – Jinwen
    Jan 30, 2021 at 14:38
  • sure but a Unicode Opentype font used by xelatex can have tens of thousands of characters, but a font used by pdflatex can have at most 256 so something has to go, the font maintainer can choose different subsets to make into pdftex compatible fonts the T1 encoding you have specified (and is supported by courier10) has 256 accented latin script characters and no Greek. It would be possible to subset the original font again to make a subset matching the Greek LGR pdftex encoding but that hasn't been done so far. Jan 30, 2021 at 14:43

4 Answers 4

3

Your options are:

  • Load an OpenType math font with unicode-math, in LuaLaTeX or XeLaTeX. All of them come with Greek alphabets. You can change its Greek alphabet with \setmathfont[Scale=MatchLowercase, range=it/{Greek,greek}]{Some Greek Italic Font}, etc.
  • Load \setmathsfont(Greek} in mathspec in XeTeX.
  • Load a legacy 8-bit font in the LGR encoding, using mathastext. You generally want to look for a file named lgr*.fd. if you don’t care about keeping the fixed width, you might pair the Greek Font Society’s GFS Neohellenic.
  • Load \usepackage{gfsneohellenicot} in PDFTeX to get GFS Neohellenic Math, then use \usepackage{mathastext} to change the Latin letters to Courier/Cursor.
  • Load a legacy OML math font, containing both Greek and Latin letters, with isomath or \DeclareMathAlphabet.
4

Solution, using pdflatex and mathastext. On my Linux system with texlive, I found the LGR font files with the command find texlive -name "*LGR*fd" (texlive is in my home directory), and then one can find the font names.

\documentclass{article}

\usepackage{courierten} % CourierOneZeroPitch-TLF
\usepackage[italic,LGRgreek]{mathastext}

\newcommand{\mtset}[1]{\MTfamily{#1}\MTgreekfont{#1}\Mathastext[#1]}
\mtset{Cochineal-TLF}
\mtset{CourierOneZeroPitch-TLF}
\mtset{DejaVuSans-TLF}
\mtset{EBGaramond-TLF}
\mtset{TheanoDidot-TLF}
\mtset{TheanoOldStyle-TLF}
\mtset{lmtt}

% Switches font
\newcommand{\mtv}{\MTversion}
% Creates row in tabular
\newcommand{\mtrow}[1]{\mtv{#1} #1:
  &\quad\mtv{#1}$\alpha$&\mtv{#1}$\beta$&\mtv{#1}$\gamma$&\mtv{#1}$\delta$
  &\mtv{#1}$\epsilon$&\mtv{#1}$\zeta$&\mtv{#1}$\eta$&\mtv{#1}$\theta$
  &\mtv{#1}$\iota$&\mtv{#1}$\kappa$&\mtv{#1}$\lambda$&\mtv{#1}$\mu$
  &\mtv{#1}$\nu$&\mtv{#1}$\xi$&\mtv{#1}$\pi$&\mtv{#1}$\rho$
  &\mtv{#1}$\sigma$&\mtv{#1}$\tau$&\mtv{#1}$\upsilon$&\mtv{#1}$\phi$
  &\mtv{#1}$\chi$&\mtv{#1}$\psi$&\mtv{#1}$\omega$\\[2mm]
}

\begin{document}


\mtv{CourierOneZeroPitch-TLF} CourierOneZeroPitch-TLF is default
tt-font in the question's setup but it has no greek alphabet\medskip
  
\setlength{\tabcolsep}{0mm}
\begin{tabular}[t]{rccccccccccccccccccccccc}
  \hline\\
  \mtrow{Cochineal-TLF}
  \mtrow{CourierOneZeroPitch-TLF}
  \mtrow{DejaVuSans-TLF}
  \mtrow{EBGaramond-TLF}
  \mtrow{TheanoDidot-TLF}
  \mtrow{TheanoOldStyle-TLF}
  \mtrow{lmtt}
  \hline
\end{tabular}
\medskip

\mtv{CourierOneZeroPitch-TLF} A little courier with its math
$\displaystyle\frac{\alpha\beta}{2}\int_0^1 f(x)dx$

\mtv{CourierOneZeroPitch-TLF} A little courier \MTversion*{lmtt} with
lmtt's math $\displaystyle\frac{\alpha\beta}{2}\int_0^1 f(x)dx$

\mtv{lmtt} A little lmtt with its math
$\displaystyle\frac{\alpha\beta}{2}\int_0^1 f(x)dx $
\end{document}

small sample

Many interesting and beautiful greek fonts that I could find in texlive on my system.

many greek fonts

2
  • 1
    there are also some with lowercase lgr such as tempora-TLF and others
    – user691586
    Feb 27 at 22:33
  • @user691586 you were right, so I added some more, including some funky ones like fmm and solomos. Feb 28 at 12:07
3

If you're using XeLaTeX, you can declare the Greek letters to use the main font (assuming it contains them).

documentclass[11pt,a4paper]{article}
\usepackage[no-math]{fontspec}% These two lines require xelatex
\usepackage[italic]{mathastext}

\setmonofont{Menlo}
\renewcommand{\familydefault}{\ttdefault}

\Mathastext

\Umathchardef\alpha="0 \symmtletterfont `α
\Umathchardef\beta="0 \symmtletterfont `β
\Umathchardef\gamma="0 \symmtletterfont `γ
\Umathchardef\epsilon="0 \symmtletterfont `ε

\begin{document}

Text $x\alpha\beta\gamma\epsilon$

\end{document}

Fill in the rest.

enter image description here

1

To address the original problem, perhaps rescaling courier will do the job: use courier for math but, since it doesn't have its own greek, use lmtt's greek. In my opinion, lmtt's math looks better than couriers because of its use of italics instead of just slanted, so use courier with lmtt math.

\documentclass{article}

\usepackage[scale=0.95]{courierten} % CourierOneZeroPitch-TLF
\usepackage[italic,LGRgreek]{mathastext}
\MTfamily{CourierOneZeroPitch-TLF}
\Mathastext[courier]
\MTfamily{CourierOneZeroPitch-TLF}
\MTgreekfont{lmtt}
\Mathastext[courierlmtt]
\MTfamily{lmtt}
\MTgreekfont{lmtt}
\Mathastext[lmtt]

% Switches font
\newcommand{\mtv}{\MTversion}

\begin{document}
\mtv{courier} Here is a \emph{\textbf{little courier}} with its math
but doesn't have its own greek so I think it gets cmr's
$\displaystyle\frac{\alpha\beta\gamma\delta}{2}\int_0^1
f(x)dx$.\bigskip

\mtv{courierlmtt} Here is a \textbf{\emph{little courier}} with lmtt's
greek $\displaystyle\frac{\alpha\beta\gamma\delta}{2}\int_0^1
f(x)dx$. \bigskip

\mtv{lmtt} Here is a \emph{\textbf{little pure lmtt}} with it own math
$\displaystyle\frac{\alpha\beta\gamma\delta}{2}\int_0^1 f(x)dx$.\bigskip 

\mtv{courier}\mtv*{lmtt} Here is a \textbf{\emph{little courier}} with
lmtt math
$\displaystyle\frac{\alpha\beta\gamma\delta}{2}\int_0^1 f(x)dx$.
\end{document}

lmtt courier mix

You must log in to answer this question.

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