# Unnecessary first line shift in XeTeX

Using XeTeX I noticed how first line is shifted with \usepackage{indentfirst} in a document which I don't want to happen. In LaTeX everything works Ok. Examples:

XeTeX:

\documentclass[a4paper,oneside,14pt]{book}
\usepackage{xltxtra}
\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{extsizes}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\pagestyle{plain}
\setdefaultlanguage{ukrainian}
\setmainfont{Times New Roman}


LaTeX:

\documentclass[a4paper,oneside,14pt]{book}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[ukrainian]{babel}
\usepackage{extsizes}
\usepackage{indentfirst}
\usepackage{fancyhdr}
\pagestyle{plain}


The question is how to fix this indentation? Should I use some manual indentation instead of indentfirst? Will it be then a "wheel"?

-
It should hold even if you don't use indentfirst. This all stems from using different fonts, I guess. And different fonts have different dimensions set up for spacing. –  Werner May 24 '12 at 23:38
You're right! I checked your idea with english and other fonts and XeTeX handled it the right way. –  MagnusGraviti May 24 '12 at 23:55

This is not an indentation problem: you should have received a message Overfull \hbox during the typesetting and you can test it by enabling the draft option in \documentclass, which will pring a black blob next to the overfull lines.

In this case, rewriting is usually the easiest remedy. Also changing the pagination parameters can help. Anyway, such problems should be addressed only when the document is in "almost final" form.

By the way, the setup Polyglossia does for Ukrainian is

\PolyglossiaSetup{ukrainian}{
script=Cyrillic,
scripttag=cyrl,
langtag=UKR,
hyphennames={ukrainian},
hyphenmins={2,2},
frenchspacing=true,
fontsetup=true
}


which doesn't include indentfirst. Instead of loading the indentfirst package you can also say

\setmainlanguage{ukrainian}
\PolyglossiaSetup{ukrainian}{indentfirst=true}


that wouldn't change the setup for other languages. Changing this locally or globally (with the package) is a choice that depends on many factors, so take your pick.

Note that \setdefaultlanguage is a deprecated name for \setmainlanguage.

A tip
An interesting way for setting \emergencystretch locally to a paragraph (not in list environments, where things can not go as intended) so that TeX has more chances to correct bad breaks, you can say

Text of a paragraph that doesn't set well
and here's where it ends.{\emergencystretch=1.5em\par}

Here starts the following paragraph.

-
you're right. I have Overfull... message but using \PolyglossiaSetup{ukrainian}{indentfirst=true} I can't solve my problem - it is still overfilled. Anyway thanks for advices! Now I know that I should use \setmainlanguage –  MagnusGraviti May 25 '12 at 9:28
@MagnusGraviti The overfull has nothing to do with indentfirst: (Xe)TeX is unable to properly set that paragraph respecting its high quality standards. It would be the same if that paragraph didn't come immediately after a section title. Such unfortunate combinations happen and are best treated by looking at the offending paragraph and trying to modify it or to act on the paragraphing parameters. Look for \emergencystretch on this site. –  egreg May 25 '12 at 9:35
You were right! \emergencystretch=1.5em did the trick! Huge thanks for advice! Can you make a new answer with it so I'll accept it as an answer? –  MagnusGraviti May 25 '12 at 9:53

I think the right idea was given by Werner. I tested the same text with other fonts and got right indentation.

Changing geometry I got right result but I think my solution isn't so elegant but it works (with Times New Roman and cyrillic text).

-