6

Is there a way to make the polyglossia package solve the hyphenation problem that presents itself in the log as "Overfull \hbox" automatically?

(Note: I find that having shorter lines—even for the entirety of the text—is much less worse than having protruding lines.)

I'm trying to get:

... end of line
end of line
... end of line
... end of line

...but what I have (and don't want) is:

... end of line
... overfullboxishere
... end of line
... end of line

Here's an example of an "overfull box" error:

Example of "overfull box" error #1

Another question: that could be related: polyglossia does not make hyphenation for other specified languages.

Example of "overfull box" error of other language with polyglossia:

Example of "overfull box" error #2

When I use the \textenglish command, the problem seems to solve itself:

\textenglish command is used

However, the resulting document is contaminated with \textenglish, and I don't want \textenglish in my document.

MWE

\documentclass[12pt]{article}

\usepackage{polyglossia}
\usepackage{lipsum}

\setdefaultlanguage{russian}
\setotherlanguages{english}
\setmainfont[Mapping=tex-text]{Times New Roman}

\begin{document}
\lipsum[1]

\begin{itemize}
  \item Возможность работать с такими популярными как
  %  \textenglish{
    MySQL, SQLite, PostgreSQL, Oracle, and Microsoft SQL Server.
  %}
\end{itemize}

\lipsum[1]
\end{document}
  • 1
    Sorry, but this is too vague. Can you give an example? – egreg Mar 29 '14 at 20:12
  • It would be great if you provided a full compilable example. – Manuel Mar 29 '14 at 20:38
  • If you want “automatic” hyphenation of English words you have two alternatives: either you use \textenglish (or an abbreviation), or you define a whole set of patterns for Russian and English together, rebuild the formats and teach Polyglossia to use these patterns for Russian. A simpler strategy might involve the ucharclasses package. – egreg Mar 29 '14 at 21:43
5

In my opinion, the best strategy is still marking the parts in English as such. However, if your English words are just a few, there are alternative approaches.

With ucharclasses

Define transitions to and from Latin characters.

\documentclass[12pt]{article}

\usepackage{polyglossia}
\usepackage{ucharclasses}
\usepackage{microtype} % better management of overfulls

\setdefaultlanguage{russian}
\setotherlanguages{english}
\setmainfont[Ligatures=TeX]{Times New Roman}

\setTransitionsForLatin{\begingroup\hyphenrules{english}}{\endgroup}

\begin{document}

\begin{itemize}
  \item Возможность работать с такими популярными как
    MySQL, SQLite, PostgreSQL, Oracle, and Microsoft SQL Server.

  \item Возможность работать с такими популярными как
  Возможность работать с такими популярными как
  Возможность работать с такими популярными как
\end{itemize}

\end{document}

With just Polyglossia

Define a set of hyphenation rules for the small number of words you need

\documentclass[12pt]{article}

\usepackage{polyglossia}
\usepackage{microtype} % better management of overfulls

\setdefaultlanguage{russian}
\setmainfont[Ligatures=TeX]{Times New Roman}

\begin{hyphenrules}{russian}
\hyphenation{post-gresql or-a-cle mi-cro-soft}
\end{hyphenrules}

\begin{document}

\begin{itemize}
  \item Возможность работать с такими популярными как
    MySQL, SQLite, PostgreSQL, Oracle, and Microsoft SQL Server.

  \item Возможность работать с такими популярными как
  Возможность работать с такими популярными как
  Возможность работать с такими популярными как
\end{itemize}

\lipsum[1]
\end{document}

enter image description here

The output is the same with the two methods. This still produces a small overfull box, but just 0.8pt, but there's not much to do about this apart from rewording.

Note that the ucharclass method is quite heavy, so using it for longer passages in English can slow down processing the file.

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.