5

I am fairly new to LaTeX so please excuse any obvious parts of the question.

I am looking for a way to setup hyphenation in 2 languages (Greek and English) at the same time. My setup is MacTeX +Texmaker+ XeLaTeX + polyglossia. The main language is Greek and I periodically use some terms in English that escape the fully justified text body. Concerning the language, my preamble looks like:

\usepackage{xltxtra}
\defaultfontfeatures{Mapping=tex-text}

\setmainfont[]{Cambria} 
\setsansfont[]{Candara} 
\setmonofont[]{Consolas} 

\usepackage{polyglossia} 
\setotherlanguage{english}
\setmainlanguage{greek}

I would also appreciate any comments for my preamble on commands I could omit or change.

Thank you in advance.

4
  • Welcome to TeX.SX! How do you input the English terms?
    – egreg
    Commented Aug 27, 2015 at 10:46
  • If i get your q right, i don't use a special command. I just change my keybord language. Do you suggest to use a command for those terms, indicating language change, like \textlatin{ }?
    – a OS
    Commented Aug 27, 2015 at 11:41
  • for a single phrase I suggest \foreignlanguage{english}{text in English}
    – egreg
    Commented Aug 27, 2015 at 12:36
  • That gives a solution to the problem, indeed. Thank you.
    – a OS
    Commented Aug 27, 2015 at 14:21

1 Answer 1

4

The simplest way to get correct English hyphenation in your setup is to use \foreignlanguage:

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}

\setmainfont{Cambria}
\setsansfont{Candara}
\setmonofont{Consolas}

\setmainlanguage{greek}
\setotherlanguage{english}

\begin{document}

Αυτό το κείμενο είναι στα ελληνικά
\foreignlanguage{english}{and not in English}

\end{document}

You may want to define a shorthand in the preamble, such as

\newcommand{\EN}[1]{\foreignlanguage{english}{#1}}

so the input can be

Αυτό το κείμενο είναι στα ελληνικά
\EN{and not in English}

Note that loading xltxtra is not recommended any more. The most recent versions of fontspec take care of what used to be delegated to xltxtra, including the default font features.

You must log in to answer this question.

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