# How to write content next to tikz figures?

This is my code :

\begin{document}

Formally, a streaming string transducer is a 8-tuple $(Q,\Sigma_1,\Sigma_2,X,F,\delta,\gamma,q_0)$ machine, where
$Q$ is a finite set of states, $\Sigma_1$ is a finite set of input symbols, $\Sigma_2$ is a finite set of output symbols,
$X$ is a finite set of string variables,  $F$ is a partial output function from $Q$ to $(\Sigma_2 \cup X)^*$ with constraint of copyless assignment,
$\delta$ is a state transition function from $(Q \times \Sigma_1)$ to $Q$,
$\gamma$ is a variable update function from $(Q \times \Sigma_1 \times X)$ to $(\Sigma_2 \cup X)^*$ using copyless assignments and $q_0 \in Q$ is an initial state.

\begin{figure}
\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 0.5, transform shape]
%  \tikzstyle{every state}=[fill=white,draw=none,text=black]

\node[initial,state] (A)                                    {$s_0$};
\node[state]         (B) [right of=A]               {$s_1$};

\path[->] (A) edge [bend left]      node [align=center]         {$a \rightarrow$ $[x = x.a, y = a.y]$\\$b \rightarrow$ $[x = x.b, y = b.y]$} (B)
(B) edge [bend left]        node [align=center]             {$a \rightarrow$ $[x = x.a, y = a.y]$\\$b \rightarrow$ $[x = x.b, y = b.y]$} (A);

\end{tikzpicture}
\caption{An example of SST}
\end{figure}

\begin{tikzpicture}[>=stealth',shorten >=1pt,auto,node distance=5 cm, scale = 0.5, transform shape]
%  \tikzstyle{every state}=[fill=white,draw=none,text=black]

\node[initial,state] (A)                                   {$s_0$};
\node[state]         (B) [right of=A]              {$s_1$};

\path[->] (A) edge [bend left]         node [align=center]         {$a \rightarrow$ $[x = x.a, y = a.y]$\\$b \rightarrow$ $[x = x.b, y = b.y]$} (B)
(B) edge [bend left]        node [align=center]             {$a \rightarrow$ $[x = x.a, y = a.y]$\\$b \rightarrow$ $[x = x.b, y = b.y]$} (A);

\end{tikzpicture}

The semantics of a DSST is defined in terms of the summary of a computation of a DSST. Summaries are of the form
$(q, s)$ where $q$ is a state and $s$ is valuation from $X$ to $\Sigma_2^*$ that can be extended to a valuation from $(\Sigma_2 \cup X)^*$ to
$\Sigma_2^*$. Initially each variable maps to the empty string. The transition function is defined by
$\psi((q,s),a) = (\delta(q,a), s')$ and for each variable $x$, $s'(x)$ =  $s(\gamma(q,a,x))$. For an input
string $w \in \Sigma_1^*$, if $\psi^*((q_0,s_0),w) = (q, s)$, then if  $F(q)$ is defined then output string will
be $s(F(q))$ otherwise it will be undefined.

\end{document}


So how do I put the content next to tikzpicture?

-
Do you want that the text wraps around the figure? If yes, you need the wrapfig package. –  Spike Jun 16 '12 at 13:38

I’m not sure want you want. So I give two solutions …

## Text flows around an image

Use the wrapfig package to make the normal text flow around an image. Use the {wrapfig} environment instead of a {figure}. It needs two arguments the first on is the vertical position which is either left, right, inner or outer. The second one gives the width of the image.

\documentclass[english]{scrartcl}

\usepackage{tikz}
\usepackage{wrapfig}

% demo
\usepackage{babel}
\usepackage{blindtext}

\begin{document}
\blindtext
\begin{wrapfigure}{l}{6cm}
\begin{tikzpicture}
\fill [blue] (0,0) rectangle (6,4);
\end{tikzpicture}
\end{wrapfigure}
\blindtext[2]
\end{document}


## Text beside an image

To position a text beside an image use a {minipage} to align it. For that you must place two {minipage} in your {figure}. The environment takes on argument setting the width. WIth the calc package you can us things like \textwidth-7cm etc. Furthermor you can use an optional argument which is either top, centered or bottom determining the horizontal position relative to the base line.

\documentclass[english]{scrartcl}

\usepackage{tikz}
\usepackage{calc}

% demo
\usepackage{babel}
\usepackage{blindtext}

\begin{document}
\blindtext
\begin{figure}
\begin{minipage}[c]{7cm}
\begin{tikzpicture}
\fill [blue] (0,0) rectangle (6,4);
\end{tikzpicture}
\end{minipage}%
\begin{minipage}[c]{\textwidth-7cm}
Some text describing the image.
Some text describing the image.
Some text describing the image.
\end{minipage}
\end{figure}
\blindtext[2]
\end{document}


-
Thanks a lot :) –  tikzlearner Jun 16 '12 at 14:04

picins is another solution. You can find the package here : picins on ctan. It's not on texlive (I suppose a problem of licence). It's an old package but it's a very fine package. It's very well documented in laTeX Companion.

\documentclass{article}
\usepackage{tikz,picins}
\usepackage{lipsum,fancyvrb}
\DefineShortVerb{\|}
\begin{document}

{\bfseries An attempt with the macro  |\parpic| of the package  |picins| }

\lipsum[1]
\parpic{\tikz \draw (0,0) -- (5,5);}
\lipsum[1]
\end{document}


-
What would be the advantage of using picins as compared to wrapfig? –  mSSM Jun 16 '12 at 17:40
Picins works inside environment of lists like itemize at any level. Perhaps now wrapfig can do that too. See tex.stackexchange.com/questions/tagged/wrapfigure –  Alain Matthes Jun 16 '12 at 19:21