Graphics, Figures & TablesWrapfigure/wraptext indenting?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
shoemoodoshaloo
Posts: 5
Joined: Tue May 31, 2011 1:01 am

Wrapfigure/wraptext indenting?

Post by shoemoodoshaloo »

Hello all,

I'm new to this forum. I'm currently assembling a lab manual for a college science course, and am running into a few holdups along the way. I have been using Latex for a few years, so hopefully I can contribute to this forum instead of just leaching.

My current issue is that I'm trying to create a yellow textbox object which I will use to alert students to common pitfalls or mistakes with the material. I need to be able to insert these at various places in the text and have the text wrap around it. Following some guidelines I found on another site, I made the following:

Code: Select all

\begin{wrapfigure}{r}{5cm}{           %Wrapping width
  \fcolorbox{red}{yellow}{                  %Framed box.  Frame color first
    \begin{minipage}[t]{5cm}   %Box width
      {\footnotesize BLAHBLAH}
    \end{minipage}
  }
}
\end{wrapfigure}
The document compiles and the box looks ok; however, the text doesn't actually wrap around the box. Furthermore, all the text on the next pages are misaligned. If I align the wrapfigure r, the text on the next pages is cut off on the right side, and vice versa if I align left.

If anyone knows why this is happening, or a better way to do this, I'd be very grateful.

Recommended reading 2024:

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

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

shoemoodoshaloo
Posts: 5
Joined: Tue May 31, 2011 1:01 am

Re: Wrapfigure/wraptext indenting?

Post by shoemoodoshaloo »

Update: I also just realized that this is occurring for any wrapped figures, so I think the problem may be due to the wrapfig environment.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Wrapfigure/wraptext indenting?

Post by localghost »

Please always provide a minimal example that clearly shows what you are doing and the described problem(s). Otherwise specific help is nearly impossible. Especially when a problem becomes more complicated.

Your problem may be caused by the fact that your are using the wrapfigure environment in very strange way. At least the following works for me.

Code: Select all

\documentclass[11pt,a4paper,english]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{geometry}
\usepackage{calc,wrapfig}
\usepackage{xcolor}
\usepackage{blindtext}

\begin{document}
  \begin{wrapfigure}{r}{5cm+4\fboxsep}
    \fcolorbox{red}{yellow}{%
      \begin{minipage}[t]{5cm}
        \footnotesize
        The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.
      \end{minipage}
    }
  \end{wrapfigure}

  \blindtext
\end{document}
I added the calc package for better adjustment of some lengths. The blindtext package is only for creating dummy text thus not part of the solution.


Best regards and welcome to the board
Thorsten
Post Reply