# 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.

### Sustaining package ragged2e

A package that deals with text alignment is the ragged2e package. It contains improvements to the previous switches and environments, as well as a switch to switch back to justification. The improvements refer to the possibility of word separation within the text.

 switch default LATEX ragged2e left justified \raggedright \RaggedRight right-justified \raggedleft \RaggedLeft centered \centering \centering justification - \justifying

 environments default LATEX ragged2e left justified \begin{flushleft} ... \end{flushleft} \begin{FlushLeft} ... \end{Flushleft} right justified \begin{flushright} ... \end{flushright} \begin{FlushRight} ... \end{FlushRight} centered \begin{center} ... \end{center} \begin{Center} ... \end{Center} justification - \begin{justify} ... \end{justify}

This website uses cookies and pixel tags to ensure you get the best experience on our website. By using this website, you consent to the use of cookies.learn more about cookies see also our privacy policy