LaTeX的minipage命令

The minipage is often used to put things next to each other, which can otherwise be hard put together. For example, two pictures side by side, two tables next to a text or a picture or vice versa. The idea behind the minipage command is that within an existing page “built in” an additional page. By this one has the opportunity to use this new page, for example, set two pictures side by side, then just set two minipages side by side. Here than in Figure 1 is set in the first and Figure 2 in the second minipage.

The command minipage

Wherein minipage is an environment that has a specific orientation, and a predetermined width.

1
2
3
4
5
\begin{minipage}[adjusting]{width of the minipage}
Text ... \ \
Images ... \ \
Tables ... \ \
\end{minipage}

Adjustment

When adjusting the choices is: c (for centers) t (for top) and b (for bottom). By default, c is used for centering. It is aligned by t and/or b at the highest (top line) and/or at the lowest line (bottom line).

Width

The width can be set as absolute or as relative value. That means one can indicate 0.2 to the 6cm or 60mm or 0.3\textwidth or \textwidth as value for the width can. Whereby one must note here that the widths of several minipages those do not lay next to each other than the width of the text are larger, since otherwise everything cannot be indicated.

Further options

Besides there are still further options, which however in practical application the minipage does not play a role like the height and the adjustment (again c, t and b) within the minipage.

Example of further options

1
\begin{minipage}[t][5cm][b]{0.5\textwidth}

This minipage now has a defined height of 5cm, and the content will now be aligned to the bottom of the minipage.
Hint
A mistake that is often made is, there is a blank line between the \end{minipage} and \begin{minipage} left. Then the pages are no longer together.

Examples minipage

Put three pictures side by side, where you should set the width of the image using width = \textwidth, if they are too wide.

1
2
3
4
5
6
7
8
9
\begin{minipage}[t]{0.3\textwidth}
\includegraphics[width=\textwidth]{pic1}
\end{minipage}
\begin{minipage}[t]{0.3\textwidth}
\includegraphics[width=\textwidth]{pic2}
\end{minipage}
\begin{minipage}[t]{0.3\textwidth}
\includegraphics[width=\textwidth]{pic3}
\end{minipage}

With minipage also text can be put next to an image, this also can be implemented by the usepackage sidecap.

1
2
3
4
5
6
7
8
9
10
\begin{minipage}{0.5\textwidth}
\includegraphics[width=\textwidth]{pic1}
\end{minipage}
\begin{minipage}{0.5\textwidth}
on pic 1 you find the word pic 1\\
on pic 1 you find the word pic 1\\
on pic 1 you find the word pic 1\\
on pic 1 you find the word pic 1\\
on pic 1 you find the word pic 1\ \vspace{2.5cm}\\
\end{minipage}

Two tables next to each other:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\begin{minipage}{0.2\textwidth}
\begin{tabular}{|c|c|c|}
\hline
A & B & C \\
\hline
1 & 2 & 3 \\
\hline
4 & 5 & 6 \\
\hline
\end{tabular}
\end{minipage}
\begin{minipage}{0.2\textwidth}
\begin{tabular}{c|c|c}
A & B & C \\
\hline
1 & 2 & 3 \\
\hline
4 & 5 & 6 \\
\end{tabular}
\end{minipage}

Reference

Latex minipage