1

I'm using the longtable environment to display a number of figures. I'd like to include a caption at the bottom of the first page as a Figure caption, not as a table (so that it also shows up in the list of figures, not list of tables). I found in another post how to define a new figcaption, but I'm getting a "you can't use \hrule here" error when I compile the following code.

It works when I use figcaption outside of the longtable environment, but I need it to be at the bottom of the first page.

Can someone please point me in the right direction?

    \documentclass{article}
    \usepackage{array}
    \usepackage{caption}
    \usepackage{longtable}


    \makeatletter
    \def\figcaption{%
        \refstepcounter{figure}%
        \@dblarg{\@caption{figure}}}
    \makeatother

    \begin{document}
    \listoftables
    \listoffigures

    \begin{longtable}[h]{cc}

    \endfirsthead
    \endhead
    \figcaption{This should be a figure caption}\label{fig:MyFigRef}
    \endfoot
    \endlastfoot

     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\

    \end{longtable}

    \end{document}
2

I figured it out - I just needed to wrap figcaption in a multicolumn parbox.

    \documentclass{article}
    \usepackage{array}
    \usepackage{caption}
    \usepackage{longtable}


    \makeatletter
    \def\figcaption{%
        \refstepcounter{figure}%
        \@dblarg{\@caption{figure}}}
    \makeatother

    \begin{document}
    \listoftables
    \listoffigures

    \begin{longtable}[h]{cc}

    \endfirsthead
    \endhead
    \multicolumn{2}{c}{\parbox{\LTcapwidth}{\figcaption{Foo}}}
    \endfoot
    \endlastfoot

     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\
     \rule{5cm}{5cm} & \rule{5cm}{5cm} \\

    \end{longtable}

    \end{document}
  • 2
    Wouldn't \captionof{figure} be easier? – John Kormylo Dec 4 '14 at 2:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.