I've spent a while trying to figure this out and haven't able to make it so far.
My question is, I have a document in Latex and I would like to change the alignment of a piece of text to the right and justify it too. What I have now can be seen in this picture.
For the image above, this is the code:
I would like to get something like this.
I am just starting out with Latex and I'm still taking some time to learn about it. Thanks in advance.
Right. The environment \begin{flushright}... \end{flushright} does the opposite of flushleft , and the text will be aligned with the right-hand margin, and have a ragged left-hand edge. If you are already in an environment you can switch this style of alignment on in a different way using \raggedleft .
For general text you can use \raggedright and \raggedleft to align the material to the left and right, respectively. To align images inside a figure easily you can use the adjustbox package which allows you to add alignment keys to \includegraphics .
This declaration corresponds to the flushleft environment. This declaration can be used inside an environment such as quote or in a parbox. Unlike the flushleft environment, the \raggedright command does not start a new paragraph; it simply changes how LaTeX formats paragraph units.
Actually what you want is:
The way to do that is with a minipage
environment. This allows to determine a box with a given size and to put text (or anything) in it.
Then it is possible to place the minipage
at a given position of the page.
Here is an example
\documentclass{article}
\begin{document}
\hfill\begin{minipage}{0.5\linewidth}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{minipage}
\end{document}
and the result
The minipage
is 50% of textwidth. Change that value as required.
\hfill
does horizontal filling and pushes next element (ie the minipage) towards the right margin. To have a finer control on the position of the minipage, you can use \hspace{6cm}(minipage)\\
. It will leave 6cm, insert the minipage box and ends the "line" (\\
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With