Graphics, Figures & TablesFloating Text around Pictures

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
quiddi
Posts: 2
Joined: Wed Sep 25, 2013 10:27 am

Floating Text around Pictures

Post by quiddi »

Hello together,

I know, my problem is old, but I don't know why it is not working as I want. I want that the picture is integrated in the Text, that the Text floats around it. I have tried wrapfigure from wrapfig and floatingfigure from floatflt. I have stolen the example for wrapfigure from the LaTeX Wikibook (Section: Wrapping text around figures) and this is my output.
floating-pictures.jpg
floating-pictures.jpg (98.4 KiB) Viewed 12926 times
As you can see, the Text is not floating around the picture. What are your ideas, I could made wrong?

Sorry for my bad English, and thanks for your help
Last edited by localghost on Wed Sep 25, 2013 10:54 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Floating Text around Pictures

Post by localghost »

quiddi wrote:[…] I know, my problem is old, but I don't know why it is not working as I want. […]
This has been discussed several times here. Hence you should find some ready-to-use solutions by a Forum Search.
quiddi wrote:[…] I have tried wrapfigure from wrapfig and floatingfigure from floatflt.[…]
Then you can for sure show these efforts in form of a self-contained and minimal example in order to give an adequate problem description. A solely screen capture is not helpful.


Best regards and welcome to the board
Thorsten
quiddi
Posts: 2
Joined: Wed Sep 25, 2013 10:27 am

Floating Text around Pictures

Post by quiddi »

Thanks for your answer. I know that it has discussed some times. Sorry for my very bad description. Now I have found out why it is not working. My Problem is that I'm in an itemize. Is there any way that I can place it in an itemize? My Code looks like this.

Code: Select all

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{blindtext}
\begin{document}


\begin{itemize}
 \item hello
 \item \blindtext
 \begin{wrapfigure}{r}{0.5\textwidth}
   \begin{center}
     \includegraphics[width=0.48\textwidth]{hyster.jpeg}
   \end{center}
   \caption{A gull}
\end{wrapfigure}
\blindtext
\item hello
\end{itemize}
\blindtext
\end{document}
Than he places me the picture at the end of the itemize, and it looks like the same when I put the picrute with the normal

Code: Select all

\begin{figure} and so on...
after the itemize
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Floating Text around Pictures

Post by localghost »

There are two things to be considered.
  • A wrapfigure environment introduces the paragraph.
  • In a list environment like {itemize} it requires a \parbox.
And since the content of the \parbox is shifted down a bit (whyever), this shift needs to be balanced by \vspace*.

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}   % drop `demo` option in actual document
\usepackage{wrapfig}
\usepackage{blindtext}

\begin{document}
  \begin{itemize}
    \item Lorem
    \item
      \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
        \vspace*{-0.55\baselineskip}
        \begin{wrapfigure}{r}{0.5\textwidth}
          \centering
          \includegraphics[width=\linewidth]{hyster.jpeg}
          \caption{A gull}
        \end{wrapfigure}

        \blindtext
      }
    \item Lorem
  \end{itemize}
  \blindtext
\end{document}
I would not recommend this bad W0rd style.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Floating Text around Pictures

Post by cgnieder »

localghost wrote:[...] since the content of the \parbox is shifted down a bit (whyever)
Interesting... I'm not sure what's happening here but it seems related to the height of the \parbox which (with [t]) should be the height of the first line in the \parbox. Apparently this is disturbed by the {wrapfigure}. Anyway, instead of guessing the vertical shift you can insert an empty box and skip a whole line back. (My solution causes an underfull \hbox but I'm a bit too tired now for searching where it is caused):

Code: Select all

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}   % drop `demo` option in actual document
\usepackage{wrapfig}
\usepackage{blindtext}

\newcommand*\adjustwrapfigitem{\null\vskip-\baselineskip}

\begin{document}
  \begin{itemize}
    \item Lorem
    \item 
     \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
        \adjustwrapfigitem
        \begin{wrapfigure}{r}{0.5\textwidth}
          \centering
          \includegraphics[width=\linewidth]{hyster.jpeg}
          \caption{A gull}
        \end{wrapfigure}
        \blindtext
     }
    \item Lorem
  \end{itemize}
  \blindtext
\end{document}
Best
site moderator & package author
Post Reply