To make clear the following examples, I'll define a macro which produces a simple tikz picture, such as a circle with some text inside:
\newcommand{\mypicture}[1][]{% 1 optional parameter for options for the tikz picture
\begin{tikzpicture}[#1]
\node[draw, circle, fill=yellow!30, inner sep=2mm] (a) {A};
\end{tikzpicture}
}
Which produces:
Once you finish a TikZ picture, for TeX it is only a box. Think of it as a "big character" which can be part of a paragraph, like the following:
This paragraph contains a figure \mypicture{} inline.
As you can see, the "box" containing the image is aligned with the rest of your text at is baseline. Each character has an imaginary line which is used to vertically align it with other characters in the same line. The box can extends above and below of its base line, but by default tikz puts the baseline of the image at the very bottom of the resulting box.
You can change this, giving the option baseline
to your tikzpicture. This option can receive as argument a dimension such as 1mm
, or the name of any coordinate inside the figure, such as a.center
, a.north
or even a.base
, which is the baseline of the text inside the node a
. Lets see these cases:
\parbox{6cm}{
\begin{itemize}
\item Default: \hrulefill\mypicture
\item 2mm: \hrulefill\mypicture[baseline=-2mm]
\item Center: \hrulefill\mypicture[baseline=(a.center)]
\item North: \hrulefill\mypicture[baseline=(a.north)]
\item Base: \hrulefill\mypicture[baseline=(a.base)]
\end{itemize}
}
Of course, in addition to use it "inline" you can put it anywhere you could put any other text, such as in a footnote, a marginal note, a table, or a figure environment (which would make it float). See it for example in a marginal note:
\marginpar{\mypicture[baseline=(a.base)]}
\lipsum[1]
\lipsum[2]
You can also use it in combinations with packages such as wrapfig
which
allows figures or tables to have text wrapped around them.
If you use tikz options remember picture
and overlay
, you can put it at any absolute position in the page, as the other answer shows.
\caption
outside a floating environment. Please fix it. Where exactly do you want the object to appear? In any case, you can use theremember picture,overlay options
and thecurrent page
node.