# LaTeX text alignment

StartLaTeX Topics

## LaTeX text alignment

Justification is the default text alignment for LaTeX. In addition to justification, there are three other variants: left-justified, right-justified, and centered text alignment. The latter three have their own environments in which they can be used or switches with which they can be activated.
In general, the corresponding environments should be used. The switches should only be used where the use of the environments is not possible or not useful, for example within other environments.

### Environments

If the environments are used, a new paragraph is started each time.
\begin{flushleft}
One line with text \\
A second line with text\\
...
\end{flushleft}


One line with text
A second line with text
...
\begin{flushright}
One line with text\\
A second line with text \\
...
\end{flushright}


One line with text
A second line with text
...
\begin{center}
One line with text \\
New line with text \\
...
\end{center}


One line with text
New line with text
...

### Switch

The three switches are called raggedright for left flush, raggedleft for right flush and centering for centered. If these switches are used outside an environment, they work until another switch of this group comes and if it doesn't, until the end of the document. Therefore, you should always pay attention to the curly brackets, as in the following example.

{\raggedright
One line with text \\
A second line with text\\
...
}


One line with text
A second line with text
...
{\raggedleft
One line with text \\
A second line with text\\
...
}


One line with text
A second line with text
...
{\centering
One line with text \\
A second line with text\\
...
}


One line with text
A second line with text
...

#### Note

There is no additional environment and no corresponding switch for the justification itself. This means that if you have changed to left-justified by a switch and have not correctly bracketed this, you can only change to right-justified or centered - but not back to justification!

### vertical text alignment / text compensation

In addition to the horizontal text alignment, there is also the possibility to influence the vertical alignment of the text, although this is rarely necessary. In case for example the command \pagebreak was used instead of \newpage or \clearpage respectively. In such a case the command \flushbottom can be used to stretch the text over the whole page. The command is already active for the document class book, so that it only affects the three other standard classes article, report and letter. The opposite command is called \raggedbottom and is the default for article, report and letter.