Latex minipage to align groups of text

Larry picture Larry · Oct 16, 2009 · Viewed 56.3k times · Source

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

Example:

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

Answer

cheshirekow picture cheshirekow · Aug 28, 2012

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). 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}. 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.

HTH