8

I am using the minipage environment to put a table and figure next to each other. Now I would like this to 'float' like a normal figure or table, such that LaTeX decides where to put it (using the [htb] options). After some googling, I found that the minipage environment is not a floating one, so it will always be inserted in the same location as the code. This is not always the nicest solution.

Is there a way to prevent/circumvent this, such that also a minipage is treated like a float?

  • 2
  • Thanks, I didn't know about the floatrow package, and it would be a good option, if my document class hadn't used the float package. I'm getting errors that say they're not compatible. – Jelle May 24 '13 at 11:58
  • There were other possible solutions there as well. You could use Thorsten's last alternative, and replace the outer minipage with figure. – Torbjørn T. May 24 '13 at 12:02
  • 1
    @Jelle Since the floatrow package is (nearly) compatible to the commands offered by the float package, you could replace the float package by the floatrow package. – Axel Sommerfeldt May 25 '13 at 5:09
5

You can use an existing float such as figure instead of minipage to hold your side by side figure and table.

\documentclass{article}

\usepackage{capt-of}


\makeatletter
%\let\ftype@table\ftype@figure
\makeatother


\begin{document}

\listoffigures

\listoftables

\clearpage


\begin{figure}
\begin{minipage}{.4\textwidth}XXX
\captionof{figure}{fff}
\end{minipage}\hfill
\begin{minipage}{.4\textwidth}\rule{2cm}{1cm}
\captionof{table}{ttt}
\end{minipage}
\end{figure}

aaa

\begin{figure}
\begin{minipage}{.4\textwidth}YYY
\captionof{figure}{fff}
\end{minipage}\hfill
\begin{minipage}{.4\textwidth}\rule{2cm}{3cm}
\captionof{table}{ttt}
\end{minipage}
\end{figure}

aaa

\begin{table}\rule{2cm}{7cm}\quad\rule{2cm}{7cm}
\caption{TTT}
\end{table}

aaa

\begin{figure}
\begin{minipage}{.4\textwidth}XXX
\captionof{figure}{fff}
\end{minipage}\hfill
\begin{minipage}{.4\textwidth}\rule{2cm}{1cm}
\captionof{table}{ttt}
\end{minipage}
\end{figure}

aaa

\begin{figure}
\begin{minipage}{.4\textwidth}YYY
\captionof{figure}{fff}
\end{minipage}\hfill
\begin{minipage}{.4\textwidth}\rule{2cm}{3cm}
\captionof{table}{ttt}
\end{minipage}
\end{figure}

aaa


\end{document}

Note however that while this works, LaTeX sees this as a figure while floating boxes around so only keeps it in sequence with figures this means that if some tables are on their own in a table environment they may float out of sequence with tables that are in a figure environment.

The end result is that the list of tables looks like

enter image description here

The simplest fix is to uncomment the commented line so that figures and tables are kept in the same sequence. This has the disadvantage that LaTeX won't then float any figure past any table so it gives less flexibility in the algorithm but it has the advantage of working and placing teh floats in the correct order as shown in the lists:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.