Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I created custom float objects using the float package to draw stuff with tikz.

\usepackage{float}
 \floatstyle{plain}
 \newfloat{tkizfloat}{htb}{lof}
 \floatname{tkizfloat}{Figure}

Is there any way of adding custom floats like this one created above to the \listoffigures without messing up the existing one?

And how to ensure that the custom float objects are counted the same way like normal figure objects, like that:

1.1 Example 1 (figure)
1.2 Example 2 (figure)
1.3 Example 3 (tikzfloat)
1.4 Example 4 (figure)

I'm currently adding them simply to the lof-file but that's a complete mess. Just see the screenshot below to understand the problems explained above.

screenshot explaining the issue

Minimal working example for the screenshot above:

\documentclass{report}
\usepackage[english]{babel}
\usepackage{float}
 \floatstyle{plain}
 \newfloat{tkizfloat}{htb}{lof}
 \floatname{tkizfloat}{Figure}
\usepackage{environ}
\usepackage{tikz}
 \NewEnviron{elaboration}{
  \par
  \begin{tikzpicture}
   \node[rectangle,minimum width=0.4\textwidth] (m)
   {\begin{minipage}{0.5\textwidth}\BODY\end{minipage}};
   \draw[dashed] (m.south west) rectangle (m.north east);
  \end{tikzpicture} }
 \usetikzlibrary{plotmarks}

\begin{document}
 \listoffigures

 \begin{tkizfloat}
  \centering
  \begin{tikzpicture}[y=4cm, x=.5cm,font=\sffamily]
   \draw (0,0) -- coordinate (x axis mid) (20,0);
   \draw (0,0) -- coordinate (y axis mid) (0,1);
  \end{tikzpicture}
  \caption{Some Chart}
  \label{tkiz:example}
 \end{tkizfloat}

 \begin{figure}[htb]
  \centering
  \includegraphics[width=0.5\textwidth]{example.png}
  \caption{Some Image}
  \label{img:example}
 \end{figure}
\end{document}
share|improve this question
4  
Why don't you simply use the figure environment? –  egreg Jun 3 '12 at 15:07
    
some solutions are too simple to figure out, thanks :) –  vertoe Jun 3 '12 at 15:24
    
A common misconception is that figure can contain only \includegraphics and, conversely, that \includegraphics can only go in a figure environment. Both are wrong. –  egreg Jun 3 '12 at 15:27
add comment

2 Answers 2

up vote 6 down vote accepted

Your current labelling/numbering scheme is confusing as it is now: you have two floating objects labelled "Figure" but they are numbered independently. Apparently your new float behaves exactly as figure, so you can simply use the figure environment to wrap your tikzpicture; this will solve both the numbering and the LoF issues:

\documentclass{report}
\usepackage{pgfplots}

\begin{document}
 \listoffigures

 \begin{figure}
  \centering
  \begin{tikzpicture}[y=4cm, x=.5cm,font=\sffamily]
   \draw (0,0) -- coordinate (x axis mid) (20,0);
   \draw (0,0) -- coordinate (y axis mid) (0,1);
  \end{tikzpicture}
  \caption{Some Chart}
  \label{tkiz:example}
 \end{figure}

 \begin{figure}[htb]
  \centering
  \includegraphics[width=0.5\textwidth]{cat}
  \caption{Some Image}
  \label{img:example}
 \end{figure}
\end{document}

enter image description here

share|improve this answer
    
i feel so stupid right now, i tried so much but i never thought of simply using the exiting figure environment... thanks alot! –  vertoe Jun 3 '12 at 15:21
add comment

In case you really want a new float type (say, "Map") that nevertheless should be listed in the List of Figures, here's how to do it:

\documentclass{article}

\renewcommand*{\listfigurename}{List of Figures and Maps}

\usepackage{newfloat}
\DeclareFloatingEnvironment[fileext=lof]{map}

\usepackage{caption}
\captionsetup[figure]{listformat=simple}
\captionsetup[map]{listformat=simple}

\makeatletter
\renewcommand*{\l@figure}{\@dottedtocline{1}{1.5em}{4.5em}}
\renewcommand*{\l@map}{\@dottedtocline{1}{1.5em}{4.5em}}
\renewcommand*{\p@figure}{\figurename~}
\renewcommand*{\p@map}{\mapname~}
\makeatother

\begin{document}

\listoffigures

\begin{figure}[ht]
\centering
\rule{1cm}{1cm}
\caption{A figure}
\end{figure}

\begin{map}[ht]
\centering
\rule{1cm}{1cm}
\caption{A map}
\end{map}

\end{document}

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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