from Tex FAQ – hyphenation I see that trying to help Latex in correctly hyphenating words won't work when the utf8 encoding is used. Is there a work around?
[Tex/LaTex] hyphenation and utf8
hyphenationunicode
Related Solutions
You shouldn't be using XeLaTeX in that way, since it expects Unicode input. In any case, correct hyphenation does not depend on the input encoding, but rather on the output encoding.
I'll assume your file is UTF-8 encoded, or a bunch of problems would arise. Here's a working version, at least with TeX Live 2013 (the 2009 version shipped with Ubuntu till 12.04 is really outdated). Note that for Russian only T2A
should be loaded, but only if pdflatex
is used. So I load the ifxetex
package to distinguish between the two engines.
You might also put babel
in the “non XeLaTeX” code and call polyglossia
for XeLaTeX.
\documentclass[a4paper,twoside,titlepage,openright,10pt]{book}
\usepackage{ifxetex}
\ifxetex
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{CMU Serif}
\setsansfont{CMU Sans Serif}
\else
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\fi
\usepackage[english,russian]{babel}
\title{УНИКАЛЬНАЯ ЖЕНЩИНА \\ Проницательность и мудрость для достижения полноты жизни}
\author{Эдвин Луис Коул и Нэнси Корбетт Коул}
\begin{document}
\maketitle
\begin{otherlanguage*}{english}
``We will implement prudent and responsible macroeconomic policies to ensure mutually reinforcing effect of growth and to maintain economic and financial stability in the region, and prevent negative spillover effect.''
\end{otherlanguage*}
Многие женщины начинают поиск истинного <<Я>> и оказываются обманутыми и разочарованными, пытаясь стать похожими на образец современной женщины. Приспосабливаясь внешне, но сопротивляясь внутренне, они однажды обнаруживают, что глубоко в душе они не являются тем, чем случайно оказались.
Некоторые женщины научились искать и получать розы, обеды и драгоценности и все же не ощущают стабильности, безопасности, удовлетворения от проявления своей индивидуальности и настоящей любви, чего они в действительности желают.
Множество женщин вверили свою жизнь мужчинам, желая жить жизнью своих мужей или любовников, но это ведет лишь к тому, что они разочаровываются в мужчинах, а в итоге и в самих себе.
Многие, очень многие жены отчаянно хотят, чтобы их мужья изменялись, становились зрелыми, брали ответственность на себя и были такими мужчинами, какими они сотворены быть. Они осознают слишком поздно, что подлинно свободна только та замужняя женщина, муж которой <<достиг максимума>>.
\begin{otherlanguage*}{english}
``Global growth is too weak, risks remain tilted to the downside, global trade is weakening and the economic outlook suggests growth is likely to be slower and less balanced than desired," the group said in a prepared statement.''
\end{otherlanguage*}
\end{document}
I can compile this either with pdflatex
or xelatex
and below I show the results. You can see they are pretty much alike. Note that in order to get English hyphenation you should enclose the text in an otherlanguage*
environment.
pdflatex
xelatex
At first the word \LaTeX
right before usando
is confusing the hyphenation. But most importantly: \righthyphenmin is 3 in this language, that means that LaTeX will never break 2 chars at the end. You can change this:
\documentclass[10pt,openright,twoside,a5paper]{memoir}
\usepackage[brazil]{babel}
\usepackage[showframe]{geometry}
\setlength{\parindent}{1.6cm}
\renewcommand\brazilhyphenmins{22} %left=2, right=2
\begin{document}
\frenchspacing
\selectlanguage{brazil}
No entanto, você pode compilar os documentos \LaTeX{} usando os seguintes
comandos, que devem ser digitados no \emph{Prompt de Comandos} do Windows ou no
\emph{Terminal} do Mac ou do Linux:
\end{document}
Best Answer
since it may be useful to someone, for specific languages with accents for instance, the \hyphenation command will correctly work only with a T1-encoding
\usepackage[T1]{fontenc}
but won't without.