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 want to align my text. I use these packages (Linux):

texlive texlive-xetex texlive-lang-greek

I use kile as editor. I can write English and Greek with no problem. But when it comes to alignment I have the following problem:

I use \begin{flushleft} (as I say in a previous question) and it aligns to the left, but to the right it has no alignment. Some words excel and it is ugly. After some reading, I realized that the alignment supposed to work automatically (am I right?). But to me it doesn't.

The setup is:

\documentclass[a4paper,12pt,oneside]{book} 

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}

\setmainfont{Times New Roman}

\usepackage[a4paper,left=2cm,top=2.5cm,right=2cm,bottom=2.5cm]{geometry}

\begin{document}
 \chapter {Κεφάλαιο 1}

 \textbf {\LARGE Εισαγωγή}

 \setcounter{page}{1}

 \section {Ιστορία των επεξεργαστών γραφικών}

 \noindent      Μια μονάδα επεξεργασίας γραφικών ....
 \noindent    Στο διάστημα 1999-2000 ,...

here is an example

share|improve this question
2  
Welcome to TeX.sx! It would be good if you add a full, but minimal working example (MWE) that illustrates your problem, not just your preamble. Also, your LaTeX editor is normally not important, but the used LaTeX version (e.g. TeX Live 2010, 2011 etc.) or package versions might be. Here it is not really important becayse flushleft is a basic LaTeX macro so it didn't changed in 10 years. –  Martin Scharrer May 15 '12 at 10:06
1  
A general note: You seem to use either Debian or Ubuntu. The TeXLive packages which they provide are hopelessly outdated (TL'09 I think). We heavily recommend to install TeX Live manually as described in How to install “vanilla” TeXLive on Debian or Ubuntu?. Note that TeX Live 2011 just got frozen and TeX Live 2012 will be released in the next weeks, so you might want to actually wait a little if you don't want to install it twice. –  Martin Scharrer May 15 '12 at 10:08
    
@Martin Scharrer:Thanks for the notes! –  George May 16 '12 at 13:12
    
I'd recommend using the ragged2e package because the LaTeX default for ragged margin is very ugly. Also, your MWE is not complete and using \noindent twice within the same paragraph makes no sense. You don't even use \begin{flushleft} there BTW. –  Christian May 16 '12 at 15:08
add comment

2 Answers 2

up vote 5 down vote accepted

You're not telling LaTeX that your main language is Greek, so it's not able to properly hyphenate words. Load the Polyglossia package and announce what languages you're using.

\documentclass[a4paper,12pt,oneside]{book} 

\usepackage{fontspec}

\setmainfont{Times New Roman}
\usepackage{polyglossia}
\setmainlanguage{greek}
\setotherlanguage{english}

\usepackage[a4paper,left=2cm,top=2.5cm,right=2cm,bottom=2.5cm]{geometry}

\begin{document}
\chapter{Εισαγωγή}

\section {Ιστορία των επεξεργαστών γραφικών}

Μια μονάδα επεξεργασίας γραφικών ....

Στο διάστημα 1999-2000 ,...

\foreignlanguage{english}{Some words in English}

\end{document}

You can also, for short English phrases, define a personal command:

\newcommand{\EN}[1]{\foreignlanguage{english}{#1}}

so that the phrase before can be input as \EN{Some words in English}.

If you don't want an indent at the beginning of paragraphs, then add

\setlength{\parindent}{0pt}

before \begin{document}, but I strongly discourage you to do so. The indent is meant to help in reading your document.

share|improve this answer
    
About the indentation: in my opinion, documents (especially ones with lots of math in it) tend to look messy when using a nonzero parindent, so my documents by default \setlength{\parindent}{0pt} at the beginning. To keep the document readable I add \setlength{\parskip}{8pt} as well. –  Yori May 16 '12 at 12:16
1  
@Yori That's exactly the opposite of what I think. ;-) A document is less readable with a nonzero parskip. Why a document with lots of math should become messy with a nonzero parindent is very unclear to me. –  egreg May 16 '12 at 12:20
    
Different tastes I guess :), but I do add a nonzero \parskip to make up for it. (on a different note: why does "at egreg" get deleted from my comment all the time?) –  Yori May 16 '12 at 13:04
    
@egreg:Thanks a lot!Worked fine!I also didn't need to use \foreignlanguage{english} in order to insert english in the document.It can recognize it. –  George May 16 '12 at 13:11
    
@Yori: At the time of posting your comments, only egreg and you were in conversation, making the use of "@ egreg" superfluous. –  Werner May 16 '12 at 13:59
show 2 more comments

with respect to your previous question i think you misunderstand the meaning of flushleft. The default of LaTeX without any alignment-command is fully align.

For example:

begin{flushleft}
A BB CCC DD
F GGG HHH
III
{end}

gives output like:

A BB CCC DD
F GGG HHH
III

whereas

\noindent A BB CCC DD
F GGG HHH
III

gives output like:

A BB CCC DD
F  GGG  HHH
III

and

begin{flushright}
A BB CCC DD
F GGG HHH
III
{end}

gives output like:

A BB CCC DD
  F GGG HHH
        III

does this answer your question?

share|improve this answer
    
:The problem is exactly as you describe it.But i tried to use \noindent and no flushleft and it still insists.. –  George May 15 '12 at 14:58
    
maybe because i am using 'xelatex' as command?and not latex? –  George May 15 '12 at 15:11
    
@George: The default behaviour of LaTeX is to justify text horizontally. Using flushleft (similar to \raggedright) and flushright (similar to \raggedleft) is not the default. Regardless, alignment does not depend on the compiler and should therefore provide similar output if compiles in xelatex, latex or pdflatex. Please edit your original question showing a small (minimal) example that illustrates the problem you're experiencing. Additionally include an image of the output. That may help community members highlight the issue at hand. –  Werner May 15 '12 at 15:29
    
@Werner:I updated my question.Thanks –  George May 16 '12 at 9:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.