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:

\newcommand{\loadFigure}[1]{ % define command to load figures
%\usepackage{endfloat} %un-comment to produce error
Hello world\\   

Secondary/figures file (figures_file.tex):

    \caption{A figure}

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

! Undefined control sequence.
\GenericError  ...                                
                                                    #4  \errhelp \@err@     ...
l.9 \loadFigure{fig:figure1}

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, 2019 at 13:48

1 Answer 1


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:


See explanation at the link above. That example loads the etoolbox package but I find this runs successfully without it. Note that this likely causes further conflicts; I already noticed one with floatrow.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .