[英]How to right align text and justify it? [Latex]
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. 我的问题是,我在Latex中有一个文档,我想在右侧更改一段文本的对齐方式并使其对齐。 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. 我刚开始使用Latex,但仍需要一些时间来了解它。 Thanks in advance. 提前致谢。
Actually what you want is: 实际上,您想要的是:
The way to do that is with a minipage
environment. 这样做的方法是在minipage
环境中。 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. 然后可以将minipage
页面放置在页面的给定位置。
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. minipage
为文本宽度的50%。 Change that value as required. 根据需要更改该值。
\\hfill
does horizontal filling and pushes next element (ie the minipage) towards the right margin. \\hfill
水平填充,并将下一个元素(即微型页面)推向右边距。 To have a finer control on the position of the minipage, you can use \\hspace{6cm}(minipage)\\\\
. 要更好地控制微型页面的位置,可以使用\\hspace{6cm}(minipage)\\\\
。 It will leave 6cm, insert the minipage box and ends the "line" ( \\\\
). 它将离开6厘米,插入迷你页框并结束“行”( \\\\
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.