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.
---
header-includes:
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
by his academicnopar
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.
Addendum:
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
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP