# Different float types side-by-side

I'm familiar with using minipages inside a float to effectively place two floats side-by-side, but is there a way to do this with different float types? Eg a Figure and a Scheme (chemscheme)?

• – lockstep Oct 22 '11 at 9:35
• Welcome to TeX.sx! This question is very similar to the one lockstep pointed you to. Please take a look at it as the information there might help you. If so, that's great, and we'll probably close this question as a duplicate just to keep the place tidy and to help people find answers quickly. If not, please edit your question here to explain why so that people can better focus their attention to help you. – doncherry Oct 22 '11 at 12:41

\documentclass{article}
\usepackage[demo]{graphicx}% delete demo later
\usepackage{chemscheme}
\usepackage{caption}
\begin{document}

\begin{scheme}
\begin{floatrow}
\ffigbox[\FBwidth]
{\includegraphics[width=0.45\textwidth]{normalimage}}
{\caption{My figure}\label{foo}}
\ffigbox[\FBwidth]
{\includegraphics[width=0.45\textwidth]{chemfig}}%
{\captionof{scheme}{My chem scheme}\label{bar}}
\end{floatrow}
\end{scheme}

\end{document}


Simply use one float environment with two minipages inside. Then use the normal \caption for the one float and \captionof{<other type>}{<caption text>} for the other. This needs either the caption or the capt-of package.

The issue with scheme from chemscheme is that it isn't a normal float but (by default) defined using floatrow which doesn't support code like above (I get a 'caption lost' error). The alternate definition over the float package doesn't work either because it always places the caption on its own and not part of the actual content, so it breaks out of the minipage.

I now found the following solution which undoes some stuff from the floatrow package and define scheme the same way as figure:

\documentclass{article}

\usepackage[demo]{graphicx}% 'demo' option only to not require actually images for this example file
\usepackage{capt-of}% or 'caption'
\usepackage{chemscheme}

\begin{document}
\makeatletter
\def\scheme{\@float{scheme}}
\let\endscheme\endfigure
\makeatother

\begin{scheme}
\begin{minipage}{.48\textwidth}
\includegraphics[width=\textwidth]{normalimage}
\captionof{figure}{My figure}
\end{minipage}%
\hfill
\begin{minipage}{.48\textwidth}
\includegraphics[width=\textwidth]{chemfig}
\caption{My chem scheme}
\end{minipage}%
\end{scheme}

\end{document}


However, putting \captionof{scheme} into a figure environment still doesn't work ('caption lost' error again).

You would recommend to wait until someone which knows floatrow better than me posts an answer.

• I downvoted this because the usage of \RawFloats inside this scheme environment would be a much cleaner (and documented) solution. I'm always angry about such patches since after using three to six such "solutions" the user gets into trouble and is asking package authors (like me) for help via e-mail afterwards. – Axel Sommerfeldt Oct 22 '11 at 10:18
• @AxelSommerfeldt: No problem. It is a hack after all. Can you tell me why scheme and other floats are not defined exactly the same way than figure and table? It is a shame that e.g. float doesn't allow for arbitrary content. – Martin Scharrer Oct 22 '11 at 11:19
• Yes, it's a shame. AFAIK scheme is simply not defined like figure and table because it uses the floatrow package for defining it. The floatrow package does not do it this way because it was designed as an extension to the float package first. And the float package follows the idea of having "float styles" but forget to offer a macro to define new non-styled floating environments. – Axel Sommerfeldt Oct 22 '11 at 12:07
• KOMA-Script and the caption package are offering macros for defining new floating environments which behave like figure and table, but IMHO it would be overkill to include them for just defining new floating environments. Maybe I should split that functionality into a new package called newfloat or similar? – Axel Sommerfeldt Oct 22 '11 at 12:11
• @AxelSommerfeldt: I had the same idea about a newfloat package. However, a CTAN search gave me Joseph Wright's trivfloat package which seems to do this. – Martin Scharrer Oct 22 '11 at 12:13