> 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/es/formato/06-text-alignment.md).

# Alineación del texto

## Introducción

Por defecto, LaTeX compone el texto con justificación completa, pero en ocasiones puede ser más apropiado un texto alineado a la izquierda o con «margen derecho irregular» (para idiomas de derecha a izquierda), por ejemplo, texto dentro de columnas estrechas. Este artículo explica cómo cambiar la alineación del texto de partes, o de todo, de su documento usando las funciones integradas de LaTeX y el paquete `ragged2e`.

## Los comandos y entornos estándar de LaTeX

LaTeX sí tiene comandos integrados para cambiar la alineación tipográfica del texto:

* alineado a la izquierda (`\raggedright`)
* alineado a la derecha (`\raggedleft`)
* centrado (`\centering`)

junto con los entornos correspondientes:

* alineado a la izquierda (`flushleft` entorno)
* alineado a la derecha (`flushright` entorno)
* centrado (`centering` entorno)

Sin embargo, el [`ragged2e` paquete](https://ctan.org/pkg/ragged2e?lang=en) proporciona algunas mejoras que perfeccionan estos comandos y entornos estándar de LaTeX.

## Uso del paquete ragged2e

Para empezar, aquí hay un ejemplo usando el `ragged2e` paquete y su `[document]` opción para componer *todo el texto del documento* como alineado a la izquierda. El código de ejemplo añade la línea

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

al preámbulo del documento:

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

\begin{document}
\section{Encabezado en nivel 1 (sección)}
Hola, aquí hay un texto sin significado. Este texto debería mostrar cómo se verá un texto impreso en este lugar. Si lees este texto, no obtendrás ninguna información. ¿De verdad? ¿No hay ninguna información? ¿Hay alguna diferencia entre este texto y algún sinsentido como ¡nada en absoluto! Un texto ciego como este te da información sobre la fuente seleccionada, cómo están escritas las letras y una impresión del aspecto.
\end{document}
```

[Abre este `ragged2e` ejemplo en 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 ejemplo produce la siguiente salida:

![Ragged2eOLV21.png](/files/425cc2e00df4fd14470d4268e9e786c1d918caf4)

## Comparación de \raggedright (LaTeX) frente a \RaggedRight (ragged2e)

El comando de LaTeX `\raggedright` a veces produce resultados que parecen verse «demasiado irregulares». El paquete `ragged2e` aborda este problema permitiendo la separación silábica cuando una línea es demasiado corta, generando un borde de texto irregular más uniforme. El siguiente ejemplo muestra texto alineado a la izquierda producido mediante el comando de LaTeX `\raggedright` y, para comparar, el mismo texto compuesto usando el `\RaggedRight` comando proporcionado por `ragged2e`:

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

\begin{document}
\setlength{\hsize}{0.9\hsize}% enfatizar los efectos

\subsection*{Ejemplo alineado a la izquierda con
\texttt{\string\raggedright}\\ (comando estándar de \LaTeX{})}
\raggedright\blindtext[2]\par

\subsection*{Ejemplo alineado a la izquierda con \texttt{\string\RaggedRight}\\ (comando \texttt{ragged2e})}
\RaggedRight\blindtext[2]\par
\end{document}
```

[Abre este ejemplo en 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/2ea5cdc65bd4be63b3c6a9ee7c57863cfedfa0cb)

Como se comenta en el `ragged2e` [documentación del paquete](https://mirror.ox.ac.uk/sites/ctan.org/macros/latex/contrib/ragged2e/ragged2e.pdf), `ragged2e` proporciona comandos y entornos alternativos para modificar la alineación del texto y veremos algunos de ellos.

## Entornos para texto alineado a la izquierda

El entorno predeterminado de LaTeX para producir texto alineado a la izquierda es `flushleft`. El equivalente en `ragged2e` se llama `FlushLeft` (observe las mayúsculas). El siguiente ejemplo compara la salida de esos entornos:

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

\subsection*{Entorno \texttt{flushleft}: (\LaTeX{} estándar)}

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

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

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

\end{document}
```

[Abre este ejemplo en 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/fc72d58306334a86bb506c2c9ea294dd9d347f17)

## Entornos para texto alineado a la derecha

El entorno predeterminado de LaTeX para producir texto alineado a la derecha es `flushright`. El equivalente en `ragged2e` se llama `FlushRight` (observe las mayúsculas). El siguiente ejemplo compara la salida de esos entornos:

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

\subsection*{Entorno \texttt{flushright}: (\LaTeX{} estándar)}

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

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

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

\end{document}
```

[Abre este ejemplo en 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/572de94782493377808ff8ca786d7fd401402732)

## Entornos para centrar texto

El entorno predeterminado de LaTeX para producir texto centrado es `center`. El equivalente en `ragged2e` se llama `Center` (observe las mayúsculas). El siguiente ejemplo compara la salida de esos entornos:

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

\subsection*{Entorno \texttt{center}: (\LaTeX{} estándar)}

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

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

[Abre este ejemplo en 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/022fc7ed0495b946946f63ca9a515ff7738cfca4)

## Texto completamente justificado

El paquete `ragged2e` proporciona el comando `\justifying` que puede usar como se muestra en el ejemplo siguiente:

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

\Centering
\blindtext[1]

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

[Abre este ejemplo en 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/600c02bb3f425bcf26c89e141ecbe7b7abfed677)

## Guía de referencia

**Resumen de entornos y comandos para la alineación del texto**

| Alineación                | Entorno      | Comando de cambio | entorno ragged2e | comando de cambio de ragged2e |
| ------------------------- | ------------ | ----------------- | ---------------- | ----------------------------- |
| Izquierda                 | `flushleft`  | `\raggedright`    | `FlushLeft`      | `\RaggedRight`                |
| Derecha                   | `flushright` | `\raggedleft`     | `FlushRight`     | `\RaggedLeft`                 |
| Centro                    | `center`     | `\centering`      | `Center`         | `\Centering`                  |
| Completamente justificado |              |                   | `justificar`     | `\justifying`                 |

## Lectura adicional

Para más información, consulte:

* [Párrafos y nuevas líneas](/latex/es/conceptos-basicos-de-latex/02-paragraphs-and-new-lines.md)
* [Formato de párrafos](/latex/es/formato/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Negrita, cursiva y subrayado](/latex/es/conceptos-basicos-de-latex/03-bold-italics-and-underlining.md)
* [Tamaños, familias y estilos de fuente](/latex/es/fuentes/01-font-sizes-families-and-styles.md)
* [Familias tipográficas](/latex/es/fuentes/02-font-typefaces.md)
* [Compatibilidad con fuentes modernas con XeLaTeX](/latex/es/fuentes/03-xelatex.md)
* [Saltos de línea y espacios en blanco](/latex/es/formato/05-line-breaks-and-blank-spaces.md)
* [Listas](/latex/es/conceptos-basicos-de-latex/04-lists.md)
* [Secciones y capítulos](/latex/es/estructura-del-documento/01-sections-and-chapters.md)
* [Varias columnas](/latex/es/formato/09-multiple-columns.md)
* [Documentos a una sola cara y a doble cara](/latex/es/formato/08-single-sided-and-double-sided-documents.md)
* [La introducción no tan breve a LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [La documentación del paquete 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/es/formato/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.
