I tend to use latex's features on a need-to-know basis, only seeking new ones when there's something I want to do but don't know how. This happened recently with an article I was writing. I wanted to group a number of definitions together in a floating environment with a black box around them. Enter minipage. The minipage environment creates...well, um...a mini page with adjustable height and width within a page. A minipage can have footnotes, figures, the works. In conjunction with the figure environment and a framebox, I used it to create my boxed-in definitions as follows:
\begin{figure}[t]
\noindent \framebox{
\begin{minipage}[t]{1.0\textwidth}
\begin{definition}[Definition 1's Name]
\label{def:mydef1}
My Def text here.
\end{definition}
\begin{definition}[Definition 2's Name]
\label{def:mydef2}
My Def text here.
\end{definition}
\end{minipage}
}
\caption{Some definitions}
\label{fig:mydefs}
\end{figure}
I should probably mention the \noindent. At first, I didn't wrap the minipage within a figure environment, and I found that latex kept indenting the minipage because it was treating it like a paragraph. The \noindent made sure that the minipage was flush with the left margin.
Minipage is more powerful than the above illustrates. For instance, it can also be used to make a single figure out of several smaller figures. Each smaller figure simply gets its own minipage. Consider the following:
\begin{figure}
\begin{minipage}[t]{1.0\linewidth}
\center{\underline{\Large{Some Text}}}
\vspace{.1in}
\end{minipage}
\hfill
\begin{minipage}[t]{1.0\linewidth}
\epsfxsize=4.5in
\centerline{\hbox{
\epsffile{a-figure-component.eps}
}}
\vspace{.15in}
\end{minipage}
\hfill
\framebox{
\begin{minipage}[t]{0.45\linewidth}
\begin{tabular}{l}
Stuff inside the tabular environment
\end{tabular}
\end{minipage}
}
\begin{minipage}[t]{0.55\linewidth}
\epsfxsize=2.3in
\centerline{\hbox{
\epsffile{another-figure-component.eps}
}}
\center{\large{b)}}
\end{minipage}
\caption{Caption Text}
\label{figure-label}
\end{figure}
The above figure utilizes four minipages. The first is the width of the page and consists of some text. The second is also the width of the page and consists of a figure I drew with Xfig. The third minipage is 0.45 times the width of the page and consists of some text in a tabular environment. The fourth takes up the remaining 0.55 of the page width and consists of another figure I drew with Xfig. The result is a single figure with title text at the top and a large figure beneath that. The tabular text and the smaller figure are side-by-side beneath the larger figure. Note that I had to play around with \vspace commands to get the spacing right. A Google search for minipage and latex will unearth many more details.
Friday, August 17, 2007
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment