TikZ 図は常に新しいページの中央に配置されます

TikZ 図は常に新しいページの中央に配置されます

LyX 2 で TikZ を使用すると、このかなり奇妙な問題に遭遇します。このグラフは TikZ を使用してプログラムされており、テキストの段落の後に続き、次の新しいページの先頭に配置されるはずです。代わりに、新しいページの中央に配置され、テキストとグラフ自体の間に大きなスペースが残ります。私のドキュメントでは、図の tex コードをテキスト自体の直後にスペースを入れて配置しており、TikZ コードは次のようになります。

\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}

どうすれば修正できるでしょうか?

何か違いがあるかどうかはわかりませんが、私は Springer LNCS ドキュメント クラスを使用しています。

答え1

図が最後のページにあり、その後にテキストがない場合は、以下の MWE に示すように中央に配置されます (行をコメント アウトした場合\setlength)。

に従ってフロートページの垂直レイアウトフロート間の距離を制御する値は次のとおりです。

\@fptopページの上部から最初のフロートの上部までの距離を定義します。

\@fpsepフロート間の間隔を定義し、

\@fpbotページ上の最後のフロートの下部からページの下部までの距離を定義します。

デフォルト値は次のとおりです。

\@fptop = 0pt + 1fil
\@fpsep = 8pt + 2fil
\@fpbot = 0pt + 1fil

したがって、\@fptopなしで何かに設定すると1fill、目的の結果が得られます。

\documentclass{article}
\usepackage[demo]{graphicx}% Remove [demo] option in real use
\usepackage[showframe]{geometry}
\usepackage{lipsum}

\makeatletter% Set distance from top of page to first float
\setlength{\@fptop}{5pt}
\makeatother

\begin{document}
\lipsum[1-5]
\begin{figure}[ht!]
    \centering
    \includegraphics{foo}
    \caption{A graph $G$}
\end{figure}
\end{document}

関連情報