简体   繁体   English

Latex minipage用于对齐文本组

[英]Latex minipage to align groups of text

I am trying to get two minipage sections to show up next to each other. 我试图让两个小型部分彼此相邻。 They always show up one underneath the other currently below is an example of my .tex 它们总是出现在另一个下面,下面是我的.tex的一个例子

Example: 例:

\begin{minipage}[b]{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}
\begin{minipage}[b]{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}

You need to remove the newline from one minipage to the other. 您需要将换行符从一个小型号移到另一个小型号。

\begin{minipage}{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}\begin{minipage}{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}

You can keep the newline if you fake it with the comment character 如果你用评论字符伪造它,你可以保留换行符

\begin{minipage}{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}%
\begin{minipage}{1in}
   Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}

Note that if the accumulated width of minipages is too wide, the next one will drop to the next line (kind of like floating divs... if you do css). 请注意,如果小型的累积宽度太宽,则下一行将下降到下一行(类似浮动div ...如果你做css)。 In order to worry about this less, I generally give my minipages a width which is a fraction of the line width. 为了减少这一点,我通常给我的小型宽度是线宽的一小部分。 For instance \\begin{minipage{0.25\\linewidth} . 例如\\begin{minipage{0.25\\linewidth} You have to account for a little separation and I dont know what relevant tex variables handle the glue in this case, but if I keep the total less than or equal to 0.99\\linewidth things seem to be ok. 你需要考虑一点分离,我不知道在这种情况下哪些相关的tex变量处理胶水,但是如果我保持总数小于或等于0.99\\linewidth似乎没问题。

HTH HTH

When I run the following through pdfLaTeX I get a document with two vertical columns, aligned next to one another; 当我通过pdfLaTeX运行以下内容时,我得到一个带有两个垂直列的文档,彼此相邻排列;

\documentclass{article}
\begin{document}
\begin{minipage}[b]{1in} Hello World
akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd \end{minipage}
\begin{minipage}[b]{1in} Hello World
akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd \end{minipage}
\end{document}

In the future, please use code tags around your examples. 将来,请在示例周围使用代码标记。

You could also just set them in a two column table: 您也可以将它们设置在两列表中:

\begin{tabular}{ p{0.5\textwidth} p{0.5\textwidth} }

column one blah blab blah

&

column two blah blab blah

\tabularnewline
\end{tabular}

You can use the \\textwidth command to make them fit: 您可以使用\\textwidth命令使它们适合:

\documentclass{article}
\begin{document}
\begin{minipage}[b]{0.5\textwidth}
Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}
\begin{minipage}[b]{0.5\textwidth}
Hello World akdjfasljdfkjasjdfjsadkflkjksadflkaskjdfsadlflkjsafdalkjsfd
\end{minipage}
\end{document}

(learnt this trick here ) 在这里学到了这个技巧)

Do make sure there aren't any blank lines between the end of one minipage and the start of another. 确保一个小型号的末端与另一个小型号的开头之间没有任何空白行。 And you may want to use \\noindent before the first \\begin{minipage} to get the columns to be aligned the same as the text with respect to the left margin. 并且您可能希望在第一个\\begin{minipage}之前使用\\noindent来使列与左边距的文本对齐。

You should increase the minipage width from 1in to say 5in or 6cm 您应该将小型宽度从1in 5in增加到5in6cm 5in

For example: 例如:

\begin{minipage}[b]{1in}

should be: 应该:

\begin{minipage}[b]{5in}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM