# How to get a Scheme from chemmacros floats inside a section?

Currently I'm struggling with a weird problem. I use the chemmacros package to provide the \scheme float enviroment for my chemical schemes. Then I use \FloatBarrier to prevent them from floating away too far. Now there should be a specific layout where I have my sectionheading then the picture and then the text. So my code looks like this:

\documentclass[a4, english]{scrreprt}
\begin{document}
\section{Synthesis A}
\FloatBarrier
\begin{scheme}[h]
\includegraphics
\end{scheme}

Here some text

\end{document}


For some reason I have cases, where it works out totally fine, in other samples, the warning "h specified to ht" comes up and I have the scheme on the page, then the heading of the section or subsection then the text.

I know that Float enviroments are there to float not to be restricted but this drives me mad. So I'm looking for a workaround. Can I place a picture just by \includegraphics{} and then still add a label and a caption to it leaving out the float environment?

I heard of the package captionof which might provide some help?

The solution is quite easy, actually, and you're on the right track: don't use the floating environment. I'd probably use center instead.

You can still caption the image with \captionof which is available in each KOMA-Script class like scrreprt that you're already using*:

\documentclass{scrreprt}
\usepackage{chemmacros}
\usechemmodule{scheme}

\usepackage{lipsum}

\begin{document}

\section{Synthesis A}

\begin{center}
\includegraphics{example-image-a}
\captionof{scheme}{Some caption}
\end{center}

\lipsum

\end{document}


* users of other classes can use the caption package which also provides \captionof.