1

I have a problem with typesetting LaTeX using both Greek and English characters. All this time, I've been using the polyglossia+fontspec packages which allowed me to change between Greek and English just by changing language on my keyboard.

This combination allows me to choose the fonts that I will use, but when letters in math mode mix with letters outside of math mode, the result is not so aesthetic. A solution to this is to substitute all math mode letter with \textrm, but I hope to find something less tiresome.

I actually want to change the font that I am using to, say, Kerkis. What I found online is that I have to add the following two packages

\usepackage{kmath,kerkis}
\usepackage[T1]{fontenc}

Adding these two packages (while removing fontspec) makes the file to not even compile.

So, my question is: how can I change the typesetting font in and out of math mode (let's say to Kerkis) while keeping the ability to change language without having to use a TeX command?

Edit: I used the mathspec package instead of fontspec, downloaded Kerkis fonts and manually added them using these:

\usepackage[MnSymbol]{mathspec}
\setmainfont{KerkisSans}
\setmathsfont(Digits,Latin)[Scale=MatchLowercase]{Kerkis}
\setmathsfont(Greek)[Scale=MatchLowercase]{Kerkis}
\usepackage{polyglossia}

Still, it feels like a half-measure since I'm feeling like I should just load a "Kerkis" package or something that would do the job for me, shouldn't I?

cgnieder
  • 66,645
  • When the alfabet is Latin, glyphs in math mode should also look different as those in text mode. – Przemysław Scherwentke Jan 08 '18 at 13:53
  • Please give a real, compilable example of font combinations you find unsatisfactory. – Mico Jan 08 '18 at 14:13
  • @mico any font i try in greek language except from the latex defaults does not seem fine. – royal with cheese Jan 08 '18 at 14:22
  • Does my answer in this question helps? :(https://tex.stackexchange.com/q/396528/120578 ) It is about XeLaTeX for these languages and you can chose font for math and for text at any time... – koleygr Jan 08 '18 at 14:25
  • Nice approach but I do not know if it answers my question exactly. I still only use greek letters outside of math mode. For math mode I restrict myself to latin characters. – royal with cheese Jan 08 '18 at 15:34
  • You may didn't checked my answer with your code... I just suggesting using latin letters in math mode for greek... But it is not necessary. See my answer – koleygr Jan 08 '18 at 17:00
  • I suggest an edit to the title close to yours but more accurate to help future users: "switch between English/Greek without command (text and math mode-XeLaTeX) " – koleygr Jan 09 '18 at 16:28

2 Answers2

1

Here is the solution I suggested in the comment above:

\documentclass[11pt,oneside]{article}    
\usepackage{amsmath}
\usepackage{mathspec}%[MnSymbol]{mathspec} %<-No need for this in this example
%\usepackage{MnSymbol}
\defaultfontfeatures{Ligatures=TeX}
\setallmainfonts{Linux Libertine O}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}
\setmainfont{Linux Libertine O}
%\newfontfamily\greekfont{Linux Libertine O}

% Definitions of Greek (in math mode)
\def\alpha{α}
\def\beta{β}
\let\oldgamma\gamma %<-see the difference below
\def\gamma{γ}
\def\delta{δ}
\def\epsilon{ε}
\def\zeta{ζ}
\def\eta{η}
\def\theta{θ}
\def\iota{ι}
\def\kappa{κ}
\def\lambda{λ}
\def\mu{μ}
\def\nu{ν}
\def\xi{ξ}
%\def\ο{o}
\def\pi{π}
\def\rho{ρ}
\def\sigma{σ}
\def\tau{τ}
\def\upsilon{υ}
\def\phi{φ}
\def\varphi{ϕ}
\def\chi{χ}
\def\psi{ψ}
\def\omega{ω}
\def\varsigma{ς}
\def\varrho{ϱ}
\def\vartheta{ϑ}

\def\Alpha{Α}
\def\Beta{Β}
\def\Gamma{Γ}
\def\Delta{Δ}
\def\Epsilon{Ε}
\def\Zeta{Ζ}
\def\Eta{Η}
\def\Theta{Θ}
\def\Iota{Ι}
\def\Kappa{Κ}
\def\Lambda{Λ}
\def\Mu{Μ}
\def\Nu{Ν}
\def\Xi{Ξ}
%\def\Ο{O}
\def\Pi{Π}
\def\Rho{Ρ}
\def\Sigma{Σ}
\def\Tau{Τ}
\def\Upsilon{Υ}
\def\Phi{Φ}
\def\Chi{Χ}
\def\Psi{Ψ}
\def\Omega{Ω}

\begin{document}
\selectlanguage{english}

English text


$$α=\frac{β}{γ_s \text{ or }\oldgamma_s} \text{ or }\alpha=\frac{\beta}{\gamma_\sigma} \text{ and } 6_p$$


\selectlanguage{greek}

Ελληνικό κείμενο εδώ

$$α=\frac{β}{γ_s \text{ or }\oldgamma_s} \text{ or }\alpha=\frac{\beta}{\gamma_\sigma} \text{ and } 6_p$$

\setmainfont{FreeSans}
\selectlanguage{english}

English text


$$α=\frac{β}{γ_s \text{ or }\oldgamma_s} \text{ or }\alpha=\frac{\beta}{\gamma_\sigma} \text{ and } 6_p$$

\selectlanguage{greek}

Ελληνικό κείμενο εδώ

$$α=\frac{β}{γ_s \text{ or }\oldgamma_s} \text{ or }\alpha=\frac{\beta}{\gamma_\sigma} \text{ and } 6_p$$

\end{document}

Output:

enter image description here

PS: The package MnSymbol didn't used here and see the correction on the \oldgamma spacing.

koleygr
  • 20,105
1

Reading the question as 'How to use the same Greek font for maths and text', here is a unicode-math package way, with its granularity of approach: use the range= option to read in glyphs for one or more of the desired lowercase and uppercase Greek alphabets in the Mathematical Alphanumeric Symbols unicode block (bold, italic, bold-italic, sans bold, sans bold-italic).

It does give a more consistent look:

greek text and maths

Direct input is also accepted (e.g., the red capital mu).

This example also sets Greek letter math-style to ISO style, rather than French or English. The maths font is XITS Math having its italic Greek and bold-italic Greek math alphabets replaced by the glyphs from the non-math Noto Serif italic and bold-italic faces, with Noto Serif itself being used for the Greek text font as well.

MWE

\documentclass[12pt,varwidth,border=6pt]{standalone}
%\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{polyglossia}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont{XITS Math}
%\setmathfont{Noto Serif}[range={up/{greek,Greek},it/{greek,Greek},bfit/{greek,Greek}},Colour=blue]%fontface; regular
\setmathfont{Noto Serif Italic}[range=it/{greek,Greek},Colour=blue]
\setmathfont{Noto Serif Bold Italic}[range=bfit/{greek,Greek},Colour=red]
\setmainfont{Noto Serif}
\setdefaultlanguage{english}
\setotherlanguage{greek}
\newfontfamily\greekfont[Script=Greek]{Noto Serif}

\begin{document}
\begin{greek}
Το \textbf{ηλιακό σύστημα} περιλαμβάνει τον Ήλιο και όλα τα αντικείμενα τα οποία κινούνται σε τροχιά γύρω από αυτόν μέσα στο πεδίο βαρύτητάς του, είτε περιστρεφόμενα άμεσα γύρω από αυτόν είτε κινούμενα σε τροχιές γύρω από άλλα σώματα που κινούνται γύρω από τον Ήλιο. Βρίσκεται στο τοπικό διαστρικό Νέφος, το οποίο ανήκει στην Τοπική Φυσαλίδα, η οποία με τη σειρά της ανήκει στον βραχίονα του Ωρίωνα στο Γαλαξία, σε απόσταση 27.000 ετών φωτός από το κέντρο του. -- \textit{Βικιπαίδεια}
\end{greek}

\[ \alpha^2 + \beta^2 = \gamma^2 \]

\[\Alpha_1 \Beta_1 = 4\Gamma_2 \]

\[ _{\iota} = (_{\alpha}, _{\beta}, _{\gamma})\cdot 4\sin^{2}()\]

\[α=\frac{β}{γ_s \text{ or }\gamma_s} \text{ or }\alpha=\frac{\beta}{\gamma_\sigma} \text{ and } 6_p\]
\ 
\end{document}

Unrelated: polyglossia, mathspec and unicode-math all use fontspec in the background.

Cicada
  • 10,129