> 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/it/formattazione/06-text-alignment.md).

# Allineamento del testo

## Introduzione

Per impostazione predefinita, LaTeX impagina il testo completamente giustificato, ma talvolta un testo allineato a sinistra o "a margine irregolare a destra" (per lingue da destra a sinistra) può essere più appropriato—ad esempio il testo all'interno di colonne strette. Questo articolo spiega come cambiare l'allineamento del testo per parti, o per l'intero documento, usando le funzionalità integrate di LaTeX e il pacchetto `ragged2e`.

## I comandi e gli ambienti standard di LaTeX

LaTeX dispone di comandi integrati per modificare l'allineamento tipografico del testo:

* a margine irregolare a destra (`\raggedright`)
* a margine irregolare a sinistra (`\raggedleft`)
* centrato (`\centering`)

insieme ai corrispondenti ambienti:

* a margine irregolare a destra (`flushleft` ambiente)
* a margine irregolare a sinistra (`flushright` ambiente)
* centrato (`centering` ambiente)

Tuttavia, il [`ragged2e` che fornisce i comandi e le funzionalità necessarie per includere file grafici esterni. L'esempio sopra carica il](https://ctan.org/pkg/ragged2e?lang=en) fornisce alcuni raffinamenti che migliorano questi comandi e ambienti standard di LaTeX.

## Usando il pacchetto ragged2e

Per cominciare, ecco un esempio che utilizza il `ragged2e` pacchetto e la sua `[document]` opzione per impaginare il *l'intero testo del documento* come a margine irregolare a destra (allineato a sinistra). Il codice di esempio aggiunge la riga

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

al preambolo del documento:

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

\begin{document}
\section{Titolo di livello 1 (section)}
Ciao, ecco un testo senza significato. Questo testo dovrebbe mostrare come apparirà un testo stampato in questo punto. Se leggi questo testo, non otterrai alcuna informazione. Davvero? Non c'è alcuna informazione? C'è una differenza tra questo testo e una sciocchezza come assolutamente no! Un testo fittizio come questo ti dà informazioni sul carattere selezionato, su come sono scritte le lettere e un'impressione dell'aspetto.
\end{document}
```

[Apri questo `ragged2e` esempio in 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)

Questo esempio produce il seguente output:

![Ragged2eOLV21.png](/files/a90e80f1cc49ffff97558c8ae1ba11f3ff94ab88)

## Confronto tra \raggedright (LaTeX) e \RaggedRight (ragged2e)

Il comando LaTeX `\raggedright` a volte produce risultati che sembrano "troppo irregolari". Il pacchetto `ragged2e` affronta questo problema consentendo la sillabazione quando una riga è troppo corta, generando un bordo del testo irregolare più uniforme. L'esempio seguente mostra il testo allineato a sinistra prodotto tramite il comando LaTeX `\raggedright` e, per confronto, lo stesso testo impaginato usando il `\RaggedRight` comando fornito da `ragged2e`:

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

\begin{document}
\setlength{\hsize}{0.9\hsize}% emphasize effects

\subsection*{Esempio allineato a sinistra con
\texttt{\string\raggedright}\\ (comando standard \LaTeX{})}
\raggedright\blindtext[2]\par

\subsection*{Esempio allineato a sinistra con \texttt{\string\RaggedRight}\\ (comando \texttt{ragged2e})}
\RaggedRight\blindtext[2]\par
\end{document}
```

[Apri questo esempio in 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/92e59baa555ba809345cf536de25f43797cb5e54)

Come discusso nel `ragged2e` [documentazione del pacchetto](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/ragged2e/ragged2e.pdf), `ragged2e` fornisce comandi e ambienti alternativi per modificare l'allineamento del testo e ne esamineremo alcuni.

## Ambienti per testo a margine irregolare a destra (allineato a sinistra)

L'ambiente LaTeX predefinito per produrre testo a margine irregolare a destra è `flushleft`. L'equivalente in `ragged2e` si chiama `FlushLeft` (si noti la maiuscola). L'esempio seguente confronta l'output di questi ambienti:

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

\subsection*{Ambiente \texttt{flushleft}: (standard \LaTeX{})}

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

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

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

\end{document}
```

[Apri questo esempio in 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/5d3e217f06b3a97d726dd2cc97e065aeea87af8a)

## Ambienti per testo a margine irregolare a sinistra (allineato a destra)

L'ambiente LaTeX predefinito per produrre testo a margine irregolare a sinistra (allineato a destra) è `flushright`. L'equivalente in `ragged2e` si chiama `FlushRight` (si noti la maiuscola). L'esempio seguente confronta l'output di questi ambienti:

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

\subsection*{Ambiente \texttt{flushright}: (standard \LaTeX{})}

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

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

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

\end{document}
```

[Apri questo esempio in 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/fcc79785ac5a3572a3eccec575a5a2ec78095d22)

## Ambienti per centrare il testo

L'ambiente LaTeX predefinito per produrre testo centrato è `center`. L'equivalente in `ragged2e` si chiama `Center` (si noti la maiuscola). L'esempio seguente confronta l'output di questi ambienti:

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

\subsection*{Ambiente \texttt{center}: (standard \LaTeX{})}

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

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

[Apri questo esempio in 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/6861205b0620296326fd6425c2bb297cadeb8763)

## Testo giustificato

Il pacchetto `ragged2e` fornisce il comando `\justifying` che puoi usare come mostrato nell'esempio seguente:

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

\Centering
\blindtext[1]

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

[Apri questo esempio in 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/54078b9218deb517d502283b720b8b06875f7b07)

## Guida di riferimento

**Riepilogo degli ambienti e dei comandi per l'allineamento del testo**

| Allineamento | Ambiente     | Comando di commutazione | ambiente ragged2e | comando di commutazione ragged2e |
| ------------ | ------------ | ----------------------- | ----------------- | -------------------------------- |
| Sinistra     | `flushleft`  | `\raggedright`          | `FlushLeft`       | `\RaggedRight`                   |
| Destra       | `flushright` | `\raggedleft`           | `FlushRight`      | `\RaggedLeft`                    |
| Centro       | `center`     | `\centering`            | `Center`          | `\Centering`                     |
| Giustificato |              |                         | `giustifica`      | `\justifying`                    |

## Approfondimenti

Per maggiori informazioni vedere :

* [Paragrafi e nuove righe](/latex/it/concetti-di-base-di-latex/02-paragraphs-and-new-lines.md)
* [Formattazione dei paragrafi](/latex/it/formattazione/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Grassetto, corsivo e sottolineatura](/latex/it/concetti-di-base-di-latex/03-bold-italics-and-underlining.md)
* [Dimensioni, famiglie e stili dei caratteri](/latex/it/caratteri/01-font-sizes-families-and-styles.md)
* [Caratteri tipografici](/latex/it/caratteri/02-font-typefaces.md)
* [Supporto dei font moderni con XeLaTeX](/latex/it/caratteri/03-xelatex.md)
* [Interruzioni di riga e spazi vuoti](/latex/it/formattazione/05-line-breaks-and-blank-spaces.md)
* [Elenchi](/latex/it/concetti-di-base-di-latex/04-lists.md)
* [Sezioni e capitoli](/latex/it/struttura-del-documento/01-sections-and-chapters.md)
* [Colonne multiple](/latex/it/formattazione/09-multiple-columns.md)
* [Documenti a facciata singola e doppia](/latex/it/formattazione/08-single-sided-and-double-sided-documents.md)
* [L'introduzione non proprio breve a LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [La documentazione del pacchetto 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/it/formattazione/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.
