Time for action – using the minipage environment
We will use the minipage
environment instead of \parbox
to get a text with a width of just 3 cm.
Modify the parbox example to get the following code:
\documentclass{article} \begin{document} \begin{minipage}{3cm} TUG is an acronym. It means \TeX\ Users Group. \end{minipage} \end{document}
Typeset and look at the output:
What just happened?
By using \begin{minipage}
, we started a "page in a page". We specified the width of 3cm by the mandatory argument. From this point onwards, the text lines will have a width of 3cm. They will be automatically wrapped and fully justified. We ended this restriction with \end{minipage}
. Any text typed afterwards would run over the complete body text width.
Note: There won't be a page break in such a "minipage".
Have you been a hero struggling with the \parbox
and all of its optional arguments? The minipage
environment accepts all those arguments as well with the same meaning.