I am trying to add a caption to an imported document. I created the
following code to wrap it in a float:
\usepackage{caption} % Captions for graphviz figures.
\usepackage{float} % For custom floats.
\newfloat{graphvizfigure}{!h}{graphvizfigure}
\floatname{graphvizfigure}{Figure}
\newcommand{\mygraph}[2]{%
\begin{graphvizfigure}
\input{figures.gen/#1}
\caption{#2}
\end{graphvizfigure}
}
This correctly adds a caption, but the float is rendered at the top of
the following page, instead of being inserted at the position at which it
was imported.
pdflatex also produces the following warning:
LaTeX Warning: `!h' float specifier changed to `!ht'
Any idea how to prevent Latex from changing the !h specifier?
-Samuel
LaTeX is telling you that "!h" means "If the float can't go here, it can't
go anywhere". "!ht" allows the float to appear at the top of the next
page if it doesn't fit on the current page.
You may find the following FAQ answer useful:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=figurehere
-- Scott
> LaTeX is telling you that "!h" means "If the float can't go here, it
> can't go anywhere".
That'd be cool, except it should easily fit there. It is in fact placed
correctly, as long as it's not wrapped in a float.
> You may find the following FAQ answer useful:
>
> http://www.tex.ac.uk/cgi-bin/texfaq2html?label=figurehere
Yay, that helped. Using the following snippet it works just fine:
\newcommand{\mygraph}[2]{%
\vspace{1em}
\input{figures/#1}
\captionof{figure}{#2}
\vspace{1em}
}
Thanks,
-Samuel
That leads to a lot of confusion about what "fits". The picture plus
caption plus twice \intextsep spacing has to fit, and there must be at
least \textfraction portion of the page containing text (not floats),
and no more than \totalnumber floats on the page, and there is not
another float already moved to the next page (else floats would be out
of order). The FAQ tells about these parameters that LaTeX must obey
when placing floats.
Donald Arseneau as...@triumf.ca