2

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} 
\newcommand{\loadFigure}[1]{ % define command to load figures
    \ExecuteMetaData[figures_file]{#1} 
}
%\usepackage{endfloat} %un-comment to produce error
\begin{document}
Hello world\\   
\loadFigure{fig:figure1}
\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@     ...
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).

1
  • 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
    Commented May 8, 2019 at 13:48

1 Answer 1

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:

\DeclareDelayedFloatFlavour{loadFigure}{figure}
\makeatletter
\newcommand\my@efloat@if@end[3]{#3#2}
\pretocmd\loadFigure{%
    \begingroup
    \let\efloat@if@end\my@efloat@if@end}{}{}
\makeatother

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.

1
  • etoolbox is already loaded by catchfilebetweentags, that's why you don't need it here.
    – Marijn
    Commented 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 .