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}
1

1 Answer 1

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}
1
  • 2
    Wouldn't \captionof{figure} be easier? Dec 4, 2014 at 2:58

You must log in to answer this question.

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