3

Why isn't the text wrapping correctly here?

code:

\documentclass{article}

\usepackage{tikz,amsmath,wrapfig,lipsum}

\setlength{\parindent}{0cm}
\setlength{\intextsep}{0pt}

\begin{document}

\lipsum[66]
\begin{wrapfigure}[12]{r}{4.5cm}
    \begin{tikzpicture}
        \fill (-1.1,-1.1) rectangle (3.3, 3.3);
    \end{tikzpicture}   
\end{wrapfigure}
\[\mathbf{u} = (u_1,0,0)=(u,0,0)=u\mathbf{i}\]

Nunc sed pede. Praesent vitae lectus. Praesent neque justo, vehicula.
\[\nabla\cdot\mathbf{u} = 0 \implies \frac{\partial u}{\partial x} + \frac{\partial 0}{\partial y} + \frac{\partial 0}{\partial z} = 0\]

\lipsum[1]

\end{document}

output:

enter image description here

  • 2
    I don't know why, but adding an empty line with \ before the first equation seems to solve this problem. – Benjamin Jan 10 '16 at 14:05
  • You should never start a paragraph with a display. – egreg Jan 10 '16 at 14:05
  • @egreg Can you explain why? – Benjamin Jan 10 '16 at 14:12
4

Starting a paragraph with a display is a sure source for bad output, particularly in connection with wrapfigure.

I guess your aim is to start the picture insertion down the paragraph; this can only be done with some manual work (in the final revision stage, of course).

One can add \nopar (defined in the code below) at the end of a suitable line, visually determined in a previous LaTeX run, insert the wrapfigure code and resume the paragraph.

Recall that every display is assumed to be three lines long, as far as the first optional argument to wrapfigure is concerned.

\documentclass{article}

\usepackage{tikz,amsmath,wrapfig,lipsum}

\setlength{\intextsep}{0pt}

\newcommand{\nopar}{{\parfillskip=0pt \par}}

\begin{document}

Nunc sed pede. Praesent vitae lectus. Praesent neque justo, vehicula eget, interdum id, facilisis et, 
nibh. Phasellus at purus et libero lacinia dictum. Fusce aliquet. Nulla eu ante placerat leo semper 
dictum. Mauris metus. Curabitur\nopar

\begin{wrapfigure}[11]{r}{4.5cm}
    \begin{tikzpicture}
        \fill (-1.1,-1.1) rectangle (3.3, 3.3);
    \end{tikzpicture}   
\end{wrapfigure}

\noindent
lobortis. Curabitur sollicitudin hendrerit nunc. Donec ultrices lacus id ipsum.
\[
\mathbf{u} = (u_1,0,0)=(u,0,0)=u\mathbf{i}
\]
Nunc sed pede. Praesent vitae lectus. Praesent neque justo, vehicula.
\[
\nabla\cdot\mathbf{u} = 0 \implies
  \frac{\partial u}{\partial x}
  + \frac{\partial 0}{\partial y}
  + \frac{\partial 0}{\partial z} = 0
\]
\lipsum[1]

\end{document}

enter image description here

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.