3

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.

  • Welcome to TeX.SX! How do you input the English terms? – egreg Aug 27 '15 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 Aug 27 '15 at 11:41
  • for a single phrase I suggest \foreignlanguage{english}{text in English} – egreg Aug 27 '15 at 12:36
  • That gives a solution to the problem, indeed. Thank you. – a OS Aug 27 '15 at 14:21
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.