> 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/more-topics/47-text-alignment-es.md).

# Text alignment es

La alineación del texto en un documento LaTeX se puede controlar manualmente mediante diversos comandos. En éste artículo se explica cómo cambiar la alineación ya sea para parte del texto o para todo un documento.

## Introducción

Por defecto el texto en LaTeX está justificado a ambos lados, pero con frecuencia el texto alineado a la izquierda es un formato más apropiado para el documento. Alinear texto a la izquierda es fácil por medio del paquete **ragged2e**.

```latex
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage[document]{ragged2e}

\begin{document}
\section{Heading on Level 1 (section)}

Hello, here is some text without a meaning.  This text should show
what aprinted text will look like at this place.  If you read this
text, you will get noinformation...

\end{document}
```

![TextAlignementEx1.png](/files/ZjBTiApa9GVVfOCR7Pb8)

La línea

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

importa el paquete **ragged2e** y justifica a la izquierda el texto. Consulta la [siguiente sección](#usando-el-paquete-ragged2e) para más información sobre cómo funciona el paquete.

[Abrir ejemplo en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535344dec52fabc07908ab7e/download/zip\&templateName=Text%20Alignment\&compiler=pdflatex)

## Usando el paquete ragged2e

Hay varios comandos estándar en LaTeX para cambiar la alineación del texto. Una alternativa a esos comandos es proveida por el paquete **ragged2e**.

Cuando uno alinea su documento a la izquierda o a la derecha, a veces el texto se ve «muy rasgado», muy disparejo. El paquete **ragged2e** ataca este problema permitiendo el uso de guiones para separar palabras cuando la línea se queda demasiado corta, generado una orilla más uniforme. En seguida se presenta el ejemplo mostrado en la [introducción](#introduccin) comparado con el mismo texto alineado usando sólo comandos estándar de LaTeX.

![TextAlignementEx2.png](/files/lK0DHVw2sfNO1GDulHwT)

El paquete provee comandos alternativos para [texto alineado a la izquierda](#texto-alineado-a-la-izquierda), [texto alineado a la derecha](#texto-alineado-a-la-derecha) y [texto centrado](#texto-centrado) que soportan separación por guiones. Para poder usar éstos comandos es necesario importar el paquete primero, añadiendo la siguiente línea en el preámbulo:

```latex
\usepackage{ragged2e}
```

Ejemplos alternativos a los descritos en este artículos se presentan en el siguiente enlace: [Abrir ejemplo del paquete ragged2e en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535357a5c52fabc07908aba8/download/zip\&templateName=Ragged2e\&compiler=pdflatex)

## Texto alineado a la izquierda

El ambiente por defecto para alinear texto a la izquierda es `flushleft`

```latex
\begin{flushleft}
Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
\end{flushleft}

This  is  the  second  paragraph. Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
```

![TextAlignmentEx3.png](/files/M7GWqapBwzzXI2Oo3mYw)

El texto entre los comandos `\begin{flushleft}` y `\end{flushleft}` está alineado a la izquierda. El ambiente correspondiente en [ragged2e](#usando-el-paquete-ragged2e) es `FlushLeft`.

El comando conmutador `\raggedright` también produce texto alineado a la izquierda, pero el comportamiento de éste comando es diferente; en este caso el texto permanecerá alineado a la izquierda hasta que otro comando conmutador lo cambie. Éste comando es adecuado cuando se requiere cambiar la alineación de bloques muy largos de texto o incluso todo el documento. El comando equivalente en [ragged2e](#usando-el-paquete-ragged2e) es `\RaggedRight`.

[Abrir ejemplo en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535344dec52fabc07908ab7e/download/zip\&templateName=Text%20Alignment\&compiler=pdflatex)

## Texto alineado a la derecha

Alinear texto a la derecha es fácil por medio del ambiente `\flushright`.

```latex
\begin{flushright}
Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
\end{flushright}

This  is  the  second  paragraph. Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
```

![TextAlignmentEx4.png](/files/CpJnEPdP66JaDEt7H4V2)

El texto entre los comandos `\begin{flushright}` y `\end{flushright}` está alineado a la derecha. Si prefieres [ragged2e](#usando-el-paquete-ragged2e), el comando correspondiente es ese paquete es `FlushRight`.

El comando conmutador `\raggedleft` también produce texto alineado a la derecha, pero el comportamiento de éste comando es diferente; en este caso el texto permanecerá alineado a la derecha hasta que otro comando conmutador lo cambie. Éste comando es adecuado cuando se requiere cambiar la alineación de bloques muy largos de texto o incluso todo el documento. El comando equivalente en [ragged2e](#usando-el-paquete-ragged2e) es `\RaggedLeft`.

[Abrir ejemplo en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535344dec52fabc07908ab7e/download/zip\&templateName=Text%20Alignment\&compiler=pdflatex)

## Texto centrado

Para centrar un bloque de texto se debe usar el `\center`

```latex
\begin{center}
Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
\end{center}

This  is  the  second  paragraph. Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
```

![TextAlignmentEx5.png](/files/hjLjoSIPjOAPGvWSloqv)

El texto entre los comandos `\begin{center}` y `\end{center}` está alineado a la derecha. Si prefieres [ragged2e](#usando-el-paquete-ragged2e), el comando correspondiente es ese paquete es `Center`.

El comando conmutador `\centering` también produce texto alineado al centro, pero el comportamiento de éste comando es diferente; en este caso el texto permanecerá centrado hasta que otro comando conmutador lo cambie. Éste comando es adecuado cuando se requiere cambiar la alineación de bloques muy largos de texto o incluso todo el documento. El comando equivalente en [ragged2e](#usando-el-paquete-ragged2e) es `\Centering`.

[Abrir ejemplo en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535344dec52fabc07908ab7e/download/zip\&templateName=Text%20Alignment\&compiler=pdflatex)

## Texto justificado

En LaTeX el texto está justificado por defecto y si se usa alguno de los comandos conmutadores `\raggedright` o `\raggedleft` la alineación ya no se puede revertir. Para estos casos la opción es usar el paquete **ragged2e**. Se debe importar añadiendo el comando `\usepackage{ragged2e}` en el preámbulo del documento, una vez hecho ésto se puede usar el comando `justify` tal como se muestra en el siguiente ejemplo:

```latex
\centering
Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.

\justify
This  is  the  second  paragraph. Hello, 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,
you will get no information.  Really?  Is there no information?  Is there
a difference between this text and some nonsense like not at all!  A
blind text like this gives you information about the selected font, how
the letters are written and an impression of the look.  This text should
contain all letters of the alphabet and it should be written in of the
original language.There is no need for special content, but the length of
words should match the language.
```

![TextAlignmentEx6.png](/files/rov5KlHtXmCGyQh4po0C)

El primer párrafo en el ejemplo es centrado por medio del comando conmutador `\centering` y posteriormente su alineación se revierte a texto justificado por medio de `\justify`.

**ragged2e** también provee un ambiente homónimo, `justify` que permite justificar bloques de texto en un documento que esté completamente alineado a la izquierda o a la derecha.

[Abrir un ejemplo del paquete ragged2e en Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535357a5c52fabc07908aba8/download/zip\&templateName=Ragged2e\&compiler=pdflatex)

## Guía de referencia

**Resumen de comandos y ambientes para alinear texto**

| Alineación  | Ambiente     | Comando conmutador | Ambiente en ragged2e | Comando conmutador en ragged2e |
| ----------- | ------------ | ------------------ | -------------------- | ------------------------------ |
| Izquierda   | `flushleft`  | `\raggedright`     | `FlushLeft`          | `\RaggedRight`                 |
| Derecha     | `flushright` | `\raggedleft`      | `FlushRight`         | `\RaggedLeft`                  |
| Centrar     | `center`     | `\centering`       | `Center`             | `\Centering`                   |
| Justificado |              |                    | `justify`            | `\justify`                     |

[Open an example of the ragged2e package in Overleaf](https://www.sharelatex.com/project/new/template?zipUrl=/project/535357a5c52fabc07908aba8/download/zip\&templateName=Ragged2e\&compiler=pdflatex)

## Lecturas adicionales

Para más información consultar:

* [Paragraphs and new lines](/latex/latex-basics/02-paragraphs-and-new-lines.md)
* [Paragraph formatting](/latex/formatting/04-articles-how-to-change-paragraph-spacing-in-latex.md)
* [Bold, italics and underlining](/latex/latex-basics/03-bold-italics-and-underlining.md)
* [Font sizes, families, and styles](/latex/fonts/01-font-sizes-families-and-styles.md)
* [Font typefaces](/latex/fonts/02-font-typefaces.md)
* [Supporting modern fonts with XeLaTeX](/latex/fonts/03-xelatex.md)
* [Line breaks and blank spaces](/latex/formatting/05-line-breaks-and-blank-spaces.md)
* [Lists](/latex/latex-basics/04-lists.md)
* [Sections and chapters](/latex/document-structure/01-sections-and-chapters.md)
* [Multiple columns](/latex/formatting/09-multiple-columns.md)
* [Single sided and double sided documents](/latex/formatting/08-single-sided-and-double-sided-documents.md)
* [The not so short introduction to LaTeX2ε](http://www.ctan.org/tex-archive/info/lshort/)
* [The ragged2e package documentation](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/more-topics/47-text-alignment-es.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.
