3

Here's what I've currently got.

\documentclass{report}

\usepackage{graphicx}
\usepackage{wrapfig}

\begin{document}
  \begin{wrapfigure}[5]{r}{0.4\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{A \textbf{ducking} duck!}
  \end{wrapfigure}

  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
  kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
  ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
  vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
  gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
  dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
  invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
  eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
  sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}

Here's the output:

enter image description here

Here's what I want:

enter image description here

I know I can use \vspace{}, but is there a parameter that I can add to wrapfigure itself to add some spacing after 5 lines or something?

5
  • 1
    you are forcing only 5 lines are cut out [5] add start a new paragraph and vspace before Stet if you want a paragraph there Commented Oct 14, 2022 at 21:37
  • You could place text next to figure using minipage. There's plenty of posts here, e.g. this one
    – Celdor
    Commented Oct 15, 2022 at 8:36
  • @Celdor yes I did wonder if the OP should not be using wrapfig at all. Using wrapfig while preventing wrapping does seem a strange requirement Commented Oct 15, 2022 at 9:06
  • See also \wrapfill from tex.stackexchange.com/questions/526518/… Commented Oct 15, 2022 at 13:59
  • How do you want TeX to know where in line 5 it should break things? I don't see any indication in the source file. After the first period seems like it would be hard to figure out.
    – Teepeemm
    Commented Oct 18, 2022 at 14:10

2 Answers 2

4

If you only want a 5 line paragraph and then clear to the next paragraph, you can simply vspace:

enter image description here

\documentclass{report}

\usepackage{graphicx}
\usepackage{wrapfig}

\begin{document}
  \begin{wrapfigure}[5]{r}{0.4\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{A \textbf{ducking} duck!}
  \end{wrapfigure}

  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua. At vero eos et accusam et justo duo dolores et ea rebum. 


\vspace{4\baselineskip}
  Stet clita
  kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
  ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
  vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
  gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
  dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
  invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
  eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
  sea takimata sanctus est Lorem ipsum dolor sit amet.
\end{document}
6
  • I know I can use vspace, but I was wondering if there was any extra parameter I can pass to wrapfigure to add some extra space after it's done wrapping around the given text because throughout a ton of my notes, I'm always modifying the vspace because I'm modifying the text, image size, etc. Commented Oct 15, 2022 at 0:18
  • @SingularisArt you know the size of the figure you are adding and you know that you are (for some reason??) preventing wrapfig from wrapping by restricting it to 5 lines so you could pre-calculate how many baselineskip you need in the vspace to compensate for using [5] Commented Oct 15, 2022 at 7:12
  • But is there a way other than using vspace, like a custom command that will add spacing until the end of the image, and a little space after? Commented Oct 15, 2022 at 20:19
  • @SingularisArt the image is entred before the paragraph, and the space needs to go after, so it isn't easy to connect them or in general to know where [5] came from. If you do not want the paragraph to wrap around the figure and revert to full width why use wrapfig at all? You only need the space adding as you have [5] and as that appears to be a manual choice, it seems natural to add the compensating vspace at the same time Commented Oct 15, 2022 at 20:27
  • Oh. do you have any links or something so I can read more about how wrapfigure works, because I'm starting to see that I know nothing about it? I read the documentation for wrapfigure (which wasn't that big), and that's it. Anyway, thanks for your help and explanation! Commented Oct 15, 2022 at 20:29
0

wrapfig2 package computes the number of lines needed to fit in the wrapped figure/table/text:

a wrapped figure

If the computation is not successful and so requires a correction, a starred version of the environment is available (see the documentation).

Wrapping requires a suitably long text. However, if the text is short, the task of wrapping is given to the following paragraph.

fig2

MWE

\documentclass{report}

\usepackage{graphicx}
\usepackage{wrapfig2}

\begin{document}
  \begin{wrapfigure}{r}{0.4\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{A \textbf{ducking} duck!}
  \end{wrapfigure}

  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita
  kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
  ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
  vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
  gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
  dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
  invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
  eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
  sea takimata sanctus est Lorem ipsum dolor sit amet.


  \begin{wrapfigure}{r}{0.4\linewidth}
    \centering
    \includegraphics[width=\linewidth]{example-image-duck}
    \caption{A \textbf{ducking} duck!}
  \end{wrapfigure}

  Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy
  eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam
  voluptua. At vero eos et accusam et justo duo dolores et ea rebum. 
  
  Stet clita
  kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem
  ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod
  tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At
  vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd
  gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum
  dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor
  invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero
  eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no
  sea takimata sanctus est Lorem ipsum dolor sit amet.


\end{document}

If no wrapping is needed (and therefore no caption?, with the text being a taken as a description, if I understand correctly):

Here is one method using tabularray:

image plus description

MWE

\documentclass{article}

\usepackage{tabularray}

\usepackage{xcolor}
\usepackage{graphicx}

\usepackage{tikz}

\usepackage{tcolorbox}
\tcbuselibrary{vignette}







\newcommand\texta{The cat sat on the mat and the quick brown fox jumps over the lazy dog.\ }
\newcommand\textb{\texta\texta}
\newcommand\textc{\textb\textb}
\newcommand\textd{\textc\textc\textc\hfill$\diamondsuit$\par\textb}


\begin{document}


%\fbox{
\begin{tblr}{
rows = {bg=yellow!50!red!5},
colspec={Q[l,h,0.5\textwidth]Q[c,blue!32]},}
tcolorbox vignette image, small amount of text \texta
&
\begin{tikzpicture}%
\node[draw,fill=blue!60] (A) {{\sffamily\large\bfseries%
\includegraphics[width=1in]{example-image-duck-portrait}%
}};%
\tcbvignette{outside node=A}%
\end{tikzpicture}%
\\
\end{tblr}
%}

\textc


\fbox{
\begin{tblr}{colspec={Q[l,h,0.5\textwidth]Q[c,blue!32!green!5]},rowspec={QQ}}
tcolorbox vignette image, large amount of text \textd
&
\begin{tikzpicture}%
\node[draw,fill=blue!60] (A) {{\sffamily\large\bfseries%
\includegraphics[width=1in]{example-image-duck-portrait}%
}};%
\tcbvignette{outside node=A}%
\end{tikzpicture}%
\\
\end{tblr}
}


\textc


\end{document}

A TOC entry if needed could be added various ways, depending on the use case.

You must log in to answer this question.

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