> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/overleaf-learn-latex-pt/formatacao/06-text-alignment.md).

# Alinhamento de texto

## Introdução

Por padrão, o LaTeX compõe o texto totalmente justificado, mas ocasionalmente texto alinhado à esquerda ou "à direita irregular" (para idiomas da direita para a esquerda) pode ser mais apropriado — como texto em colunas estreitas. Este artigo explica como alterar o alinhamento do texto em partes, ou em todo o seu documento, usando os recursos integrados do LaTeX e o pacote `ragged2e`.

## Os comandos e ambientes padrão do LaTeX

O LaTeX possui comandos integrados para alterar o alinhamento tipográfico do texto:

* à direita irregular (`\raggedright`)
* à esquerda irregular (`\raggedleft`)
* centralizado (`\centering`)

juntamente com os ambientes correspondentes:

* à direita irregular (`flushleft` ambiente)
* à esquerda irregular (`flushright` ambiente)
* centralizado (`centering` ambiente)

No entanto, o [`ragged2e` pacote](https://ctan.org/pkg/ragged2e?lang=en) fornece alguns refinamentos que melhoram esses comandos e ambientes padrão do LaTeX.

## Usando o pacote ragged2e

Para começar, aqui está um exemplo usando o `ragged2e` pacote e sua `[document]` opção para compor o *texto completo do documento* como à direita irregular (alinhado à esquerda). O código de exemplo adiciona a linha

```latex
\usepackage[document]{ragged2e}
```

ao preâmbulo do documento:

```latex
\documentclass{article}
\usepackage[document]{ragged2e}

\begin{document}
\section{Heading on Level 1 (section)}
Olá, aqui há algum texto sem significado. Este texto deve mostrar como ficará um texto impresso neste local. Se você ler este texto, não obterá nenhuma informação. Realmente? Não há nenhuma informação? Há alguma diferença entre este texto e um disparate como de jeito nenhum! Um texto cego como este fornece informações sobre a fonte selecionada, como as letras são escritas e uma impressão da aparência.
\end{document}
```

[Abra este `ragged2e` exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Example+using+ragged2e+package\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Bdocument%5D%7Bragged2e%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csection%7BHeading+on+Level+1+%28section%29%7D%0AHello%2C+here+is+some+text+without+a+meaning.+This+text+should+show+what+a+printed+text+will+look+like+at+this+place.++If+you+read+this+text%2C+you+will+get+no+information.++Really%3F++Is+there+no+information%3F++Is+there+a+difference+between+this+text+and+some+nonsense+like+not+at+all%21++A+blind+text+like+this+gives+you+information+about+the+selected+font%2C+how+the+letters+are+written+and+an+impression+of+the+look.%0A%5Cend%7Bdocument%7D)

Este exemplo produz a seguinte saída:

![Ragged2eOLV21.png](/files/2d1137cd242b29ce1d98fa6c394a48b63959aca1)

## Comparando \raggedright (LaTeX) vs \RaggedRight (ragged2e)

O comando LaTeX `\raggedright` às vezes produz resultados que parecem ficar "irregulares demais". O pacote `ragged2e` resolve esse problema ao permitir hifenização quando uma linha é muito curta, gerando uma borda de texto irregular mais uniforme. O exemplo a seguir mostra texto alinhado à esquerda produzido pelo comando LaTeX `\raggedright` e, para comparação, o mesmo texto composto usando o `\RaggedRight` comando fornecido pelo `ragged2e`:

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{blindtext}

\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar os efeitos

\subsection*{Exemplo alinhado à esquerda com
\texttt{\string\raggedright}\\ (comando padrão do \LaTeX{})}
\raggedright\blindtext[2]\par

\subsection*{Exemplo alinhado à esquerda com \texttt{\string\RaggedRight}\\ (comando \texttt{ragged2e})}
\RaggedRight\blindtext[2]\par
\end{document}
```

[Abra este exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+left-aligned+text\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bragged2e%7D%0A%5Cusepackage%7Bblindtext%7D%0A%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Chsize%7D%7B0.9%5Chsize%7D%25+emphasize+effects%0A%0A%5Csubsection%2A%7BLeft-aligned+example+with+%0A%5Ctexttt%7B%5Cstring%5Craggedright%7D%5C%5C+%28standard+%5CLaTeX%7B%7D+command%29%7D%0A%5Craggedright%5Cblindtext%5B2%5D%5Cpar%0A%0A%5Csubsection%2A%7BLeft-aligned+example+with+%5Ctexttt%7B%5Cstring%5CRaggedRight%7D%5C%5C+%28%5Ctexttt%7Bragged2e%7D+command%29%7D%0A%5CRaggedRight%5Cblindtext%5B2%5D%5Cpar+%0A%5Cend%7Bdocument%7D)

![Leftaligncompare2.png](/files/3034624f4880002e44d8f66bd506ea3309582e7f)

Conforme discutido no `ragged2e` [documentação do pacote](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/ragged2e/ragged2e.pdf), `ragged2e` fornece comandos e ambientes alternativos para modificar o alinhamento do texto e veremos alguns deles.

## Ambientes para texto à direita irregular (alinhado à esquerda)

O ambiente padrão do LaTeX para produzir texto à direita irregular é `flushleft`. O equivalente em `ragged2e` chama-se `FlushLeft` (observe as maiúsculas e minúsculas). O exemplo a seguir compara a saída desses ambientes:

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{blindtext}
\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar os efeitos

\subsection*{Ambiente \texttt{flushleft}: (padrão \LaTeX{})}

\begin{flushleft}
\blindtext[1]
\end{flushleft}

\subsection*{Ambiente \texttt{FlushLeft}: (\texttt{ragged2e})}

\begin{FlushLeft}
\blindtext[1]
\end{FlushLeft}

\end{document}
```

[Abra este exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+left-aligned+text\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bragged2e%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Chsize%7D%7B0.9%5Chsize%7D%25+emphasize+effects%0A%0A%5Csubsection%2A%7B%5Ctexttt%7Bflushleft%7D+environment%3A+%28standard+%5CLaTeX%7B%7D%29%7D%0A%0A%5Cbegin%7Bflushleft%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7Bflushleft%7D%0A%0A%5Csubsection%2A%7B%5Ctexttt%7BFlushLeft%7D+environment%3A+%28%5Ctexttt%7Bragged2e%7D%29%7D%0A%0A%5Cbegin%7BFlushLeft%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7BFlushLeft%7D%0A%0A%5Cend%7Bdocument%7D)

![Flcompare.png](/files/d2da4198d9549be224a717c2d2a3e28d844f111f)

## Ambientes para texto à esquerda irregular (alinhado à direita)

O ambiente padrão do LaTeX para produzir texto à esquerda irregular (alinhado à direita) é `flushright`. O equivalente em `ragged2e` chama-se `FlushRight` (observe as maiúsculas e minúsculas). O exemplo a seguir compara a saída desses ambientes:

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{blindtext}
\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar os efeitos

\subsection*{Ambiente \texttt{flushright}: (padrão \LaTeX{})}

\begin{flushright}
\blindtext[1]
\end{flushright}

\subsection*{Ambiente \texttt{FlushRight}: (\texttt{ragged2e})}

\begin{FlushRight}
\blindtext[1]
\end{FlushRight}

\end{document}
```

[Abra este exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+right-aligned+text\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bragged2e%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Chsize%7D%7B0.9%5Chsize%7D%25+emphasize+effects%0A%0A%5Csubsection%2A%7B%5Ctexttt%7Bflushright%7D+environment%3A+%28standard+%5CLaTeX%7B%7D%29%7D%0A%0A%5Cbegin%7Bflushright%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7Bflushright%7D%0A%0A%5Csubsection%2A%7B%5Ctexttt%7BFlushRight%7D+environment%3A+%28%5Ctexttt%7Bragged2e%7D%29%7D%0A%0A%5Cbegin%7BFlushRight%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7BFlushRight%7D%0A%0A%5Cend%7Bdocument%7D)

![FRcompare.png](/files/1d0fefa1ef3f5021d9383549d4cc235a19e1671c)

## Ambientes para centralizar texto

O ambiente padrão do LaTeX para produzir texto centralizado é `center`. O equivalente em `ragged2e` chama-se `Center` (observe as maiúsculas e minúsculas). O exemplo a seguir compara a saída desses ambientes:

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{blindtext}
\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar os efeitos

\subsection*{Ambiente \texttt{center}: (padrão \LaTeX{})}

\begin{center}
\blindtext[1]
\end{center}

\subsection*{Ambiente \texttt{Center}: (\texttt{ragged2e})}
\begin{Center}
\blindtext[1]
\end{Center}
\end{document}
```

[Abra este exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+right-aligned+text\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bragged2e%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Chsize%7D%7B0.9%5Chsize%7D%25+emphasize+effects%0A%0A%5Csubsection%2A%7B%5Ctexttt%7Bcenter%7D+environment%3A+%28standard+%5CLaTeX%7B%7D%29%7D%0A%0A%5Cbegin%7Bcenter%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7Bcenter%7D%0A%0A%5Csubsection%2A%7B%5Ctexttt%7BCenter%7D+environment%3A+%28%5Ctexttt%7Bragged2e%7D%29%7D%0A%5Cbegin%7BCenter%7D%0A%5Cblindtext%5B1%5D%0A%5Cend%7BCenter%7D%0A%5Cend%7Bdocument%7D)

![Centrecompare.png](/files/f2bd9784309ab5b18997fab7a09a7d95870f2405)

## Texto totalmente justificado

O pacote `ragged2e` fornece o comando `\justifying` que você pode usar como mostrado no exemplo abaixo:

```latex
\documentclass{article}
\usepackage[english]{babel}
\usepackage{ragged2e}
\usepackage{blindtext}
\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar os efeitos

\Centering
\blindtext[1]

\vspace{5mm}
\justifying
\blindtext[1]
\end{document}
```

[Abra este exemplo no Overleaf](https://www.overleaf.com/docs?engine=pdflatex\&snip_name=Demonstrating+justification+with+ragged2e\&snip=%5Cdocumentclass%7Barticle%7D%0A%5Cusepackage%5Benglish%5D%7Bbabel%7D%0A%5Cusepackage%7Bragged2e%7D%0A%5Cusepackage%7Bblindtext%7D%0A%5Cbegin%7Bdocument%7D%0A%5Csetlength%7B%5Chsize%7D%7B0.9%5Chsize%7D%25+emphasize+effects%0A%0A%5CCentering%0A%5Cblindtext%5B1%5D%0A%0A%5Cvspace%7B5mm%7D%0A%5Cjustifying%0A%5Cblindtext%5B1%5D+%0A%5Cend%7Bdocument%7D)

![Justifyingdemo.png](/files/49ac1e7cca9e85a18a40f261fb1751360726e10d)

## Guia de referência

**Resumo de ambientes e comandos para alinhamento de texto**

| Alinhamento            | Ambiente     | Comando de alternância | ambiente ragged2e | comando de alternância ragged2e |
| ---------------------- | ------------ | ---------------------- | ----------------- | ------------------------------- |
| Esquerda               | `flushleft`  | `\raggedright`         | `FlushLeft`       | `\RaggedRight`                  |
| Direita                | `flushright` | `\raggedleft`          | `FlushRight`      | `\RaggedLeft`                   |
| Centro                 | `center`     | `\centering`           | `Center`          | `\Centering`                    |
| Totalmente justificado |              |                        | `justificar`      | `\justifying`                   |

## Leitura adicional

Para mais informações, veja :

* [Parágrafos e novas linhas](/latex/overleaf-learn-latex-pt/nocoes-basicas-de-latex/02-paragraphs-and-new-lines.md)
* [Formatação de parágrafos](/latex/overleaf-learn-latex-pt/formatacao/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Negrito, itálico e sublinhado](/latex/overleaf-learn-latex-pt/nocoes-basicas-de-latex/03-bold-italics-and-underlining.md)
* [Tamanhos, famílias e estilos de fonte](/latex/overleaf-learn-latex-pt/fontes/01-font-sizes-families-and-styles.md)
* [Tipos de letra](/latex/overleaf-learn-latex-pt/fontes/02-font-typefaces.md)
* [Suporte a fontes modernas com XeLaTeX](/latex/overleaf-learn-latex-pt/fontes/03-xelatex.md)
* [Quebras de linha e espaços em branco](/latex/overleaf-learn-latex-pt/formatacao/05-line-breaks-and-blank-spaces.md)
* [Listas](/latex/overleaf-learn-latex-pt/nocoes-basicas-de-latex/04-lists.md)
* [Secções e capítulos](/latex/overleaf-learn-latex-pt/estrutura-do-documento/01-sections-and-chapters.md)
* [Múltiplas colunas](/latex/overleaf-learn-latex-pt/formatacao/09-multiple-columns.md)
* [Documentos de uma face e de dupla face](/latex/overleaf-learn-latex-pt/formatacao/08-single-sided-and-double-sided-documents.md)
* [A introdução não tão curta ao LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [A documentação do pacote ragged2e](http://mirror.hmc.edu/ctan/macros/latex/contrib/ms/ragged2e.pdf)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/overleaf-learn-latex-pt/formatacao/06-text-alignment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
