# Text Alignment problem [closed]

I am having a problem with the alignment in my pdf. The pdf is compiled with Xelatex. Some words instead of being separated with a "-" and continue at the bottom line are written whole in the upper line and thus they extend more than they should normally leading to a bad result to the reader's eye, as they don't respect the right margin of the page. Any possible ideas? I am not speaking of a mathematical formula, which can't be separated, I am speaking of a simple word that normally should have been separated with a "-" and continue at the next line. In my text, there are more than 1 languages if that helps. Any ideas appreciated, feel free to ask more if question is not specific enough.

-

## closed as too localized by Joseph Wright♦Oct 11 '12 at 16:20

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.

Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem (e.g., whether you use the babel package and/or the \hypenation command). –  lockstep Oct 10 '12 at 11:36
@lockstep It is a bit difficult, because for the first time this occurs after the page 14 of my pdf. How can I attach the pdf here? I am new here so I don't really know how. –  Paramar Oct 10 '12 at 11:41
Attached PDFs aren't useful to reconstruct your problem. Instead, in a copy (!) of your actual document, remove the first 14 pages. If the bad line break is still present, you now have a small example. Also, try to remove packages that aren't essential to the problem. –  lockstep Oct 10 '12 at 11:45
Please, show at least a paragraph where the problem appears, telling what's the involved word. It's also important to know what languages you're using; is the problematic word in a different language than the main one? –  egreg Oct 10 '12 at 11:53
You can try with \usepackage{polyglossia} and then \setdefaultlanguage{<lang1>}, \setotherlanguages{<lang2>,<lang3>,...}, and then switch to the appropriate languages using \text<lang>{...} or \begin{<lang>}...\end{<lang>} –  Guido Oct 10 '12 at 11:55

Too long for an comment:

Just to give you an idea how you can build a MWE have a look to this one (compile this with pdflatex):

%http://tex.stackexchange.com/questions/76131/text-alignment-problem
%compile this MWE with pdflatex
\documentclass[a5paper]{article}
\usepackage[utf8]{inputenc}       % utf-8 input encoding
\usepackage[T1]{fontenc}          % Fontencription
%\usepackage[ngerman]{babel}       % German ä and ü
%\usepackage{microtype}            % use always
\usepackage{showframe}            % to show frame

%\hyphenation{Donau-dampf-schiffs-kapitäns-mütze}
%\hyphenation{Do-nau-dampf-schiffs-ka-pi-täns-müt-ze}
\begin{document}
To create some hyphenation errors we use the German word
%To create some hyphenation errors we use the long German word
Donaudampfschiffskapitänsmütze Donaudampfschiffskapitänsmütze
Donaudampfschiffskapitänsmütze Donaudampfschiffskapitänsmütze
Donaudampfschiffskapitänsmütze Donaudampfschiffskapitänsmütze
Donaudampfschiffskapitänsmütze Donaudampfschiffskapitänsmütze
Donaudampfschiffskapitänsmütze Do\-nau\-dampf\-schiffs\-ka\-pi\-täns\-müt\-ze
Donaudampfschiffskapitänsmütze Donaudampfschiffskapitänsmütze
\end{document}


Play with the included % signs to change the behavior of the tex document. Change this MWE (I do not run XeLaTeX so I don't know) and copy your relevant macros into it to show us, what you are doing in your thesis.

-
Kurt you are very close in solving the question. So if I compile your example with pdflatex and after removing all % it is perfectly ok. Actually it is perfectly ok even if I replace the Do\-nau\-dampf\-schiffs\-ka\-pi\-täns\-müt\-ze with Donaudampfschiffskapitänsmütze. However while compiling with Xelatex the result is not the desirable even if I replace all Donaudampfschiffskapitänsmütze with Do\-nau\-dampf\-schiffs\-ka\-pi\-täns\-müt\-ze and erase every %. I would have posted an image but I am not allowed! –  Paramar Oct 10 '12 at 21:36
Well, the \- in the Word in the 3rdlast line marks were LaTeX can hyphenate, if necceccary. If not, no - is written. I only included this word to show it to you. I do not know what is necceccary for XeLaTeX to get good typesetted hyphenations. See the comment of @Guido ... –  Kurt Oct 10 '12 at 22:06
Ok thanks but one question. Pdflatex seems to understand even without hyphenation instructions where to divide words. On the other hand Xelatex doesn't hyphenate words correctly even when given those instructions. Isn't that strange behavior? I should find an equivalent of microtype for Xelatex I think –  Paramar Oct 10 '12 at 22:17
If everything fails, you can use \sloppy before the paragraph where you have words that goes in the margin and \fussy after the paragraph. Inter word spacing will be less than optimal for such paragraphs. –  Guido Oct 10 '12 at 22:21
Have a look on british-hyphenation-with-either-xelatex-or-lualatex. That should help you going on. –  Kurt Oct 10 '12 at 22:33