# How can I make tikzpicture flow smoothly around text?

I have a problem when I use tikzpicture and wrapfigure. The main issue is that when using the third parameter, the "distance" becomes arbitary. For example, I am using 9cm but what is the correct way to do it? Because, currently, the text looks out of place and not aligned.

\documentclass{article}
\usepackage{pgfplots}
\usepackage{graphicx}
\usepackage{wrapfig}

\begin{document}

Whenever we deal with integration, we come across the constant of integration $C$. Suppose we have the following graph of $f(x) = \sin x$.

\begin{wrapfigure}{l}{9cm}
\begin{tikzpicture}
\begin{axis}[
xlabel = $x$,
ylabel = $f(x)$
]
\end{axis}
\end{tikzpicture}
\end{wrapfigure}

The primary reason for doing integration is to be able to solve differential equations.

\begin{quote}
some random text goes here and other cool stuff.
\end{quote}

\end{document}

• Instead of using 9cm, use 0pt, then the natural width of the wrapfigure will be used to align the surrounding text. It may also look weird to have an indent in the first line, so adding \noindent The primary... makes it look a little less weird.
– Werner
Jul 23, 2013 at 17:51
• If your figure is more than 3/4 of the text width I would not wrap the text around it but center it and let it float. For smaller figures Werner's comment is spot on. You can shrink the plot for example by using the width=6cm argument to the axis environment. Jul 23, 2013 at 17:57
• Thanks for the answers! If one of you would like to post one as an answer so I can accept it, that would be great. Jul 23, 2013 at 23:49

Instead of using 9cm, use 0pt, then the natural width of the wrapfigure will be used to align the surrounding text. It may also look weird to have an indent in the first line, so adding \noindent The primary... makes it look a little less weird.

\documentclass{article}
\usepackage{pgfplots,wrapfig}

\begin{document}

Whenever we deal with integration, we come across the constant of integration $C$. Suppose we have the following graph of $f(x) = \sin x$.

\begin{wrapfigure}{l}{0pt}
\begin{tikzpicture}
\begin{axis}[
xlabel = $x$,
ylabel = $f(x)$
]