0

I had the same problem as in LINK. The question is about using \endgroup somewhere. If I use the following code

\usepackage[a4paper,hmargin=1in,top=1.2in,bottom=1in]{geometry}
\usepackage{lipsum}
\usepackage{wrapfig} 
\usepackage{pgfplots}
\pgfplotsset{width=10cm,compat=1.9}

\begin{document}

\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{r}{0pt}
\begin{tikzpicture}[scale=0.5]
\draw[step=1cm,very thin] (0,0) grid (13,8);
\end{tikzpicture}
\end{wrapfigure}
\noindent \lipsum[1]
\endgroup

\end{document}

it would look like this picture Test1

However, if I add an empty line after \lipsum[1]

(... like above)
\noindent \lipsum[1]

\endgroup

\end{document}

it would look like this picture Test2

Why is there a difference in the code? If I replace this empty line with \\, \newline or even \hfill \break, none changes. What does this ''empty line'' in grouping mean? Is there other way to fill this empty line to make the code work as in the second picture?

6
  • You should not use wrapfig in a group or if you do, as you show, make sure the paragraph ends before the group ends. Commented Nov 20, 2022 at 21:41
  • @DavidCarlisle The only reason I used group is \setlength\intextsep{0pt} to move the figure a little bit up, only for this figure without affecting other future figures. I followed similar method in link about grouping
    – UnknownW
    Commented Nov 20, 2022 at 21:44
  • just us a vspace, wrapfig says If you put a wrapfigure in a parbox or a minipage, or any other type of grouping, the text wrapping should end before the group does. So if you have the group you must end the paragraph with blank line before endgroup, and even then it may not work ` Commented Nov 20, 2022 at 21:46
  • @DavidCarlisle Sorry, I don't understand what you meant by vspace. Where should I write it? If I remove begingroup and endgroup, and move the \setlength\intextsep{0pt} in the premable, everything works as I wanted. But it would mean that all other figures would be affected by this code as well
    – UnknownW
    Commented Nov 20, 2022 at 21:52
  • begin{wrapfigure}{r}{0pt}\vspace{-10pt}\begin{tik... Commented Nov 20, 2022 at 21:56

0

You must log in to answer this question.

Browse other questions tagged .