4

I have a problem with wrapfigure. I only want to wrap the picture in the first section, but it automatically repeats in the second section. What am I doing wrong?

\documentclass[10pt,a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}
%\section*{Lebenslauf}
\begin{wrapfigure}[7]{l}{3cm}
   
    \includegraphics[width=3cm]{foto.jpeg}
\end{wrapfigure} 

\subsection*{Heading}

Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 

\subsection*{Heading}

Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
\end{document}

enter image description here

2
  • Do you really want the section title to be also indented?
    – Bernard
    Dec 16, 2020 at 21:02
  • yes I would prefer it this way, if it's possible
    – Knall bert
    Dec 16, 2020 at 22:10

2 Answers 2

4

The problem does not happen if there is some text before the wrapfigure environment. As there was none, I added a \leavevmode, and to ensure the alignment of the top of the image with the section title, I used \raisebox{0pt} with the optional argument for the height of the box to fool latex, and make it believe the image is higher than it is really.

\documentclass[10pt,a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{calc}
\usepackage{wrapfig}
\input{insbox.tex}
\usepackage{lipsum}

\begin{document}

\leavevmode
\begin{wrapfigure}[9]{l}{3cm}
\raisebox{0pt}[\height+\baselineskip]{\includegraphics[width=3cm]{foto.jpeg}}
\end{wrapfigure}

\subsection*{Heading}

Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text

\subsection*{Next Heading}

Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text

\end{document} 

enter image description here

1

Try this code

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{lipsum}

\begin{document}
%\section*{Lebenslauf}

\subsection*{Heading 1}
\begin{wrapfigure}[8]{l}{3cm} 
    \vspace{-\baselineskip}     
    \includegraphics[width=3cm, height=3cm]{example-image-A}
\end{wrapfigure} 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 


\subsection*{Heading 2}

Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text 
Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text Some Text
\end{document}

xxy

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .