I run into this rather strange problem when using TikZ with LyX 2. I have this graph programmed using TikZ, and it is supposed to follow a paragraph of text and be positioned at the top of next new page. Instead, it is positioned exactly at the center of the new page, leaving a chunk of space between the text and itself. In my document, I place the tex code for the figure immediately after the text itself with a space, and the TikZ code is as follows.
\usetikzlibrary{shapes}
\usetikzlibrary{fit}
\usetikzlibrary{calc}
\usetikzlibrary{arrows}
\begin{figure}[ht!]
\centering
\begin{tikzpicture} [label distance=2mm,
vertice/.style={circle, fill=gray!30, thick, inner sep=0pt, minimum size=7mm},
dot/.style={shape=circle, fill=black, minimum size=2pt, inner sep=0pt, outer sep=2pt}]
\node [vertice] (a) at (0,7) {$t_1$};
\node [vertice] (b) at (0,6) {$t_2$};
\node [vertice] (c) at (0,5) {$t_3$};
\node [dot] (d) at ($(c) + (270:1)$) {};
\node [dot] (e) at ($(d) + (270:0.5)$) {};
\node [dot] (f) at ($(e) + (270:0.5)$) {};
\node[draw, ellipse, label=below:$T$, fit=(a) (b) (c) (d) (e) (f)] {};\node [vertice] (h) at (5,7) {$a_1$};
\node [vertice] (i) at (5,6) {$a_2$};
\node [vertice] (j) at (5,5) {$a_3$};
\node [dot] (k) at ($(j) + (270:1)$) {};
\node [dot] (l) at ($(k) + (270:0.5)$) {};
\node [dot] (m) at ($(l) + (270:0.5)$) {};
\node[draw, ellipse, label=below:$A$, fit=(h) (i) (j) (k) (l) (m)] {};
\path (h) edge [-stealth, auto, swap] node {$w_1$} (a)
edge [-stealth, auto] node[below, sloped] {$w_2$} (e)
(i) edge [-stealth, auto, swap] node {$w_3$} (b)
(j) edge [-stealth, auto] node[below, sloped] {$w_4$} (a)
edge [-stealth, auto] node[above, sloped] {...} (f)
(k) edge [-stealth, auto] node[above, sloped] {...} (c)
(l) edge [-stealth, auto] node[below, sloped] {...} (d)
(m) edge [-stealth, auto] node {...} (f);
\end{tikzpicture}
\caption{A graph $G$}
\end{figure}
Any suggestion how it can be fixed?
I am using Springer LNCS document class, if that makes any difference.
Best Answer
If the figure happens to be on the very last page with no text following it it is centered as illustrated by the MWE below (if you comment out the
\setlength
line).As per Vertical layout of float pages the values that control the distances between floats are:
and the default values are:
So, setting
\@fptop
to something without the1fill
, achieves the desired result.