# Is catchfilebetweentags compatible with endfloat?

I am using catchfilebetweentags to add figures to a document as described here. I get an error when additionally using the endfloat package. Here is an example:

Main file:

\documentclass[11pt]{article}
\usepackage{catchfilebetweentags}
}
%\usepackage{endfloat} %un-comment to produce error
\begin{document}
Hello world\\
\end{document}


Secondary/figures file (figures_file.tex):

%<*fig:figure1>
\begin{figure}[htpb!]
\caption{A figure}
\end{figure}
%</fig:figure1>


The error is produced by un-commenting \usepackage{endfloat}. Error message:

! Undefined control sequence.
\GenericError  ...
#4  \errhelp \@err@     ...


I know this might seem like an odd thing to want to do, but I mostly want the figures at position in the text, but occasionally want them at the end (e.g. if en editor asks me to put them there).

• Welcome back to TeX.SE! I've included the error message in your question, that might help other people to verify the behavior and try to find an answer. The error does look a bit obscure however, even for LaTeX standards :) – Marijn May 8 '19 at 13:48

The problem seems to be related to the issue explained here: a problem in endfloat with floats added via macro. I adapted a solution provided there by Axel-Sommerfeldt that works. The following should be added to the preamble when enabling endfloat:

\DeclareDelayedFloatFlavour{loadFigure}{figure}
\makeatletter
\newcommand\my@efloat@if@end[3]{#3#2}

• etoolbox is already loaded by catchfilebetweentags, that's why you don't need it here. – Marijn May 9 '19 at 15:00