GeneralList of "Figures and Tables"

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

List of "Figures and Tables"

Post by cbustaam »

Hi all,
In my document I have a list of tables and a list of figures, but I only have 1 table. I'm wondering if its possible to make a "List of Figures and Tables", like:


List of Figures and Tables

Figure 1. The number one
Figure 2. The number two
Table 1. The only table

Bests
"Show me your .emacs and I'll tell you who you are." -- modified proverb

Recommended reading 2024:

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

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

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

List of "Figures and Tables"

Post by gmedina »

Hi,

the idea is to redefine the \ext@table command to force all references to tables to be listed in the .lof file (that usually contains information about only figures) so that the new list of figures (produced with \listoffigures) will now include the figures and the tables.

To include the words "Figure" and "Table" in the new list I used some of the features provided by the tocloft package.

Code: Select all

\documentclass{book}
\usepackage{tocloft}

\makeatletter
  \renewcommand\ext@table{lof}
\makeatother

\newlength\mylen
\settowidth\mylen{Figure\ }
\addtolength\cftfignumwidth{\mylen}
\addtolength\cfttabnumwidth{\mylen}

\renewcommand\cftfigpresnum{Figure }
\renewcommand\cfttabpresnum{Table }

\renewcommand\listfigurename{List of Figures and Tables}

\begin{document}
\listoffigures
\clearpage

\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 1}
  \label{fig:test1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 2}
  \label{fig:test2}
\end{figure}
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test table}
  \label{tab:test}
\end{table}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

List of "Figures and Tables"

Post by cbustaam »

Thanks for your reply gmedina.
It's possible to get something like:

List of Figures and Tables

Figures
1. The number one
2. The number two

Tables
1. The only table

Bests
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

Re: List of "Figures and Tables"

Post by cbustaam »

Another question... this solutions apparently to be not compatible with the option -titles- of the tocloft package. How can I make it compatible.

Bests
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

List of "Figures and Tables"

Post by gmedina »

cbustaam wrote:Thanks for your reply gmedina.
It's possible to get something like:

List of Figures and Tables

Figures
1. The number one
2. The number two

Tables
1. The only table

Bests
You are welcome, and yes, it is possible; an example:

Code: Select all

\documentclass{book}
\usepackage{tocloft}

\renewcommand\listfigurename{List of figures and Tables}
\renewcommand\listtablename{}

\begin{document}
\listoffigures
\listoftables

\addtocontents{lof}{\bfseries\Large Figures\vskip10pt}
\addtocontents{lot}{\vskip-70pt}
\addtocontents{lot}{\bfseries\Large Tables\vskip10pt}
\clearpage

\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 1}
  \label{fig:test1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 2}
  \label{fig:test2}
\end{figure}
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test table}
  \label{tab:test}
\end{table}

\end{document}
cbustaam wrote:Another question... this solutions apparently to be not compatible with the option -titles- of the tocloft package. How can I make it compatible.

Bests
Of course they're not compatible, since the examples that I posted change the way the titles are formatted; please tell me exactly what you desire to achieve with the LoF and LoT and what document class you are using.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

List of "Figures and Tables"

Post by cbustaam »

Hi gmedina,
I have the following code

Code: Select all

\documentclass{report}
\usepackage[titles]{tocloft}
\usepackage{array}
\usepackage[table,svgnames]{xcolor}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}

\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter.\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=white!70!gray] (0,0) rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
              rounded corners=20pt,inner sep=11pt,
              fill=MidnightBlue]
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{30pt}{10pt}

\renewcommand\listfigurename{List of figures and Tables}
\renewcommand\listtablename{}

\begin{document}
\listoffigures
\listoftables

\addtocontents{lof}{\bfseries\Large Figures\vskip10pt}
\addtocontents{lot}{\vskip-70pt}
\addtocontents{lot}{\bfseries\Large Tables\vskip10pt}
\clearpage

\chapter{Chap one}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 1}
  \label{fig:test1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 2}
  \label{fig:test2}
\end{figure}
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test table}
  \label{tab:test}
\end{table}

\end{document}
Regards
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

List of "Figures and Tables"

Post by gmedina »

Hi,

in my previous response I simply used the tocloft package to avoid the LoT to begin in a new page; since the titles option for that package is incompatible with the chnages made, then a simpler solution is to redefine the \listoftables command appropriately, and now there's no need to load tocloft:

Code: Select all

\documentclass{report}
\usepackage{array}
\usepackage[table,svgnames]{xcolor}
\usepackage{tikz}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}

\titleformat{\chapter}
  {\gdef\chapterlabel{}
   \normalfont\sffamily\Huge\bfseries\scshape}
  {\gdef\chapterlabel{\thechapter.\ }}{0pt}
  {\begin{tikzpicture}[remember picture,overlay]
    \node[yshift=-3cm] at (current page.north west)
      {\begin{tikzpicture}[remember picture, overlay]
        \draw[fill=white!70!gray] (0,0) rectangle
          (\paperwidth,3cm);
        \node[anchor=east,xshift=.9\paperwidth,rectangle,
              rounded corners=20pt,inner sep=11pt,
              fill=MidnightBlue]
              {\color{white}\chapterlabel#1};
       \end{tikzpicture}
      };
   \end{tikzpicture}
  }
\titlespacing*{\chapter}{0pt}{30pt}{10pt}

\renewcommand\listfigurename{List of figures and Tables}
\renewcommand\listtablename{}

\makeatletter
\renewcommand\listoftables{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \vskip3cm%
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }
\makeatother

\begin{document}
\listoffigures
\listoftables

\addtocontents{lof}{\bfseries\Large Figures\vskip10pt}
\addtocontents{lot}{\vskip-70pt}
\addtocontents{lot}{\noindent\bfseries\Large Tables\vskip10pt}
\clearpage

\chapter{Chap one}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 1}
  \label{fig:test1}
\end{figure}
\begin{figure}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test figure 2}
  \label{fig:test2}
\end{figure}
\begin{table}[!ht]
  \centering
  \rule{4cm}{3cm}
  \caption{test table}
  \label{tab:test}
\end{table}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

List of "Figures and Tables"

Post by cbustaam »

Thanks, it works very well excetp for one thing:
When I load the babel package with spanish language, the line that rename the LoF, doesn't have any effect.

Code: Select all

\usepackage[spanish]{babel}
\renewcommand\listfigurename{Lista de Figuras y Cuadros}
Why?
"Show me your .emacs and I'll tell you who you are." -- modified proverb
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

List of "Figures and Tables"

Post by gmedina »

Because babel causes this redefinitions to have no effect; in this case, instead of simply

Code: Select all

\renewcommand\listfigurename{Lista de Figuras y Cuadros}
you have to use

Code: Select all

\addto\captionsspanish{%
  \renewcommand\listfigurename{Lista de Figuras y Cuadros}}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
User avatar
cbustaam
Posts: 57
Joined: Mon Sep 01, 2008 10:17 pm

List of "Figures and Tables"

Post by cbustaam »

Ops... I found what happend. The babel package redefine the names of some commands, so when I use the spanish language is needed to use \spanishlistfigurename instead of \listfigurename

Code: Select all

\usepackage[spanish]{babel}
\renewcommand\spanishlistfigurename{Lista de Figuras y Cuadros}
A lot of thanks gmedina.

Bests
"Show me your .emacs and I'll tell you who you are." -- modified proverb
Post Reply