3

It happens when a wrapfigure is placed (by the system, not by myself) beside an ExSheets question.

This is a minimal working example:

\documentclass[a4paper,10pt]{book}

\usepackage{fontspec}
\usepackage{mdframed}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{wrapfig}
\usepackage{exsheets}
\usepackage{lipsum}

\mdfdefinestyle{noteSty}{backgroundcolor=gray!10, linewidth=0pt, innerleftmargin=1ex, innerrightmargin=1ex, innertopmargin=1ex, innerbottommargin=1ex, innermargin = 0.1cm, outermargin = 0.1cm}

\newcounter{noteCounter}[chapter]
\numberwithin{noteCounter}{chapter}
\newmdtheoremenv[style=noteSty]{note}[noteCounter]{Note}

\SetupExSheets{
  headings          = block-subtitle ,
  subtitle-format   = \sc ,
  counter-within    = {chapter} ,
  counter-format    = ch.qu[1] ,
  label-format      = ch.qu[1] ,
  headings-format   = \bfseries ,
  question/pre-hook = \vspace{1ex} ,
  question/post-hook = \vspace{1ex} ,
  question/pre-body-hook = {\vspace{1ex} \mdframed[innermargin=+1cm,outermargin=+1cm]},
  question/post-body-hook = \endmdframed
}

\begin{document}

\lipsum[1-2]

\begin{wrapfigure}{r}{0.6\linewidth}
  \begin{note}{Lorem ipsum}
    \lipsum[3]
  \end{note}
\end{wrapfigure}

\begin{figure}
  \includegraphics[width=0.9\linewidth]{lipsum.jpg}
  \caption{dolor sit amet}
  \label{fig:lipsum}
\end{figure}

\begin{question}
  \lipsum[66]
\end{question}

\lipsum[6-7]

\end{document}

This is the dummy image I use in it (in case you want to compile it as is):

Dummy picture.

This is how the second page appears to me:

Blank column below wrapfigure until end of chapter.

I'm using Overleaf with LuaLaTex.

The question below is similar to this, but I can't related them in a productive way.

White space in subsequent pages after wrapfigure

  • wrapfig is often causing trouble and you always need to adjust by hand. There might be better ways to achieve what you want. – Johannes_B Dec 19 '15 at 16:47
  • 2
    most likely the exsheets thing is a list environment internally. The one instruction in the wrapfig documentation is : don't use near lists. – David Carlisle Dec 19 '15 at 16:56
  • It also will go wrong near page breaks, section headings etc. And you need to make sure that there is sufficient stuff to wrap the figure right after it. In your example, there isn't. (The next thing is a float and the thing afterwards is presumably a list.) – cfr Dec 19 '15 at 22:42
  • It is definitely the question environment which causes the problem. Since this is expected, I think you either have to rethink your design or think about another way of implementing it. – cfr Dec 19 '15 at 22:51

1 Answers1

1

The figure has no relevance, but it is nice to prove that. You can put both the exercise and the note inside minipages. I put the minipages inside \fboxes to illustrate the actual sizes. Then I overlapped the next paragraph with the unused space.

\documentclass[a4paper,10pt]{book}

%\usepackage{fontspec}
\usepackage{mdframed}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{wrapfig}
\usepackage{exsheets}
\usepackage{lipsum}
\usepackage{showframe}

\mdfdefinestyle{noteSty}{backgroundcolor=gray!10, linewidth=0pt, innerleftmargin=1ex, innerrightmargin=1ex, innertopmargin=1ex, innerbottommargin=1ex, innermargin = 0.1cm, outermargin = 0.1cm}

\newcounter{noteCounter}[chapter]
\numberwithin{noteCounter}{chapter}
\newmdtheoremenv[style=noteSty]{note}[noteCounter]{Note}

\SetupExSheets{
  headings          = block-subtitle ,
  subtitle-format   = \sc ,
  counter-within    = {chapter} ,
  counter-format    = ch.qu[1] ,
  label-format      = ch.qu[1] ,
  headings-format   = \bfseries ,
  question/pre-hook = \vspace{1ex} ,
  question/post-hook = \vspace{1ex} ,
  question/pre-body-hook = {\vspace{1ex} \mdframed[innermargin=+1cm,outermargin=+1cm]},
  question/post-body-hook = \endmdframed
}

\begin{document}

\lipsum[1-2]

\begin{figure}
  \includegraphics[width=0.9\linewidth]{example-image}
  \caption{dolor sit amet}
  \label{fig:lipsum}
\end{figure}

\fboxsep=0pt
\noindent\fbox{\begin{minipage}[t]{0.5\textwidth}
\begin{question}
  \lipsum[66]
\end{question}
\end{minipage}}\hfill\fbox{\begin{minipage}[t]{0.5\textwidth}
\begin{note}{Lorem ipsum}
    \lipsum[3]
  \end{note}
\end{minipage}}
\vspace{-2\baselineskip}% overlap minipages

\hangindent=-0.55\textwidth
\hangafter=-2
\lipsum[6-7]

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • The problem with that solution is that the question is beside the note by construction. On the other hand, wrapfigures float through the text and only incidentally they get beside a question. I would like to keep that feature of wrapfigures. – Leonardo Castro Dec 20 '15 at 17:33
  • I've just accepted this answer because it shows a solution, although I've just decided to put Wrapfig figures, ExSheets questions and plain figures always separated by a large amount of text. – Leonardo Castro Jan 05 '16 at 14:42