# Putting wrapfigure right next to the following paragraph

TeX - LaTeX Asked on December 24, 2020

I’d like to put a floating picture to the right of not just any text, but specifically the text that follows. The problem is that wrapfigure seems to choose a subsequent paragraph.

In the following Pandoc example, I would like the picture to be right next to the Occupation / Drive / Pillars of Sanity section; instead, it shows up next to the After seeing Europe… part.

---
usepackage{graphicx,wrapfig}
---

# Clarence Merriweather

begin{wrapfigure}{r}{0.3textwidth}
includegraphics[width=linewidth]{portrait.jpg}
end{wrapfigure}

* Occupation: Professor
* Drive: Scholarship
* Pillars of Sanity:
* Positivism: the world can be understood via science
* Enlightenment will prevail over primitive barbarism
* The world changes, but I'll always have the family house in Abingdon

After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.

His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving "crazies who imitate the primitive savages".


How can I force wrapfigure to put things on the current paragraph, i.e. next to the "Occupation", "Drive" and "Pillars" part?

I don't know what exactly happens between the markdown(?) of pandoc and the LaTeX input, but wrapfigure resists being placed in a list. The answer to starting "immediately" is

indent vspace*{-baselineskip}vspace{-parskip}par


before the beginning of the list.

Also, there is a white-space border above the content of wrapfigure, so it doesn't touch the text above. To make the image start right on that line you should undo the border inside the wrapfigure. In total (actually, in "partial")

# Clarence Merriweather

begin{wrapfigure}{r}{0.3textwidth}
vspace{-intextsep}
includegraphics[width=linewidth]{portrait.jpg}
end{wrapfigure}

indent vspace*{-baselineskip}vspace{-parskip}par
* Occupation: Professor
* Drive: Scholarship


Correct answer by Donald Arseneau on December 24, 2020

I have grown increasingly fond of replacing wrapfig with paracol. It is far more robust, but it does require manually breaking paragraphs (nopar and noindent).

documentclass{article}
usepackage{graphicx}
usepackage{paracol}

newcommand{nopar}{{parfillskip=0ptparskip=0ptpar}}

begin{document}

section*{Clarence Merriweather}

setcolumnwidth{dimexpr 0.7textwidth-columnsep}% right column is 0.3textwidth
begin{paracol}{2}
begin{itemize}
item Occupation: Professor
item Drive: Scholarship
item Pillars of Sanity:
begin{itemize}
item Positivism: the world can be understood via science
item Enlightenment will prevail over primitive barbarism
item The world changes, but I'll always have the family house in Abingdon
end{itemize}
end{itemize}

After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
switchcolumn
includegraphics[height=2.5in, % in real document remove this option
width=linewidth]{example-image}%{portrait.jpg}
end{paracol}
noindent standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU

His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
end{document}


Answered by John Kormylo on December 24, 2020

I'm not familiar with pandoc, but in LaTeX code (resulted from pandoc) code should be something like this:

documentclass{article}
usepackage{graphicx,wrapfig}

begin{document}

section*{Clarence Merriweather} % this is LaTeX emulation of pandoc
begin{itemize}
item Occupation: Professor
item Drive: Scholarship
item Pillars of Sanity:
begin{itemize}
item Positivism: the world can be understood via science
item Enlightenment will prevail over primitive barbarism
item The world changes, but I'll always have the family house in Abingdon
end{itemize}
end{itemize}

begin{wrapfigure}{r}{0.3textwidth} % <--- had to be inserted here
vspace{-baselineskip}
includegraphics[height=linewidth, % in real document remove this option
width=linewidth]{example-image-duck}%{portrait.jpg}
end{wrapfigure}
After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.

His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
end{document}


which produce

As you can observe, wrapfigure had to be at begin of paragraph, where is desired that image be inserted.

Unfortunately wrapfig doesn't work with itemize. A possible solution is incapsulate lists in minipage and instead of wrapfigure use InsertBoxR defined in plain TeX macro package insbox

documentclass{article}
usepackage{graphicx}
usepackage{enumitem}
input{insbox}%%%%%%%%%%%%%% TeX macro, very useful

begin{document}

section*{Clarence Merriweather}

InsertBoxR{0}{%
includegraphics[height=0.4linewidth, % in real document remove this option
width =0.3linewidth]{example-image-duck}%{portrait.jpg}
}
noindentbegin{minipage}[t]{0.65linewidth}
setlist[itemize]{topsep=0pt, itemsep=0.2ex, leftmargin=*}
begin{itemize}
item Occupation: Professor
item Drive: Scholarship
item Pillars of Sanity:
begin{itemize}
item Positivism: the world can be understood via science
item Enlightenment will prevail over primitive barbarism
item The world changes, but I'll always have the family house in Abingdon
end{itemize}
end{itemize}
end{minipage}

After seeing Europe sink into the death cult that was the Great War,
Prof. Merriweather, himself spared of experiencing combat first-hand
by his academic standing and his asthma, decided to leave his faculty
position in Oxford to pursue a new career in NYU.

His interest in primitive cultures and the occult is purely
academical. He is happy to lend his expertise to the FBI to help with
cases involving ''crazies who imitate the primitive savages''.
end{document}


(red lines indicate text border)

Answered by Zarko on December 24, 2020

## Related Questions

### LaTeX Texmaker – Creating a separate file for glossary

1  Asked on April 23, 2021 by j-o-p-p

### Single command at the beginning of my Latex document that induces linebreaks?

1  Asked on April 23, 2021 by zaanwellies96

### Representation of skillpoints on LaTeX

1  Asked on April 23, 2021 by nenno-lillo

### Replicating a decision tree in tikz

1  Asked on April 23, 2021

### Is there any package or document class for a 79.50 ± 0.50 (W) mm x dia 83.00 mm paper roll (thermal printer)?

0  Asked on April 22, 2021 by namal

### Including images in an R code chunk of R sweave using for loop

1  Asked on April 22, 2021

### Cross reference .xlsx file to main.tex

0  Asked on April 22, 2021 by lamamo

### Environment equivalent of ensuremath

2  Asked on April 22, 2021

### Fill region and add a vertical or horizontal strip inside

2  Asked on April 22, 2021 by sdpmaths

### List of Acronyms is not displayed

4  Asked on April 22, 2021 by thili

### TikZ: How to draw in a ‘path picture’ environment outside of the ‘path picture bounding box’

0  Asked on April 22, 2021

### adjust vertical space in quoting environment to exactly one line

2  Asked on April 22, 2021 by peterstrawson

### LaTeX Error-Missing Begin Document

7  Asked on April 22, 2021 by vaibhav-sundriyal

### Centering table does not work with tbl macro

0  Asked on April 22, 2021 by wahedsaw

### Write in an easy way $frac{a}{b}$. Shortcuts to output the fractions

2  Asked on April 22, 2021 by iuli

### How to put the dots in the centre?

2  Asked on April 22, 2021

### pgfplots: How to get coordinates, draws as a style

1  Asked on April 22, 2021