Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider the following LaTeX code, the bottom half of which was generated from MarkDown by Pandoc.

\documentclass{article}
\usepackage{mwe}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}

\setlength{\parindent}{0pt}

% begin preamble.tex
\usepackage{wrapfig}
\renewenvironment{description}{}{}
\renewcommand{\item}[1][]{%
    \renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=4cm]{##1}}%
    \begin{wrapfigure}{l}{4cm}%
    #1%
    \end{wrapfigure}%
    }
% end preamble.tex

\begin{document}
\begin{wrapfigure}{l}{4cm}%
\Oldincludegraphics[width=4cm]{example-image-a}%
\end{wrapfigure}%
A.0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.

A.1 \blindtext

\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-b}]
B.0 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

B.1 \blindtext
\end{document}

What I would like to do, is to redefine the description environment and the \item command as normal text for the wrapfigure to work properly.

\renewenvironment{description}{}{} appears to do fine. It is the \renewcommand{\item}[1][] block that still seems to provoke unexpected wrapfig behaviour. Something similar happens when replacing wrapfig by picins.

Note: Since we are dealing here with a Pandoc-generated document, above should only be achieved by changing the preamble and/or adding a header and/or footer to the document. enter image description here

share|improve this question

1 Answer 1

Originally intended to be an edit to this question, here is a solution using the floatflt package; a floating package I had not tried yet. The trick is in the \hspace{0pt}.

The issue of clearing the float is dealt with here and here.

\documentclass{article}
\usepackage{mwe}

\makeatletter
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth
\else\Gin@nat@width\fi}
\makeatother
\let\Oldincludegraphics\includegraphics
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=\maxwidth]{#1}}

\setlength{\parindent}{0pt}

% begin preamble.tex
\usepackage{floatflt}
\renewenvironment{description}{%
    \renewcommand{\includegraphics}[1]{\vspace{-1ex}\Oldincludegraphics[width=4cm]{##1}}
    \renewcommand{\item}[1][]{##1\end{floatingfigure}}%
    \hspace{0pt}%
    \begin{floatingfigure}[l]{4cm}}%
    {}
% end preamble.tex

\begin{document}
\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-a}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

\blindtext

\begin{description}
\itemsep1pt\parskip0pt\parsep0pt
\item[\includegraphics{example-image-b}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam lobortis facilisis
sem. Nullam nec mi et neque pharetra sollicitudin.
\end{description}

\blindtext
\end{document}

floatflt solution

share|improve this answer
    
The solution is not compatible (yet?) with \usepackage[nobottomtitles*]{titlesec} in the preamble. –  Serge Stroobandt Aug 29 '13 at 14:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.