2

Is there a way to make tables and figures appear in the same TOC, in order of appearance in the document, but numbered separately? Exactly like this post, but with the tables and figures mixed together in order of page number? I know this sounds odd, but I have an application that specifically requires this format.

EDIT: Thanks to Jagath, the main issue is solved. However, this has upset the formatting a little. To use his MWE:

\documentclass{article}
\usepackage{lipsum,tocloft}

\makeatletter
\newcommand{\listfloatname}{List of Floats}
\newlistof{float}{flt}{\listfloatname}
\long\def\@caption#1[#2]#3{%
\par
\refstepcounter{float}%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
 {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\addcontentsline{flt}{float}%
 {\protect\numberline{\csname thefloat\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\if@minipage
  \@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
% my formatting 
\renewcommand{\cfttabfont}{Table }
\renewcommand{\cftfigfont}{Figure }
\renewcommand{\cfttabaftersnum}{:}
\renewcommand{\cftfigaftersnum}{:}

\begin{document}
\listoffloat
\listoftables
\listoffigures

\newpage
\lipsum[1]

\begin{figure}
\caption{First figure.}
\end{figure}

\begin{table}[h]
\caption{First table.}
\end{table}

\lipsum[1]

\begin{figure}[h]
\caption{Second figure.}
\end{figure}

\lipsum[1]

\begin{table}
\caption{Second table.}[h]
\end{table}

\lipsum[1]

\end{document}
4

Here is how you can achieve using tocloft package:

\documentclass{article}

\usepackage{lipsum,tocloft}

\makeatletter
\newcommand{\listfloatname}{List of Floats}
\newlistof{float}{flt}{\listfloatname}
\long\def\@caption#1[#2]#3{%
  \par
  \refstepcounter{float}%
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
  \addcontentsline{flt}{float}%
    {\protect\numberline{\csname thefloat\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}
\makeatother

\begin{document}

\listoffloat

\lipsum[1]

\begin{figure}
\caption{First figure.}
\end{figure}

\lipsum[1]

\begin{table}
\caption{First table.}
\centering
\begin{tabular}{cccc}
      \multicolumn{1}{c}{$C$}  & \multicolumn{1}{c}{$M_i$} & \multicolumn{1}{c}{$m$}  & \multicolumn{1}{c}{$G'_i$}  \\ \hline
      28,3 & 1 & 22 & 43  \\
      28,4 & 3 & 25 & 141
\end{tabular}
\end{table}

\lipsum[1]

\begin{figure}
\caption{Second figure.}
\end{figure}

\lipsum[1]

\begin{table}
\caption{Second table.}
\centering
\begin{tabular}{cccc}
      \multicolumn{1}{c}{$C$}  & \multicolumn{1}{c}{$M_i$} & \multicolumn{1}{c}{$m$}  & \multicolumn{1}{c}{$G'_i$}  \\ \hline
      28,2 & 2 & 21 & 80  \\
      28,4 & 3 & 25 & 141
\end{tabular}
\end{table}

\lipsum[1]

\end{document}

If the numbering should be seperate then change:

  \addcontentsline{flt}{float}%
    {\protect\numberline{\csname thefloat\endcsname}{\ignorespaces #2}}%

to

  \addcontentsline{flt}{float}%
    {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%

The difference is to change \csname thefloat\endcsname to \csname the#1\endcsname.

Updated Answer:

The following code will generate the PDF with float names.

\documentclass{article}
\usepackage{lipsum,tocloft}

\makeatletter
\newcommand{\listfloatname}{List of Floats}
\newlistof{float}{flt}{\listfloatname}
\long\def\@caption#1[#2]#3{%
\par
\refstepcounter{float}%
\addcontentsline{\csname ext@#1\endcsname}{#1}%
 {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\addcontentsline{flt}{#1}%
 {\protect\numberline{\csname the#1\endcsname}{\ignorespaces #2}}%
\begingroup
\@parboxrestore
\if@minipage
  \@setminipage
\fi
\normalsize
\@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
\endgroup}
\makeatother
% my formatting 
\renewcommand{\cfttabfont}{Table }
\renewcommand{\cftfigfont}{Figure }
\renewcommand{\cfttabaftersnum}{:}
\renewcommand{\cftfigaftersnum}{:}

\begin{document}
\listoffloat
\listoftables
\listoffigures

\newpage
\lipsum[1]

\begin{figure}
\caption{First figure.}
\end{figure}

\begin{table}[h]
\caption{First table.}
\end{table}

\lipsum[1]

\begin{figure}[h]
\caption{Second figure.}
\end{figure}

\lipsum[1]

\begin{table}
\caption{Second table.}[h]
\end{table}

\lipsum[1]

\end{document}
  • Thank you so much, this works like a charm. I was using \renewcommand{\cfttabfont}{Table } and \renewcommand{\cftfigfont}{Figure } to provide labels - is there a way I can adapt them? I thinkthat I need to edit the flt class, but cftfltfont obviously is not defined - I'd have to make that a command? – JP Janet Jun 28 '16 at 3:50
  • 1
    Sorry. I couldn't quiet get it. Could you please post a minimum working example, so that I can help you :-) – Jagath Jun 28 '16 at 4:01
  • Sure, I'll add it to an edit in my question. Thanks again! – JP Janet Jun 28 '16 at 4:05
  • 1
    @JPJanet: Could you please check the new code appended to my answer. – Jagath Jun 28 '16 at 4:32
  • 1
    Excellent, thank you! If I could accept it twice... – JP Janet Jun 28 '16 at 4:48

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.