Tell me more ×
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.

I'm trying to get a caption to span the figure width on a wrapfig environment. But for some reasons it just won't go. Here is my code and a graphical representation:

problem

\begin{wrapfigure}{R}{0.3\textwidth}    
  \vspace{-30pt}
  \label{fig:UbiContentClass}
  \ffigbox[\textwidth]
  {
    \caption{A classe que define Conteúdo Ubíquo}
  }
  {
    \includegraphics[width=\textwidth]{figs/UbiContentClass.png}
  }
  \vspace{-20pt}
\end{wrapfigure}
share|improve this question
3  
Please add to your question a complete and minimal version of the code illustrating the problem. – Gonzalo Medina Apr 13 '12 at 2:48
...this will just make things easier for others to help you. Change your \includegraphics[width=\textwidth]{...} into \rule{\textwidth}{...} and include at least floatrow and wrapfig. Don't use the minimal document class, but article rather. – Werner Apr 13 '12 at 2:50

1 Answer

up vote 4 down vote accepted

Use \ffigbox[\FBwidth] instead of \ffigbox[\textwidth]. This will equal the caption width to that of object. Here is a screen shot from floatrow documentation for more details.

enter image description here

The MWE for your case:

\documentclass{article}
\usepackage[demo]{graphicx} % Remove demo in your file
\usepackage{wrapfig,floatrow}
\usepackage{lipsum} % provides dummy text
%------------------------------------------
\begin{document}
\lipsum[1-2]
\begin{wrapfigure}{R}{0.3\textwidth}
%\vspace{-30pt} % why this space?
  \label{fig:UbiContentClass}
  \ffigbox[\FBwidth]
  {
    \caption{A classe que define Conteúdo Ubíquo}
  }
  {
    \includegraphics[width=\textwidth]{figs/UbiContentClass.png}
  }
%\vspace{-20pt} % why this space?
\end{wrapfigure}
\lipsum[2-3]    
%------------------------------------------
\end{document}

enter image description here

share|improve this answer
thanks! it worked :) – Marcos Roriz Apr 13 '12 at 16:48
The space is to remove the extra empty stuff. – Marcos Roriz Apr 13 '12 at 16:56

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.