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 have the following problem with XeLatex, Russian language, hyphenation and verbatim.

Consider the following tex file (text below). It is compiled with XeLaTex, and before verbatim hyphenation is OK, but after verbatim environment hyphenation is broken. I have tested it with english --- it works well. I am on Mac Os X with MacTex.

\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{polyglossia}
\usepackage{xltxtra}
\setdefaultlanguage{russian}
\newfontfamily\cyrillicfont{Cambria}
\newfontfamily\cyrillicfontsf{Calibri}
\newfontfamily\cyrillicfonttt{Cambria}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Cambria}
\setsansfont[Scale=MatchLowercase,Mapping=tex-text]{Calibri}

\title{Test}
\date{\today}
\begin{document}

\maketitle
%Everything is fine here
Цель данного текста — дать читателю краткое представление о языке
Python и его применении в реальных научных вычислениях. Не предполагается 
какого-то предварительного знакомства с синтаксисом языка. Текст пока 
является наброском личного опыта автора (пока не очень большого), 
однако будет пополняться.


\begin{verbatim}
Some stupid text
\end{verbatim}
%No hyphenation here!
Цель данного текста — дать читателю краткое представление о языке
Python и его применении в реальных научных вычислениях. Не предполагается 
какого-то предварительного знакомства с синтаксисом языка. Текст пока 
является наброском личного опыта автора (пока не очень большого), 
однако будет пополняться.

\end{document}
share|improve this question

closed as too localized by lockstep, Joseph Wright Sep 1 '12 at 21:45

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1  
Welcome to TeX.SX! There's nothing "broken": the paragraph after the verbatim can't be typeset optimally, just because "Python" happens to fall in an unfortunate position. The best thing to do in such cases is trying to reword the paragraph. –  egreg Jun 19 '12 at 16:35
    
@egreg Thank you! I don't think so --- it is a part of a longer text, and after verbatim there is no hyphenation at all (I can provide resulting pdf, if you wish). If I remove verbatim, everything is just fine. –  Ivan Oseledets Jun 19 '12 at 16:52
    
I actually used a different font, for I don't own Cambria. But I assure you that hyphenation works as it should (with Linux Libertine I get a hyphen in the last but one line). You only got an unfortunate paragraph. –  egreg Jun 19 '12 at 16:55
    
@egreg That is interesting. I have tested it on my Linux box with Linux Libertine --- everything is OK. So the source is either in my Tex installation, or in Cambria font. –  Ivan Oseledets Jun 20 '12 at 6:52