I am trying to figure out why I am getting no image and no error message in the log when using wrapfigure
environment right after a sectioning command. The only way how I was able to force wrapfigure
into showing the image was to enter some text between the section heading and the beginning of wrapfigure
environment — I have therefore got what I wanted by inserting a paragraph consisting of one non-breaking space and removing the resulting blank line by adding a negative \vspace
, which, I suppose, is not the way how things should work.
For a while I thought I have a similar problem as in Wrapfigures beneath section headings misbehave, but if I understood it correctly the problem there is caused by a page break, which is not my case.
FWIIW, I am running a recent version of MiKTeX, but I have first came across this problem about a year ago …
An illustration of the problem:
MWE:
\documentclass[12pt]{article}
\usepackage[demo]{graphicx}
\usepackage[verbose]{wrapfig}
\begin{document}
%% Tight margins
\setlength{\intextsep}{0pt}
%% Does not work
\section*{Curricula Vitae}
%% Do not allow the figure to float away ...
\begin{wrapfigure}{l}{96pt}
%% ... but nevertheless this image does not show up.
\includegraphics[width=96pt,height=22pt]{example-image}
\end{wrapfigure}
\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\section*{Working example}
%% Everything is okay if there is a paragraph of text between \section and
%% \begin{wrapfigure}. Adding the following line seems to solve my problem:
~\par\vspace{-\baselineskip}
%%
\begin{wrapfigure}{l}{96pt}
\includegraphics[width=96pt,height=22pt]{example-image}
\end{wrapfigure}
\noindent
\textbf{Primum Author} condimentum augue id magna semper rutrum. Mauris elementum
mauris vitae tortor. Fusce suscipit libero eget elit. Nam quis nulla.
\end{document}
Any ideas? I have an urgent feeling that I have missed something obvious.
Edit: The comment of @JohnKormylo caused me to look at the code once again, and after some additional testing I am pretty sure that the \noindent
is the culprit. While
\section{...}
\begin{wrapfigure}...\end{wrapfigure}
\noindent
<paragraph text>
will not display the contents of the wrapfigure
environment, moving \noindent
between \section
and \begin{wrapfigure}
seems to work.
Any idea why is this so?
Best Answer
You also can use the plain TeX macro package
insbox
: