Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to obtain a justified paragraph with greek text using XeLaTeX and fontspec package, but there is always a word that exceed the right alignment.

Note that with LaTex and the default greek font the given output is correct, with hyphenation, while with XeLaTeX and fontspec (and any greek font) there isn't hyphenation.

\documentclass[12pt]{article}
\usepackage[a4paper,top=2cm,bottom=1cm,left=3cm,right=3cm]{geometry}

\usepackage{fontspec}

\setmainfont{Palatino Linotype}

\usepackage[doublespacing]{setspace}

\setlength\parindent{0pt}


\begin{document}


Ἐν Μεγάροις ἰδὼν τὰ μὲν πρόβατα τοῖς δέρμασιν ἐσκεπασμένα, τοὺς δὲ παῖδας αὐτῶν γυμνούς, ἔφη, “λυσιτελέστερόν ἐστι Μεγαρέως εἶναι κριὸν ἢ υἱόν.” πρὸς τὸν ἐντινάξαντα αὐτῷ δοκόν, εἶτα εἰπόντα, “φύλαξαι,” “πάλιν γάρ με,” ἔφη, “παίειν μέλλεις;” ἔλεγε τοὺς μὲν δημαγωγοὺς ὄχλου διακόνους, τοὺς δὲ στεφάνους δόξης ἐξανθήματα. λύχνον μεθ' ἡμέραν ἅψας, “ἄνθρωπον,” φησί, “ζητῶ.” εἱστήκει ποτὲ κατακρουνιζόμενος· τῶν δὲ περιεστώτων ἐλεούντων, παρὼν Πλάτων ἔφη, “εἰ βούλεσθ' αὐτὸν ἐλεῆσαι, ἀπόστητε,” ἐνδεικνύμενος φιλοδοξίαν αὐτοῦ. ἐντρίψαντος αὐτῷ κόνδυλόν τινος, “Ἡράκλεις,” ἔφη, “οἷον με χρῆμ' ἐλάνθανε  τὸ μετὰ περικεφαλαίας περιπατεῖν.” 

\end{document}

enter image description here

UDPATE:

Although the solution proposed by egreg works good with standard margin, changing the margin dimension will result in a text with overfull lines. So i used the parameter

\tolerance=10000

following the instructions found here : http://www.tex.ac.uk/cgi-bin/texfaq2html?label=overfull. It seems to work properly:

\documentclass[12pt]{article}
\usepackage[a4paper,top=2cm,bottom=1cm,left=6cm,right=6cm]{geometry}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainfont[Ligatures=TeX]{Palatino Linotype}
\setmainlanguage[variant=polytonic]{greek}

\setlength\parindent{0pt}
\tolerance=10000

\begin{document}

Ἐν Μεγάροις ἰδὼν τὰ μὲν πρόβατα τοῖς  δέρμασιν ἐσκεπασμένα, τοὺς δὲ παῖδας αὐτῶν 
υμνούς,  ἔφη, “λυσιτελέστερόν ἐστι Μεγαρέως  εἶναι  κρι-ὸν ἢ υἱόν.” πρὸς τὸν ἐντινάξαντα 
αὐτῷ δοκόν, εἶτα εἰπόντα, “φύλαξαι,” “πάλιν γάρ με,” ἔφη,  “παίειν μέλλεις;” ἔλεγε τοὺς 
μὲν δημαγωγοὺς ὄχλου διακόνους, τοὺς δὲ στεφάνους δόξης ἐξανθήματα. λύχνον μεθ' ἡμέραν 
ἅψας,  “ἄνθρωπον,”   φησί, “ζητῶ.” εἱστήκει ποτὲ κατακρουνιζόμενος· τῶν δὲ περιεστώτων  
ἐλεούντων, παρὼν Πλάτων ἔφη, “εἰ βούλεσθ' αὐτὸν ἐλεῆσαι, ἀπόστητε,” ἐνδεικνύμενος 
φιλοδοξίαν αὐτοῦ. ἐντρίψαντος αὐτῷ κόνδυλόν τινος, “Ἡράκλεις,” ἔφη, “οἷον με χρῆμ' 
ἐλάνθανε τὸ μετὰ περικεφαλαίας περιπατεῖν.” 

\end{document}

enter image description here

share|improve this question
3  
Surely you need to load the greek hyphenation patterns? \usepackage{polyglossia}\setmainlanguage{greek} should fix this, I think. –  Alan Munn Nov 30 '13 at 19:49
    
Probably \setmainlanguage[variant=polytonic]{greek}, since the text seems to be polytonic Greek. –  egreg Nov 30 '13 at 20:34
    
It doesn't work. Since there isn't hyphenation in the output, i think that a macro like this could work: ctan.org/tex-archive/macros/xetex/hyphenation/greek. But i'm pretty new to LaTeX and i don't know how to make it work. –  Alessio Nov 30 '13 at 20:38
    
\tolerance=10000 is surely the worst method for avoiding overfull lines. –  egreg Dec 1 '13 at 11:41
    
why? i really want to know the correct method to avoid overfull lines –  Alessio Dec 1 '13 at 15:20

2 Answers 2

I don't have the “Palatino Linotype” font, so I use a substitute, which requires the definition of \greekfont (one gets a suitable warning, in case this is necessary).

\documentclass[12pt]{article}
\usepackage[a4paper,top=2cm,bottom=1cm,left=3cm,right=3cm]{geometry}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainfont[Ligatures=TeX]{Palatino}
\setmainlanguage[variant=polytonic]{greek}
\newfontfamily{\greekfont}[Ligatures=TeX]{Palatino}

\begin{document}


Ἐν Μεγάροις ἰδὼν τὰ μὲν πρόβατα τοῖς δέρμασιν ἐσκεπασμένα, τοὺς δὲ
παῖδας αὐτῶν γυμνούς, ἔφη, “λυσιτελέστερόν ἐστι Μεγαρέως εἶναι κριὸν ἢ
υἱόν.” πρὸς τὸν ἐντινάξαντα αὐτῷ δοκόν, εἶτα εἰπόντα, “φύλαξαι,” “πάλιν
γάρ με,” ἔφη, “παίειν μέλλεις;” ἔλεγε τοὺς μὲν δημαγωγοὺς ὄχλου διακόνους,
τοὺς δὲ στεφάνους δόξης ἐξανθήματα. λύχνον μεθ' ἡμέραν ἅψας, “ἄνθρωπον,”
φησί, “ζητῶ.” εἱστήκει ποτὲ κατακρουνιζόμενος· τῶν δὲ περιεστώτων
ἐλεούντων, παρὼν Πλάτων ἔφη, “εἰ βούλεσθ' αὐτὸν ἐλεῆσαι, ἀπόστητε,” 
ἐνδεικνύμενος φιλοδοξίαν αὐτοῦ. ἐντρίψαντος αὐτῷ κόνδυλόν τινος,
“Ἡράκλεις,” ἔφη, “οἷον με χρῆμ' ἐλάνθανε τὸ μετὰ περικεφαλαίας
περιπατεῖν.”

\end{document}

enter image description here

As you see there's no overfull line with words sticking into the margin and hyphenation is properly done.

Install a full TeX distribution, either TeX Live 2013 or MiKTeX 2.9 if on Windows, but I recommend TeX Live anyway.

For GNU/Linux systems, see the TUG page and several questions on this site.

share|improve this answer

If you load either (i) the polyglossia package and setting polytonic greek to be the main language or (ii) the babel package with the "polutonikogreek" option, XeTeX will find a hyphenation point for the word παῖδας and thereby avoid creating an overfull line on the very first line of your MWE. (Aside: Until about a year ago, polyglossia was the preferred language-related package for XeLaTeX while babel was better for LuaLaTeX. Fortunately, in recent months both language packages have undergone considerable improvements and now seem to work smoothly with both TeX engines.)

The example below loads babel and -- just because I happen to have the font on my system... -- the font "Palatino Linotype". Compiling it with either XeLaTeX or LuaLaTeX (assuming you have an up-to-date TeX distribution) will produce this output:

enter image description here

\documentclass[12pt,a4paper]{article}
\usepackage[top=2cm,bottom=1cm,hmargin=3cm]{geometry}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX]{Palatino Linotype}
\usepackage[polutonikogreek]{babel}
%\usepackage[doublespacing]{setspace}
\setlength\parindent{0pt}
\begin{document}
Ἐν Μεγάροις ἰδὼν τὰ μὲν πρόβατα τοῖς δέρμασιν ἐσκεπασμένα, τοὺς δὲ παῖδας αὐτῶν 
γυμνούς, ἔφη, “λυσιτελέστερόν ἐστι Μεγαρέως εἶναι κριὸν ἢ υἱόν.” πρὸς τὸν ἐντινάξαντα 
αὐτῷ δοκόν, εἶτα εἰπόντα, “φύλαξαι,” “πάλιν γάρ με,” ἔφη, “παίειν μέλλεις;” ἔλεγε τοὺς 
μὲν δημαγωγοὺς ὄχλου διακόνους, τοὺς δὲ στεφάνους δόξης ἐξανθήματα. λύχνον μεθ' ἡμέραν 
ἅψας, “ἄνθρωπον,” φησί, “ζητῶ.” εἱστήκει ποτὲ κατακρουνιζόμενος· τῶν δὲ περιεστώτων  
ἐλεούντων, παρὼν Πλάτων ἔφη, “εἰ βούλεσθ' αὐτὸν ἐλεῆσαι, ἀπόστητε,” ἐνδεικνύμενος 
φιλοδοξίαν αὐτοῦ. ἐντρίψαντος αὐτῷ κόνδυλόν τινος, “Ἡράκλεις,” ἔφη, “οἷον με χρῆμ' 
ἐλάνθανε τὸ μετὰ περικεφαλαίας περιπατεῖν.” 
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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