I haven't found any question on this but I'm having problems when placing a Tikz picture in a document. It's enclosed in a Figure environment, and it uses \centerfloat to center it, with some code in the preamble since it's not a Memoir, but an Article class.
In my MWE I added the picture between two Lorem Ipsums, but when typesetting, it appears before both of them. What is happening and how can I solve it?
\documentclass{article}
\usepackage{rotating}
\usepackage{pgfplots}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning,calc}
\usepackage{caption}
\makeatletter
\newcommand*{\centerfloat}{%
\parindent \z@
\leftskip \z@ \@plus 1fil \@minus \textwidth
\rightskip\leftskip
\parfillskip \z@skip}
\makeatother
\tikzset{
every node/.style={align=center, fill=white, draw=black, thick, rectangle, outer sep=0mm, inner sep=0mm},
rect/.style={minimum height=8mm},
recv/.style={text width=2.5cm, rotate=90},
}
\begin{document}
FIRST Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam sit amet ante id augue faucibus maximus sit amet vel lacus. Suspendisse potenti. Nullam metus nunc, auctor vel rutrum sed, sollicitudin vitae ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. In ornare elit dui, sed aliquet erat pharetra ac. Nullam viverra ipsum tincidunt est cursus, at elementum neque congue. Aliquam tempor lorem ac eros mollis accumsan. Quisque vulputate consectetur ex at mattis. Ut aliquam, ligula at placerat elementum, lorem mauris convallis ante, vel faucibus nulla leo vel odio. Quisque nec ullamcorper ipsum.\\
\begin{figure}
\centerfloat
\begin{tikzpicture}
\node[rect, text width=4cm] (prop) at (0,0) {proposition};
\node[rect, text width=12cm, left=0mm of prop, anchor=east] (ent) {entity};
\end{tikzpicture}
\caption{A caption}
\end{figure}
SECOND Nullam et efficitur justo. Donec sodales velit sit amet lorem varius tempus. Nulla vitae leo justo. Phasellus rhoncus egestas dui, in rutrum nisi ullamcorper sit amet. Aliquam eget imperdiet dolor. Morbi quis hendrerit erat. Nulla ornare purus ac sollicitudin dapibus.
\end{document}
And here's the result:


\centerfloatrather than use the standard\centering? The only reason for usingfigureis to allow the figure to move, if you do not want that, just usetikzpicturedirectly. – David Carlisle Apr 09 '15 at 08:40\centeringdoesn't work. And withoutfigure, I don't know how to add a proper caption. – Alenanno Apr 09 '15 at 08:43\begin{figure}[!htbp] ...for example? – AboAmmar Apr 09 '15 at 08:47\makeboxis the standard way to centre that, although it isn't clear that allowing things to over-print the physical page boundaries without any warning is necessarily a good thing. There are lots of ways of captioning things egcapt-ofpackage. – David Carlisle Apr 09 '15 at 08:51frameboxno need for tikz or tabular at all. – David Carlisle Apr 09 '15 at 08:57