latex3 / babel

The multilingual framework to localize LaTeX, LuaLaTeX and XeLaTeX
https://latex3.github.io/babel/
LaTeX Project Public License v1.3c
130 stars 35 forks source link

greek transliteration with xe/luatex? #135

Closed kberry closed 3 years ago

kberry commented 3 years ago

With pdftex, and \usepackage[greek]{babel}, \textgreek{FD} comes out with the expected Psi and Delta.

When I run the same document with xelatex, \textgreek is not defined, and the Latin F and D are typeset (not surprisingly).

Is there a way to get Greek transliterations with lua/xetex? I have three words of Greek in a 300-page English manuscript, and I'd much rather have good old ASCII than UTF-8 Greek. I did not find anything in the manual, though I could easily have missed it.

I more or less have to use xe/luatex since the TrueType font in question is not set up for pdftex. I don't really want to go down that road either, sorry to say. Looking for the least-work alternative as always ... Thanks for any advice.

\documentclass[10pt]{article}
\usepackage[greek]{babel}
\babelfont{rm}{LucidaBrightRegular.ttf} % running with xelatex
\begin{document}
\textgreek{FAIDROS} %  undefined control sequence
\end{document}
u-fischer commented 3 years ago

^^^^03a6^^^^0391^^^^0399^^^^0394^^^^03a1^^^^039f^^^^03a3 ?

kberry commented 3 years ago

Indeed. Thanks Ulrike. I hadn't thought of that. I wish regular transliteration worked, but can imagine (I think) why it doesn't. At least this way I don't have to have "binary garbage" (aka UTF-8 :) in my beautiful 7-bit ASCII sources :). Thanks again.

kberry commented 3 years ago

P.S. I should have said "Phi" not "Psi". Sigh :).

u-fischer commented 3 years ago

I wish regular transliteration worked, but can imagine (I think) why it doesn't.

Well I'm quite sure that one can setup transliteration. I know e.g. that with lualatex there is a devanagari transliteration somewhere, and with xelatex you could use some teckit mapping, but I don't think that it is worth the time to search for it for three words ...

jbezos commented 3 years ago

@kberry Things like \textgreek, \textcyrillic and the like are discouraged, but you can define it for a certain language, either directly or with \babeltags. That's the easy part. As to the transliteration, it's feasible, but as explained by @u-fischer, it doesn't worth the time, at least a general solution. But devising a partial transliteration system in luatex is not that difficult if you need just a few letters:

\usepackage[greek, english]{babel}

\babeltags{greek = greek}

% \babelfont{rm}{LucidaBrightRegular.ttf} 
\babelfont{rm}{FreeSerif}

\babelprehyphenation{greek}{ ([ADFIORS]) }{
  string = {1|ADFIORS|ΑΔΦΙΟΡΣ}
}

Just complete the list: the 2nd argument is a lua pattern, and the part {1|...|...} defines a one-to-one map.

Edit The ^^^^ notation is supported, too.

kberry commented 3 years ago

Thanks Javier. I was hoping that the existing Greek transliteration for (pdf)latex babel, that's been in use for decades after all, could be used somehow. I guess not, which is understandable. I think the ^^ direction will work well enough for me. Thanks again. (Closing this.)

u-fischer commented 3 years ago

@kberry the "existing transliteration" is a fontencoding. You could use it with {\fontencoding{LGR}\selectfont FAIDROS} but it would change the font as your font hasn't been setup for it.