Graphics, Figures & Tables ⇒ Textbox with multiple figures and/or tables
Textbox with multiple figures and/or tables
Hi,
At the moment I am writing a thesis and I want to make an 'intermezzo' block, where I can write text, add figures and tables. I tried several things, e.g. \fbox,\colorbox, and \parbox, but it becomes problematic when I want to add multiple figures in the same textbox. With one figure or table you can avoid problems by putting the \begin{figure} outside the \fbox, but this I can't do if I want more than one figure in the intermezzo block.
Does anyone knows how to do this. It must be a frequently asked question, but cannot find it on the internet.
Thanks,
Miriam
At the moment I am writing a thesis and I want to make an 'intermezzo' block, where I can write text, add figures and tables. I tried several things, e.g. \fbox,\colorbox, and \parbox, but it becomes problematic when I want to add multiple figures in the same textbox. With one figure or table you can avoid problems by putting the \begin{figure} outside the \fbox, but this I can't do if I want more than one figure in the intermezzo block.
Does anyone knows how to do this. It must be a frequently asked question, but cannot find it on the internet.
Thanks,
Miriam
NEW: TikZ book now 40% off at Amazon.com for a short time.

- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Textbox with multiple figures and/or tables
Hi Miriam,
you cannot use figures or tables in a box since they are floating objects. In the box, directly use \includegraphics and tabular etc.
If you need captions, you could use the caption package and its command \captionof, such as
Stefan
you cannot use figures or tables in a box since they are floating objects. In the box, directly use \includegraphics and tabular etc.
If you need captions, you could use the caption package and its command \captionof, such as
Code: Select all
\usepackage{caption}
% or customized captions, such as
% \usepackage[margin=10pt,font=small,labelfont=bf]{caption}
...
\begin{framed}% or any box
...
\begin{center}
\begin{minipage}{\linewidth}
\centering
\includegraphics{filename}
\captionof{figure}{Description}
\label{fig:10}
\end{minipage}
\end{center}
...
\end{framed}
LaTeX.org admin
Re: Textbox with multiple figures and/or tables
Hi Stefan,
Thank you for your answer. It indeed works when you only have one figure of table. But I would like to have multiple figures in the framed box.
Furthermore, by using the caption package, LaTeX is now giving errors for all the other figures since there I only use \caption{blahblah}. According to the package documentation you have to define for every caption if it is a figure or a table. This is quite a lot of work. Do you know a smarter way for this??
Regards,
Miriam
Thank you for your answer. It indeed works when you only have one figure of table. But I would like to have multiple figures in the framed box.
Furthermore, by using the caption package, LaTeX is now giving errors for all the other figures since there I only use \caption{blahblah}. According to the package documentation you have to define for every caption if it is a figure or a table. This is quite a lot of work. Do you know a smarter way for this??
Regards,
Miriam
Textbox with multiple figures and/or tables
What errors do you get? Could you please tell us the very first one?mippes wrote:Furthermore, by using the caption package, LaTeX is now giving errors for all the other figures
This is (of course) still ok, if typeset inside a floating environment. Otherwise you'll get an error, but this is true when not using the caption package, too.since there I only use \caption{blahblah}.
This is not the case. Where exactly have you read this?According to the package documentation you have to define for every caption if it is a figure or a table.

Or do you mean \captionof? You don't have to use it, as an alternative one can use \captionsetup{type=figure}, e.g.:
Code: Select all
\usepackage{caption}
% or customized captions, such as
% \usepackage[margin=10pt,font=small,labelfont=bf]{caption}
...
\begin{framed}% or any box
...
\begin{center}
\begin{minipage}{\linewidth}
\captionsetup{type=figure}
\centering
\includegraphics{filename}
\caption{Description}
\label{fig:10}
...
\end{minipage}
\end{center}
...
\end{framed}
Textbox with multiple figures and/or tables
Additionally, I have a question about your initial post:
Why can't you do that?mippes wrote:With one figure or table you can avoid problems by putting the \begin{figure} outside the \fbox, but this I can't do if I want more than one figure in the intermezzo block.
Textbox with multiple figures and/or tables
The errors I get, when I don't change anything, but only add the package (\usepackage{caption}) and even not add any frames:
The comment on the errors is in Section 2.9 of http://archive.cs.uu.nl/mirror/CTAN/mac ... on-eng.pdf! Undefined control sequence.
\captionlabelfont@default ->\cph@font
l.6 \caption{The hydrological cycle.}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
Textbox with multiple figures and/or tables
Concerning the question on why I cannot put the \begin{figure} outside frame:
E.g. if I do:
Then it is considered as two blocks/floats. Problem is then that the text from the main text is coming in between the intermezzo blocks. Even if I force the framed box to be located [h!]
E.g. if I do:
Code: Select all
\begin{figure}
\begin{framed}
\includegraphics{..}
\caption{blahblah}
\end{framed}
\end{figure}
\begin{figure}
\begin{framed}
\includegraphics{...figure2}
\caption{blahblah}
\end{framed}
\end{figure}
Textbox with multiple figures and/or tables
It seems that your document class is called "thesis". In this case older versions of the caption package assumed that you are using the thesis document class from CTAN. This was fixed in version 3.1l of the caption package.mippes wrote:! Undefined control sequence.
\captionlabelfont@default ->\cph@font
So either update your caption package, or place the following code after loading the caption package:
Code: Select all
\captionsetup{format=plain,labelfont=,textfont=}
Code: Select all
\begin{figure}
\begin{framed}
\includegraphics{..}
\caption{blahblah}
\end{framed}
\begin{framed}
\includegraphics{...figure2}
\caption{blahblah}
\end{framed}
\end{figure}
Code: Select all
\begin{figure}
\begin{framed}
\includegraphics{..}
\caption{blahblah}
\medskip
\includegraphics{...figure2}
\caption{blahblah}
\end{framed}
\end{figure}