10

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)$
]
\addplot{sin(deg(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}
3
  • 3
    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 '13 at 17:51
  • 1
    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. – Alexander Jul 23 '13 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. – Jeel Shah Jul 23 '13 at 23:49
9

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.

enter image description here

\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)$
]
\addplot{sin(deg(x))};
\end{axis}
\end{tikzpicture}
\end{wrapfigure}

\noindent 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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.