Graphics, Figures & TablesCaption for Figure not possible

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
leonardo1979
Posts: 4
Joined: Sat Apr 07, 2012 3:46 pm

Caption for Figure not possible

Post by leonardo1979 »

Dear Tex experts,

I am trying to add a caption for a graphic generated using tikZ. I tried to use

Code: Select all

\begin{figure} 
% HERE the commands to generate my graphic
\caption{My caption}
\end{figure}
...but it is not working. the commands that I tried to use are as comments.
Where is my mistake? (I use Windows 7, WinEdt 6.0 and MiKTeX 2.8)

Code: Select all

\documentclass{minimal}
\usepackage[a4paper,margin=1cm,landscape]{geometry}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{caption}

 \usetikzlibrary{positioning,shadows,arrows}
\begin{document}
\vspace*{\fill}
%\begin{figure}
\begin{tikzpicture}[
level 1/.style={sibling distance=90mm},
level 2/.style={sibling distance=28mm},
level 3/.style={sibling distance=20mm},
level 4/.style={sibling distance=12mm},
    fact/.style={rectangle, draw=none, rounded corners=1mm, fill=blue, drop shadow,
        text centered, anchor=north, text=white},
    state/.style={circle, draw=none, fill=orange, circular drop shadow,
        text centered, anchor=north, text=white},
    leaf/.style={circle, draw=none, fill=red, circular drop shadow,
        text centered, anchor=north, text=white},
        level distance=3cm
]
\node {$\mathcal{O}$}
%
%
%
child { node {i }
%
child{ node  {j}
%
%
child{ node {x(i,j)}
edge from parent
node[left] {$\alpha_j(i)$}
}
child{node { $\mathcal{O}$}
%
edge from parent
node[midway] {$\overline{\alpha}_j(i)$}
}
edge from parent
node[left] {$\alpha_i(j)$}
}
%
%
%
child{ node  {k}
child{ node {x(i,k)}
edge from parent
node[] {$\alpha_k(i)$}
}
%
child{node  { $\mathcal{O}$ }
%
edge from parent
node[] {$\overline\alpha_k(i)$}
%
}
edge from parent
node {$\alpha_i(k)$}
}
%
child{ node {j}
child{ node {k}
child{ node {x(ijk)}
edge from parent
node[left] {$\alpha_k(jk)$}
}
child{node  { $\mathcal{O}$}
edge from parent
node {$\overline\alpha_k(jk)$}
}
edge from parent
node {$\alpha_j(jk)$}
}
child{node  { k}
child{ node {$\mathcal{O}$}
edge from parent
node [] {{$\alpha_k'(jk)$}}
}
child{node  { $\mathcal{O}$}
edge from parent
node [right] {$\overline\alpha'_k(jk)$}
}
edge from parent
node [right] {$\overline\alpha_j(jk)$}
}
edge from parent
node [right] {$\alpha_i(j,k)$}
}
edge from parent
node [left]{$\mu_{(i)}$}
}
%
%
%
%
%
%Here  J
child { node {j }
%
child{ node  {i}
%
%
child{ node {x(i,j)}
edge from parent
node[left] {$\alpha_i(j)$}
}
child{node { $\mathcal{O}$}
%
edge from parent
node[midway] {$\overline{\alpha}_i(j)$}
}
edge from parent
node[left] {$\alpha_j(i)$}
}
%
%
%
child{ node  {k}
child{ node {x(j,k)}
edge from parent
node[] {$\alpha_k(j)$}
}
%
child{node  { $\mathcal{O}$ }
%
edge from parent
node[] {$\overline\alpha_k(j)$}
%
}
edge from parent
node {$\alpha_j(k)$}
}
%
child{ node {i}
child{ node {k}
child{ node {x(ijk)}
edge from parent
node[left] {$\alpha_k(ik)$}
}
child{node  { $\mathcal{O}$}
edge from parent
node {$\overline\alpha_k(ik)$}
}
edge from parent
node {$\alpha_j(ik)$}
}
child{node  { k}
child{ node {$\mathcal{O}$}
edge from parent
node [] {{$\alpha_k'(ik)$}}
%edge from parent
%node[right] {YYYa31}
}
child{node  { $\mathcal{O}$}
edge from parent
node [right] {$\overline\alpha'_k(ik)$}
}
edge from parent
node [right] {$\overline\alpha_j(ik)$}
}
edge from parent
node [right] {$\alpha_j(i,k)$}
}
edge from parent
node [right]{$\mu_{(j)}$}
}
%
%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
%
%
%
%
child { node {k }
%
child{ node  {i}
%
%
child{ node {x(i,k)}
edge from parent
node[left] {$\alpha_i(k)$}
}
child{node { $\mathcal{O}$}
%
edge from parent
node[midway] {$\overline{\alpha}_i(k)$}
}
edge from parent
node[left] {$\alpha_k(i)$}
}
%
%
%
child{ node  {j}
child{ node {x(j,k)}
edge from parent
node[] {$\alpha_j(k)$}
}
%
child{node  { $\mathcal{O}$ }
%
edge from parent
node[] {$\overline\alpha_j(k)$}
%
}
edge from parent
node {$\alpha_k(j)$}
}
%
child{ node {i}
child{ node {j}
child{ node {x(ijk)}
edge from parent
node[left] {$\alpha_i(jk)$}
}
child{node  { $\mathcal{O}$}
edge from parent
node {$\overline\alpha_i(jk)$}
}
edge from parent
node {$\alpha_i(ij)$}
}
child{node  { j}
child{ node {$\mathcal{O}$}
edge from parent
node [] {{$\alpha_j'(ij)$}}
%edge from parent
%node[right] {YYYa31}
}
child{node  { $\mathcal{O}$}
edge from parent
node [right] {$\overline\alpha'_j(ij)$}
}
edge from parent
node [right] {$\overline\alpha_i(ij)$}
}
edge from parent
node [right] {$\alpha_i(i,j)$}
}
edge from parent
node [right]{$\mu_{(k)}$}
}
;
\end{tikzpicture}
\vspace*{\fill}
%%\caption{A caption: THIS IS A SMALL TRY}
%%\end{figure}
\end{document}
Thanks in advance for your attention.
Leo
Last edited by Stefan Kottwitz on Sat Apr 07, 2012 7:25 pm, edited 1 time in total.

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10350
Joined: Mon Mar 10, 2008 9:44 pm

Caption for Figure not possible

Post by Stefan Kottwitz »

Hi Leo,

it doesn't work because you used the minimal class, which doesn't provide a {figure} environment. With article or book, for example, it would work. Btw. \vspace*{\fill} is not needed if you use a figure environment, it's not meaningful since figures are floating objects.

Don't use the minimal class just because you don't want to create a small example, since many commands from standard classes are simply not defined. It's more like a test class for developer.

Stefan
LaTeX.org admin
leonardo1979
Posts: 4
Joined: Sat Apr 07, 2012 3:46 pm

Re: Caption for Figure not possible

Post by leonardo1979 »

Thanks a lot Stephan.
KIndest regards,
Leo
Post Reply