[Tex/LaTex] Wrap text around a picture except for the first line

line-breakingpositioningwrapfigure

As the following minimal sample shows, a text wrapping around a picture starts wrapping with the first line. Including the wrapfigure in the text leads to strange paragraph breaks.

%----
\documentclass[bibliography=totoc,listof=totoc,12pt,a4paper,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
%----

    \begin{document}

\begin{wrapfigure}[]{l}{0pt}
    \vspace{-30pt}
    \includegraphics{test}
\end{wrapfigure}    

\textbf{Lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-elitr (1)}. Now starts text \lipsum[1]

\end{document}

Any suggestions how to avoid the first line form wrapping around a picture like in the following scheme?

enter image description here

Edit:

I have found a way to solve the problem for a minimal example using picinpar and a window environment.

\begin{window}[<number of lines>, <align>, \includegraphics[]{<file>}, {<caption-text>}]

%---
\documentclass[bibliography=totoc,listof=totoc,12pt,a4paper,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{picinpar}
%---

\begin{document}

\begin{window}[1, l, \includegraphics[]{test}, {}]
\textbf{Lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-elitr (1)}. 
Now starts text \lipsum[1]
\end{window}


\end{document}

But still I want to use schemeref to add numbering within a picture and therefore I need a figure environment and no such solution with window.

Any ideas regarding that?

Best Answer

Kind of a hack as a solution would be to push down the image a little and use a negative indentation for the first line like below. I put the code into the macro \parwithleftwrapfig because it's important to correctly end paragraphs before and after the figure and reset the original indentation...

Note that you have to explicitly specify the width of the wrapfigure for this macro to work...

EDIT: I inserted an optional parameter to show that you can still use arbitrary code.

EDIT2: Adapted solution to access internal wrapfig-var to allow for automatic width adjustment. Note that internal vars of packages may change on updates without notice.

%----
\documentclass[bibliography=totoc,listof=totoc,12pt,a4paper,oneside]{scrbook}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
%----

\makeatletter
\newlength{\oldparindent}
\newcommand{\parwithleftwrapfig}[4][]
{ %
    \par %
    \begin{wrapfigure}{l}{#2} %
        \vspace*{\baselineskip} %
        \includegraphics{#3} %
        #1 %
    \end{wrapfigure}    %
    \setlength{\oldparindent}{\parindent} %
% %  To allow automatic width adjustment we access internal spacing var of package wrapfig:
    \addtolength{\parindent}{-\wd\WF@box} %
% %  instead of using the provided width:
%    \addtolength{\parindent}{-#2} %
    \addtolength{\parindent}{-\columnsep} %
    #4 \par %
    \setlength{\parindent}{\oldparindent} %
    \par %
}
\makeatother

\begin{document}

\textbf{First paragraph}. \lipsum[1]
%
\parwithleftwrapfig[{\caption{This is a figure.}\label{fig:afigure}}]{0\textwidth}{test}
    {\textbf{Lorem-ipsum-dolor-sit-amet-consetetur-sadipscing-elitr (1)}. Now starts text with references to figure \ref{fig:afigure}. \lipsum[1]}

\textbf{Another paragraph}. \lipsum[1]

\end{document}