7

Related questions:

Wrap figure vertical alignment of text

Too much space around wrap figure

wrapfigure environment vspace above figure

Aligning graphics within wrapfigure

Why is my custom wrapfig environment messed up? and its follow-up question wrapfig vs intextsep

In the questions mentioned above, several solutions are offered to eliminate the whitespace inserted above wrapfigure environments. The most obvious way is to set \intextsep to zero globally. Unfortunately that also affects the spacing around normal figures, which look rather terrible with 0 padding.

The new environment defined in Why is my custom wrapfig environment messed up? does not solve that problem, as was already pointed out in the follow-up question.

Now neither \begingroup or {\setlength{\intextsep}\begin{wrapfigure}...} (as suggested in the follow-up) work well for me, as I am using wrapfigures right above \paragraph{} most of the time which produces errors. Additionally, I am using a lot of itemized lists, as I'm mainly using TeX to write lecture notes / summaries, reducing as much text as possible to keypoints. So these solutions would generate a set of new problems, which I'd like to avoid.

The solution of using \vspace{-\baselineskip} is how I've dealt with the issue up until now. Although that does work, it is a pain to add it to every wrapfigure. The option of inserting the vspace into the wrapfigure directly is also subpoptimal, as the images vary in size and ratio quite drastically. Additionally, vspace is ignored if the width of the wrapfigure is specified as {0} (automatic sizing to image / tabular width).

So I've come to the (potentially wrong) conclusion, that the best option would be to set \intextsep to zero globally but only for wrapfigures (not figures). Unfortunately, I wasn't able to find any answer that explained how I could achieve this.

Is there any way to do this - adjusting \intextsep only for wrapfigures?

I'll add a MWE copied from one of my summaries, in case that helps:

\documentclass[11pt,a4paper]{article}
\usepackage[headheight=13.6pt,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage{quoting,polyglossia}
    \setmainlanguage[spelling=new]{german}

\usepackage{unicode-math}
    \setmathfont{xits-math.otf}

\usepackage{multirow,
            tabularx,booktabs,array,
            multicol,
            wrapfig,float,subcaption}
        \setlength{\multicolsep}{3.0pt plus 2.0pt minus 1.5pt}
        \setlength{\floatsep}{0.0pt plus 2.0pt minus 2.0pt} %default: \setlength{\floatsep}{12.0pt plus 2.0pt minus 2.0pt} 
        \setlength{\textfloatsep}{0.0pt plus 2.0pt minus 4.0pt} %default: \setlength{\textfloatsep}{20.0pt plus 2.0pt minus 4.0pt} 
        \setlength{\intextsep}{0.0pt plus 2.0pt minus 2.0pt} %default: \setlength{\intextsep}{12.0pt plus 2.0pt minus 2.0pt}

    \usepackage[skip=2pt,figurename=Abb.,tablename=Tab.]{caption}
        \usepackage[export]{adjustbox}
            \captionsetup[figure]{font=footnotesize,labelfont=it}
                \captionsetup[subfigure]{skip=2pt,font=scriptsize,labelfont=it}

\usepackage[compact]{titlesec}

\usepackage[inline]{enumitem}
    \setitemize{noitemsep,topsep=2pt,parsep=0pt,partopsep=2pt,leftmargin=*}
\setenumerate{noitemsep,topsep=2pt,parsep=0pt,partopsep=2pt,leftmargin=*}

\newcommand{\arr}{$\rightarrow{}$}

\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[frame,width=0.92\linewidth]{Path2-Pictures/3-6.png}
\caption{Basissymptome nach Kolsterkötter, 1992; 2012}
   %\vspace{-0.5\baselineskip}  --> a vspace I inserted before I set \intextsep to 0; this figure still has sufficient padding (why is unclear to me though)
\end{figure}
Diese Rückkehrhemmung ist bei Schizophrenen gestört \arr Aachen-Studien mit Covert Orienting of Attention Task; Gouzoulis-Mayfrank (2004, 2006, 2007): Gemessen wurde die RT beim Auffinden bestimmter Objekte an der alten Position \arr Schizophrene sind \emph{schneller} 

Interpretation: Schizophrene können verschiedene Filter nicht anwenden, weshalb sie immer wieder auf basale Information zurückkehren müssen \arr Rückkehrhemmung bei Schizophrenen

\begin{wrapfigure}[7]{r}{0.3\textwidth}
   %\vspace{-\baselineskip}   --> this wrapfigure is now where I want it with \intextsep 0
\centering
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-8.png}
\caption{Moritz, 2006}
\end{wrapfigure}
\paragraph{Gedächtnisfehler \& Korrektheitskonfidenz} Studie von Moritz (2006): Bild wird gezeigt, dann entfernt; Frage: Erinnern sie sich an ...? Wie sicher sind sie sich?
\begin{itemize}
\item Gesunde Kontrollen waren sich nicht signifikant sicherer bei korrekten Antworten \arr gesehene Objekte erkennen bzw. nicht gesehene als solche bezeichnen
\item Schizophrene Patienten sind sich viel sicherer, wenn die Antwort \emph{inkorrekt ist} \arr signifikanter Unterschied
    \begin{itemize}
    \item Falsche Korrektheitskonfidenz \arr Gedächtnisfehler
    \item Alles Nicht-Wahn Inhalte in Studie
    \end{itemize}
\end{itemize}

\subsubsection{Basissymptome als Verlaufstest}
\paragraph{Hypothese:} Overinclusion als "symptomnahe Basisstörung" ist bei akuter Psychose besonders ausgeprägt \& wird im Verlauf schwächer \arr \textbf{Overinclusion:} Irrelevante Konzept-Merkmale werden integriert \arr Übereinschluss in Konzepte; Begriffe, Sachverhalte, Figuren, Schemata. 
   %\vspace{-0.8\baselineskip}  --> this figure now is way too close to the text above with \intextsep 0
\begin{figure}[hb]
\begin{subfigure}{0.52\linewidth}
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-11.png}
\caption{Maercker, 1987; Kawohl, 2010}
\end{subfigure}
\begin{subfigure}{0.47\linewidth}
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-12.png}
\caption{Maercker, 1987; Kawohl, 2010}
\end{subfigure}
\end{figure}

\end{document}

Which compiles as:

enter image description here

Note: I'm using XeLaTeX, if that makes any difference.

2 Answers 2

7

One way to set the \intextsep globally, but only for the wrap figure environemnt would be to use \BeforeBeginEnvironment from the etoolbox package.

\usepackage{etoolbox}
\BeforeBeginEnvironment{wrapfigure}{\setlength{\intextsep}{0pt}}

The before

enter image description here

and after the \BeforeBeginEnvironment is applied:

enter image description here

Notes:

  • In the MWE below I commented out your manual adjustment to \setlength{\intextsep}{0.0pt plus 2.0pt minus 2.0pt}.
  • You can uncomment the \showthe\intextsep to see the effect.
  • The demo option was used on the graphicx package as I don't have the figures you were including.

Code:

\documentclass[11pt,a4paper]{article}
\usepackage[headheight=13.6pt,left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}

\usepackage[demo]{graphicx}
\usepackage{etoolbox}
\BeforeBeginEnvironment{wrapfigure}{\setlength{\intextsep}{0pt}}


\usepackage{quoting,polyglossia}
    \setmainlanguage[spelling=new]{german}

\usepackage{unicode-math}
    \setmathfont{xits-math.otf}

\usepackage{multirow,
            tabularx,booktabs,array,
            multicol,
            wrapfig,float,subcaption}
        \setlength{\multicolsep}{3.0pt plus 2.0pt minus 1.5pt}
        \setlength{\floatsep}{0.0pt plus 2.0pt minus 2.0pt} %default: \setlength{\floatsep}{12.0pt plus 2.0pt minus 2.0pt} 
        \setlength{\textfloatsep}{0.0pt plus 2.0pt minus 4.0pt} %default: \setlength{\textfloatsep}{20.0pt plus 2.0pt minus 4.0pt} 
        %\setlength{\intextsep}{0.0pt plus 2.0pt minus 2.0pt} %default: \setlength{\intextsep}{12.0pt plus 2.0pt minus 2.0pt}

    \usepackage[skip=2pt,figurename=Abb.,tablename=Tab.]{caption}
        \usepackage[export]{adjustbox}
            \captionsetup[figure]{font=footnotesize,labelfont=it}
                \captionsetup[subfigure]{skip=2pt,font=scriptsize,labelfont=it}

\usepackage[compact]{titlesec}

\usepackage[inline]{enumitem}
    \setitemize{noitemsep,topsep=2pt,parsep=0pt,partopsep=2pt,leftmargin=*}
\setenumerate{noitemsep,topsep=2pt,parsep=0pt,partopsep=2pt,leftmargin=*}

\newcommand{\arr}{$\rightarrow{}$}

\begin{document}
\begin{figure}[ht]
\centering
\includegraphics[frame,width=0.92\linewidth]{Path2-Pictures/3-6.png}
\caption{Basissymptome nach Kolsterkötter, 1992; 2012}
   %\vspace{-0.5\baselineskip}  --> a vspace I inserted before I set \intextsep to 0; this figure still has sufficient padding (why is unclear to me though)
\end{figure}
Diese Rückkehrhemmung ist bei Schizophrenen gestört \arr Aachen-Studien mit Covert Orienting of Attention Task; Gouzoulis-Mayfrank (2004, 2006, 2007): Gemessen wurde die RT beim Auffinden bestimmter Objekte an der alten Position \arr Schizophrene sind \emph{schneller} 

Interpretation: Schizophrene können verschiedene Filter nicht anwenden, weshalb sie immer wieder auf basale Information zurückkehren müssen \arr Rückkehrhemmung bei Schizophrenen

\begin{wrapfigure}[7]{r}{0.3\textwidth}
   %\vspace{-\baselineskip}   --> this wrapfigure is now where I want it with \intextsep 0
\centering
%\showthe\intextsep% <-- uncomment to see the change
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-8.png}
\caption{Moritz, 2006}
\end{wrapfigure}
\paragraph{Gedächtnisfehler \& Korrektheitskonfidenz} Studie von Moritz (2006): Bild wird gezeigt, dann entfernt; Frage: Erinnern sie sich an ...? Wie sicher sind sie sich?
\begin{itemize}
\item Gesunde Kontrollen waren sich nicht signifikant sicherer bei korrekten Antworten \arr gesehene Objekte erkennen bzw. nicht gesehene als solche bezeichnen
\item Schizophrene Patienten sind sich viel sicherer, wenn die Antwort \emph{inkorrekt ist} \arr signifikanter Unterschied
    \begin{itemize}
    \item Falsche Korrektheitskonfidenz \arr Gedächtnisfehler
    \item Alles Nicht-Wahn Inhalte in Studie
    \end{itemize}
\end{itemize}

\subsubsection{Basissymptome als Verlaufstest}
\paragraph{Hypothese:} Overinclusion als "symptomnahe Basisstörung" ist bei akuter Psychose besonders ausgeprägt \& wird im Verlauf schwächer \arr \textbf{Overinclusion:} Irrelevante Konzept-Merkmale werden integriert \arr Übereinschluss in Konzepte; Begriffe, Sachverhalte, Figuren, Schemata. 
   %\vspace{-0.8\baselineskip}  --> this figure now is way too close to the text above with \intextsep 0
\begin{figure}[hb]
\begin{subfigure}{0.52\linewidth}
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-11.png}
\caption{Maercker, 1987; Kawohl, 2010}
\end{subfigure}
\begin{subfigure}{0.47\linewidth}
\includegraphics[frame,width=0.99\linewidth]{Path2-Pictures/3-12.png}
\caption{Maercker, 1987; Kawohl, 2010}
\end{subfigure}
\end{figure}

\end{document}
7
  • 1
    You are my personal hero! :D Jul 26, 2018 at 2:15
  • 2
    It does not work though: once set, it remains to this value until the document end. So subsequent figures are affected… At least that’s what I see in my document (I’ve tried the above one but the figure at the end are on the next page).
    – Archange
    Nov 30, 2022 at 22:38
  • @Archange: If you don't want it document wide, then apply the setlenght setting only before the reqiured figure: {\setlength{\intextsep}{0pt}% (note leading {), followed by \begin{wrapfigure} ... \end{wrapfigure}} (note extra trailing {). The additional { and } create a group and keep your change to \intextsep local to that group. Nov 30, 2022 at 22:54
  • I want it document wide for wrapfigure, but not for figure. Currently after the first wrapfigure (well actually right before it of course), intextsep is set to 0 globally, and does affect subsequent figure.
    – Archange
    Dec 1, 2022 at 8:32
  • @Archange: Sorry an busy next few days, so can't look at this issue right now. Please post a new question. It will be helpful if you include a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. Dec 1, 2022 at 19:06
0

In an answer on a separate question (which includes an example), @Ulrike Fischer suggested the following code for the preamble which avoids setting intextsep globally and thereby avoids changing spacing on normal figures.

\usepackage{wrapfig}
\usepackage{etoolbox}
\makeatletter
\patchcmd\WF@putfigmaybe{\lower\intextsep}{}{}{\fail}%
\AddToHook{env/wrapfigure/begin}{\setlength{\intextsep}{0pt}}
\makeatother

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .