1

I am using LaTeX to produce texts containing both English and Greek characters, with the aid of the babel package. My approach up to now, in declaring the use of another language, is to use a shortened self-defined command (e.g. \gr{}). Though effective, this has become quite cumbersome, and I would be interested to be able to switch between the two languages without having to declare this every time. Is there a relatively short solution to this problem?

2
  • 1
    Hi, please always show an MWE to start with. If you need some functions of babel for your text, you will always have to tell LaTeX which language you are using at the moment. You could just change languages with out any support from babel, of course. The only solution would be to have an automatic language recognizing system... Which is neither easy nor short. So the answer would be "no".
    – LaRiFaRi
    Commented Sep 16, 2014 at 9:17
  • 3
    while a unicode font (with xetex or luatex) will allow Greek and English text to be typeset with no commands, you will still need a command to switch languages so that you get correct hyphenation Commented Sep 16, 2014 at 9:56

4 Answers 4

1

Using XeTeX and unicode, you can type foreign scripts directly into your LaTeX document. See Why can't my build produce certain Greek symbols?

In that example, I use the \textgreek command, however, that's only necessary to allow automatic font switching.

If you go this path, you will need to switch to polyglossia, rather than babel.

4
  • 2
    That only solves glyphs/characters, but typographical rules, including hyphenation, cannot be switched automatically in general (not only TeX, so "in general" means exactly that). By the way, for a Greek, the foreign language is English :-). Commented Sep 17, 2014 at 16:31
  • The solution provided does allow full typographic support through polyglossia.
    – Nigel
    Commented Sep 17, 2014 at 22:03
  • Many thanks! fontspec and ucharclasses are really designed to do exactly what I was looking for. @Javier: Hahaha, true! Commented Sep 18, 2014 at 9:59
  • Since the Greek and Latin alphabets don't intersect, you can load the Greek and English hyphenation patterns together in XeTeX's formats; that way you get at least the correct hyphenation for both languages at once—spaces and other stuff may be a little trickier.
    – jarnosz
    Commented Nov 20, 2015 at 20:59
2

Try the following:

\documentclass[]{article}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage[greek,english]{babel}
\usepackage{alphabeta}


\begin{document}

This is a text in English. Αυτό είναι ένα κείμενο στα Eλληνικά
    
\end{document}

The result will be:

This is a text in English. Αυτό είναι ένα κείμενο στα Ελληνικά

1
  • Hi, Eleni, could you explain a little what your code does? I will help the one who asked. Commented Dec 14, 2020 at 17:40
0

There is auto-greek, a package which allows this exactly. I have tested some years ago, but I haven't used it; it was difficult in collaboration to use a package that cannot be installed automatically. You can review and download it here

0

Update 2024. As pointed out in a comment (here), with xelatex you can use ucharclasses (both babel and polyglossia). With lualatex you can also switch the font in the following way (I chose a contrasting font):

\documentclass{article}

\usepackage[english]{babel}
\babelprovide[onchar=ids fonts]{greek}
\babelfont[greek]{rm}{FreeSans}

\begin{document}

Some text in English Ελληνικά. And more.

\end{document}

enter image description here

You must log in to answer this question.

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