0

When I use ucharclasses with XeLaTeX to automatically change the font for Greek text, I find that it sometimes inserts transitions at the wrong point, within the Greek text. (Note: I am using the GreekExtended option of ucharclasses because my Greek text uses accents and breathing marks of various sorts as is conventional in typesetting ancient Greek.)

In particular, it looks like it works fine if the first character of Greek has an accent or breathing mark on it but not (or not always) otherwise. (This question appears to be related to this one, but I'm not sure how to apply the partial answers given there to my issue.)

Is there some way to fix this?

MWE 1: it works

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}
\usepackage{fontspec}
\newfontfamily\defaultfont[Mapping=tex-text]{Times}
\newfontfamily\greekfont{Gentium}
\usepackage[Latin, GreekExtended]{ucharclasses}
\setDefaultTransitions{\defaultfont}{}
\setTransitionsForGreek{\greekfont}{}

\begin{document}
Latin text.

ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
\end{document}

The output is correct, with the Latin in Times and the Greek in Gentium, the fonts I chose to use for each.

enter image description here

MWE 2: does not work when first Greek character is not accented

%!TEX TS-program = xelatex
%!TEX encoding = UTF-8 Unicode

\documentclass[12pt]{article}
\usepackage{fontspec}
\newfontfamily\defaultfont[Mapping=tex-text]{Times}
\newfontfamily\greekfont{Gentium}
\usepackage[Latin, GreekExtended]{ucharclasses}
\setDefaultTransitions{\defaultfont}{}
\setTransitionsForGreek{\greekfont}{}

\begin{document}
Latin text.

μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
\end{document}

This time, with the first word deleted, the fonts are now incorrect: in particular, the first word, μοι, appears in the Times font (which I had set as the default font), even though the rest of the Greek text appears in the Gentium font (which I had set as the Greek font).

enter image description here

2
  • I have just noticed that this particular issue seems to be resolved if I change GreekExtended to Greek. Is that the answer to my question? Do I misunderstand the purpose of GreekExtended? Feb 2, 2021 at 12:51
  • Note that, in LuaLaTeX, you could use the command \babelprovide[import=el-polyton, onchar=ids fonts]{greek} together with \babelfont[greek] to change the fonts automatically.
    – Davislor
    Feb 2, 2021 at 14:13

1 Answer 1

2

GreekExtended covers this range of unicode:

 \do{GreekExtended}{"01F00}{"01FFF}

Greek is a class which combine four ranges:

\def\GreekClasses{
  \do{Coptic}
  \do{CopticEpactNumbers}
  \do{GreekAndCoptic}
  \do{GreekExtended}
}

These cover

\do{GreekExtended}{"01F00}{"01FFF}
\do{GreekAndCoptic}{"0370}{"03FF}
\do{Coptic}{"02C80}{"02CFF}
\do{CopticEpactNumbers}{"0102E0}{"0102FF}

and include the GreekExtended.

So Greek is the more general setup.

1
  • Ah, so I had it backwards! Thank you, that makes sense. Feb 2, 2021 at 13:13

You must log in to answer this question.

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