0

I'm creating some custom environments. One of them will be placed in \wrapfigure and second one will contain text which should wrap around the first one.

When I'm adding \vspace between paragraphs, blank space under \wrapfiture environment gets higher.

Is there any way of removing this blank space?

I can't specify exact number of lines that \wrapfigure will take, because it can vary.I would like to be able to configure space between parahraphs in my second environment.

Below I prepared MWE of text without \vspace and with \vspace:

\documentclass[a4paper,10pt]{article}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
    \begin{wrapfigure}{l}{0.29\linewidth}
        \begin{enumerate}
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
        \end{enumerate}
    \end{wrapfigure}
    \blindtext[1]\\

    \blindtext[1]\\

    \blindtext[1]
\end{document}

enter image description here

\documentclass[a4paper,10pt]{article}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
    \begin{wrapfigure}{l}{0.29\linewidth}
        \begin{enumerate}
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
        \end{enumerate}
    \end{wrapfigure}
    \blindtext[1]\\
    \vspace{50pt}
    \blindtext[1]\\
    \vspace{50pt}
    \blindtext[1]
\end{document}

enter image description here

New contributor
Alek N is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
  • I developed a \wrapspacer macro (see tex.stackexchange.com/questions/390520/…) for this problem (more or less). The usual approach is to manually tell wrapfigure how many lines of text to wrap. – John Kormylo Dec 3 at 20:57
  • \blindtext[1]\\ is simply wrong, never use \\ at the end of a paragraph it generates warnings and makes very poor output. Or here you are not ending the paragraph at all, but simply inserting space between lines of the same pararaph. – David Carlisle Dec 3 at 21:22
0

Your example text, outside the wrapfig only had a single paragraph, with vertical space inserted between the lines. That is hard to catch (and using vspace mid-paragraph has slightly strange effects, it is almost always better to finish the paragraph with a blank line before adding space.

Here I locally set the paragraph spacing to 50pt, and adjust wrapfig so that each paragraph end counts as an additional 4 lines (actually 5 lines gets better spacing here but 5*12 being 60 > 50 would mean actually you are over compensating and could result in not enough space being left. 12pt being the default baseline space here.)

\documentclass[a4paper,10pt]{article}
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}

\begingroup
\makeatletter
\setlength\parskip{50pt}
\def\WF@mypar{\relax
 \WF@@par % what the rest of LaTeX expects \par to be (usually \@@par)
 \ifnum\@@parshape=\z@ \let\WF@pspars\@empty \fi % reset `parshape'
 \global\advance\c@WF@wrappedlines-\prevgraf \prevgraf\z@
 \global\advance\c@WF@wrappedlines-4
 \ifnum\c@WF@wrappedlines<\tw@ \WF@finale \fi}


    \begin{wrapfigure}{l}{0.29\linewidth}

        \begin{enumerate}
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
            \item Test item
        \end{enumerate}
    \end{wrapfigure}
    \blindtext[1]

    \blindtext[1]


    \blindtext[1]

\endgroup

\end{document}

enter image description here

Your Answer

Alek N is a new contributor. Be nice, and check out our Code of Conduct.

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.