Graphics, Figures & TablesCan List of Figures be combined?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
thescepticalchymist
Posts: 3
Joined: Fri Jul 17, 2009 10:13 pm

Can List of Figures be combined?

Post by thescepticalchymist »

I have two floats: figure and scheme, which are numbered sequentially (they share the same counter via aliascnt). These are effectively the same thing, but they are given different names in my field of study. Is it possible to combine my List of Figures and List of Schemes into a single List of Figures and Schemes? I suspect that it would be possible to do so by using a custom listof macro or by giving some figures a scheme caption.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

thescepticalchymist
Posts: 3
Joined: Fri Jul 17, 2009 10:13 pm

Can List of Figures be combined?

Post by thescepticalchymist »

Here is some more information:
Using the caption package, I can add the following to my schemes after the caption and label:

Code: Select all

\captionlistentry*[figure]{Some text}
which creates an additional entry in the List of Figures without incrementing the shared counter. This puts the schemes into the List of Figures, but requires that each scheme be treated specially.

Also, creating the scheme float such that it uses the same external file as the figure float (*.lof) as follows gives a partial solution

Code: Select all

\newfloat{scheme}{hbtp}{lof}[chapter]
but the formatting of the scheme entries is broken.

Finally, wrapping the figure in a new environment, Scheme, and temporarily renaming Figure to Scheme as follows is incompatible with hyperref and cleveref, which still reference "Figure 1."

Code: Select all

\newenvironment{Scheme}%
   {\floatname{figure}{Scheme}\begin{figure}[hbtp]\centering\singlespacing\small\captionsetup{figurename=Scheme}}%
   {\captionsetup{figurename=Figure}\end{figure}\floatname{figure}{Figure}}
thescepticalchymist
Posts: 3
Joined: Fri Jul 17, 2009 10:13 pm

Can List of Figures be combined?

Post by thescepticalchymist »

Here is the solution that I came up with, which uses the aliascnt, cleveref, and caption packages:

Code: Select all

\DeclareCaptionType[fileext=lof]{SchemeCaption}[Scheme]
\newaliascnt{SchemeCaption}{figure}
\crefname{SchemeCaption}{scheme}{schemes}
\newenvironment{Scheme}%
{\begin{figure}\captionsetup{type=SchemeCaption}}%
{\end{figure}}
First, I create a new caption type called SchemeCaption, which adds its entries to the same file used for the List of Figures, but prints "Scheme" for the caption label. I then make this caption type's counter an alias of the figure counter with aliascnt. I then tell cleveref to label cross references to SchemeCaptions as "scheme." Finally, I create a new environment called Scheme which is a wrapper for figure, but declares the caption type to be SchemeCaption.

The net result is that my scheme and figure floats are really both figures, but I wrap the schemes in an environment so that a customized caption is used. This customized caption is labeled "Scheme" in interpreted by cleveref as "scheme".
uccaamo
Posts: 8
Joined: Thu Jul 23, 2009 11:10 am

Re: Can List of Figures be combined?

Post by uccaamo »

Hi,

I am having similar problems with my latex document. In my field, figures and schemes are two separate things, with different name and counter. The problem I have is that when I use the same command for inserting the figure, and just replace the "figure" with "scheme", I get an eror as treated as zero!! can u please help me if you know a solution or any suggestion!

many thanks
Post Reply