How to Right-Align Text in LaTeX
In LaTeX, you can right-align text using the flushright
environment or the \raggedleft
command. These methods allow you to control the alignment of text in your document.
The following examples show how to right-align text in LaTeX.
How to Right-Align Text Using flushright
We can use the flushright
environment to right-align text in LaTeX document.
Suppose we want to right-align a block of text.
We can use the following LaTeX code to do so:
\documentclass{article}
\begin{document}
\begin{flushright}
This is an example of text right-aligned using the \texttt{flushright} environment.
\end{flushright}
\end{document}
Output: 👇️
This is an example of text right-aligned using the flushright environment.
In this example, we use the flushright
environment is used to right-align the text.
How to Right-Align Text Using \raggedleft
You can also use the \raggedleft
command to right-align text.
Suppose we want to right-align a block of text using the \raggedleft
command.
We can use the following LaTeX code to do so:
\documentclass{article}
\begin{document}
{\raggedleft
This is an example of text right-aligned using the \texttt{\textbackslash raggedleft} command.
}
\end{document}
Output: 👇️
This is an example of text right-aligned using the \raggedleft command.
In this example, we use the \raggedleft
command to right-align the text.
Conclusion
We can use the flushright
environment or the \raggedleft
command to right-align text.