3

Ok so here is a question for all of you latex experts. Every time I use the \wrapfigure{} environment I get the following:

Notice how there is line skip right after a period. and it separates the text. (Notice how in this 1st image there is a line skip right after a period which separates the text.)

But what I really want is this:

enter image description here

Maybe is not possible to achieve this with a simple \wrapfigure{} but if someone knows how to do it I would really appreciate the help. Thank you hand happy Latexing!

2 Answers2

5

It's easy using the plain TeX macro package insbox. However, it does not accept floats, so you have to put the graphic in a \parbox of the relevant width,, and use \captionof{figure}{...}.

The syntax is the following for insertion on the right side \InsertBoxR{no of unshortened lines}{object to be inserted}[optional integer]. The optional argument is the number of supplementary short lines, in case TeX doesn't calculate the exact number of short lines.

\documentclass[12pt, latin]{article}
\usepackage{babel}
\usepackage{graphicx}
\usepackage{caption}
\input{insbox.tex}
\usepackage{lipsum}

\begin{document}

\InsertBoxR{3}{\parbox{0.35\linewidth}{\includegraphics[width=\linewidth]{traccia-table}%
\captionof{figure}{Traccia table}}}[6]

\lipsum[8-9]

\end{document} 

enter image description here

Bernard
  • 271,350
1

This does look good. I typed the text and looked for a natural line break. There I put the wrapfigure environment. I admit this is a poor solution, but it works. This is also the solution mentioned in the package documentation (page 2 -- as the last bullet point in the first bullet list on that page):

It is convenient to begin the environment between paragraphs, but if you want placement in the middle of a paragraph, you must put the environment between two words where there is a natural line break.

\documentclass[]{article}

\usepackage{wrapfig,blindtext}

\begin{document}
This is my awesome paragraph with a \texttt{wrapfigure} environment. Let's see
how we can do this real quick. I'm adding some more manual text just to fill
some lines and then let the \texttt{wrapfigure} environment start. This way it
gets% a line break did occur here
\begin{wrapfigure}{r}{0pt}
  \rule{2cm}{2cm}
  \caption{figure}
\end{wrapfigure}
closer to what you want. And here goes some more \blindtext.
\end{document}

enter image description here

Skillmon
  • 60,462
  • Thank you. I ended up using your idea without noticing. Maybe there would be another package to help with this in the future. Thanks again for replying so quickly. Greetings from Manchester. :) – Jesús Toscano Feb 26 '18 at 21:38