1

I am having a problem with wrapfig. For whatever reason, this figure has an obnoxiously large amount of blank space below it, even after using a negative \vspace and a small "number of narrow lines" parameter. And what's worse, one line that is supposed to be wrapped is not! Here is a picture.

some lines wrap and some don't, but I can't say why

I have no idea how to induce or isolate this bug—no nontrivial thing I've tried has helped—so my MWE is only as minimal as I know how to safely make it. This is part of a larger document, and the problem has come up before, but only now have I run out of ways to find a better place to put things.

\documentclass[letterpaper,oneside]{article}
\usepackage[margin=2.25cm]{geometry}
\usepackage{amsmath}
\usepackage{parskip}
\usepackage{wrapfig}

\newenvironment{exer}{\textit{Exercise}.\,}{\par}

\begin{document}

To reduce to the 3-connected case, first observe the easy reduction to the 
connected case: a matroid is graphic iff its components are. Then, consider a 
2-separation $(X,Y)$ of a binary $M = M(A)$. Since ${\sqcap}(X,Y) = 1$, there 
is a unique nonzero $v \in \mathrm{Col}(A|X) \cap \mathrm{Col}(A|Y)$. Define 
$M^+ = M([\,A~v\,])$ with $E(M^+) = E(M) \sqcup \{\bullet\}$. Then let $M_X = 
M^+ | (X \cup \{\bullet\})$ and $M_Y = M^+ | (Y \cup \{\bullet\})$. Up to row 
operations, $M^+$ has a representation of the form at right (where parts marked 
$\cdots$ are part of the nonzero submatrix above or below it).

\begin{wrapfigure}{r}[1em]{0.25\textwidth}
  \vspace{-4ex}
  \begin{center}
    $\begin{bmatrix} M_X\backslash\bullet & 0 & 0 \\
                     {\cdots} & 1 & {\cdots} \\
                     0 & 0 & M_Y\backslash\bullet \end{bmatrix}$
  \end{center}
  \vspace{-5ex}
\end{wrapfigure}

\begin{exer} Show that $M$ has an $M_X$-minor and an $M_Y$-minor. \end{exer}

\begin{exer} Show that $M$ is graphic iff $M_X$ and $M_Y$ are. \end{exer}

The existence of a sequence of minors beginning from a wheel is handled by 
Tutte's Wheels and Whirls---observe that whirls are not graphic, so if the 
sequence begins there, the matroid fails to be graphic.

Consider the inductive case where $M$ is a 3-connected binary matroid, and $M 
\backslash e = M(G)$ is 3-connected and graphic for some $e \in E(M)$. The 
incidence matrix of $G$ is a representation of $M \backslash e$, so we may 
suppose that the representation of $M$ is exactly that with a new vector $t$ 
appended representing $e$.

\end{document}

Is there an explanation for what is going wrong? What can I do to avoid this problem in the future?

  • 1
    The wrapfig package is very tricky. Here the problem is that its re-setting of \parshape remains in force even when it should be over: indeed, try adding more paragraphs after “…representing $e$”. This is probably due to the additional grouping level implied by the exer environment. Place a \leavevmode right before the first of these environments, and change \vspace{-5ex} to \vspace{-\baselineskip}. EDIT: Unrelated, but “…representing~$e$” is better! ;-) – GuM Jul 17 '15 at 22:41
  • No offence but the exer environment seems pretty useless to me. Why not just create a command for the beginning and leave a blank line at the end? (You're doing this anyway.) There's no need for an environment here - it just adds an additional complication. – cfr Jul 18 '15 at 1:57
  • @cfr For the sake of MWE, I've removed the definitions of all the other sections (theorems, etc.) some of which are styled differently, and are mutliple paragraphs long, ruling out something like \def\exer#1\par{blah}. – algorithmshark Jul 18 '15 at 14:45
3

First, you can save some space by using \centering. Second, giving wrapfig the number of lines saves uncertainty. Lastly and most important, \WFclear makes sure it stays dead.

BTW, if you reduce the number of lines to 1 and use \vspace(-6ex} you can reduce the space reserved even further. Just remember that the space of top just happened to be there.

WFclear

\documentclass[letterpaper,oneside]{article}
\usepackage[margin=2.25cm]{geometry}
\usepackage{amsmath}
\usepackage{parskip}
\usepackage{wrapfig}

\newenvironment{exer}{\textit{Exercise}.\,}{\par}

\begin{document}

To reduce to the 3-connected case, first observe the easy reduction to the 
connected case: a matroid is graphic iff its components are. Then, consider a 
2-separation $(X,Y)$ of a binary $M = M(A)$. Since ${\sqcap}(X,Y) = 1$, there 
is a unique nonzero $v \in \mathrm{Col}(A|X) \cap \mathrm{Col}(A|Y)$. Define 
$M^+ = M([\,A~v\,])$ with $E(M^+) = E(M) \sqcup \{\bullet\}$. Then let $M_X = 
M^+ | (X \cup \{\bullet\})$ and $M_Y = M^+ | (Y \cup \{\bullet\})$. Up to row 
operations, $M^+$ has a representation of the form at right (where parts marked 
$\cdots$ are part of the nonzero submatrix above or below it).

\begin{wrapfigure}[2]{r}[1em]{0.25\textwidth}
  \vspace{-4ex}
  \centering
    $\begin{bmatrix} M_X\backslash\bullet & 0 & 0 \\
                     {\cdots} & 1 & {\cdots} \\
                     0 & 0 & M_Y\backslash\bullet \end{bmatrix}$
\end{wrapfigure}

\begin{exer} Show that $M$ has an $M_X$-minor and an $M_Y$-minor. \end{exer}

\begin{exer} Show that $M$ is graphic iff $M_X$ and $M_Y$ are. \end{exer}

The existence of a sequence of minors beginning from a wheel is handled by 
Tutte's Wheels and Whirls---observe that whirls are not graphic, so if the 
sequence begins there, the matroid fails to be graphic.
\WFclear

Consider the inductive case where $M$ is a 3-connected binary matroid, and 
$M \backslash e = M(G)$ is 3-connected and graphic for some $e \in E(M)$. The 
incidence matrix of $G$ is a representation of $M \backslash e$, so we may 
suppose that the representation of $M$ is exactly that with a new vector $t$ 
appended representing $e$.

\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.