Take the 2-minute tour ×
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 Rounded corner grey-colored box around figures. One solution would be to use

\usepackage{float}
\floatstyle{boxed} 
\restylefloat{figure}

but this results in black box around a figure. What would be the way to proceed?

share|improve this question
    
You can try mdframed. –  Marco Daniel Oct 14 '11 at 10:18
    
BTW, welcome to TeX.SE. –  Peter Grill Oct 14 '11 at 20:31
    
The fancybox package provides a \ovalbox macro which might be useful here. –  Martin Scharrer Nov 3 '11 at 7:16
add comment

1 Answer

up vote 9 down vote accepted

You can define your own \floatstyle. In this case I took the definition from the float package and adjusted it to use the mdframed pacakge environment to draw the frame. Below, I took the liberty to add a background color, and tikzsetting to illustrate some of the customization that are possible -- see the mdframed documentation for more options.

Here is a comparrison of usine \floatstyle{boxed} and \floatstyle{myRoundBox}:

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\usepackage[framemethod=tikz]{mdframed}

\mdfdefinestyle{myFigureBoxStyle}{backgroundcolor=yellow!10,, roundcorner=25pt,tikzsetting={draw=blue, line width=1pt}}%

\makeatletter
  \newcommand\fs@myRoundBox{\def\@fs@cfont{\bfseries}\let\@fs@capt\floatc@plain
  \def\@fs@pre{\begin{mdframed}[style=myFigureBoxStyle]}%
  \def\@fs@mid{}%
  \def\@fs@post{\end{mdframed}}\let\@fs@iftopcapt\iffalse}
\makeatother

\floatstyle{myRoundBox} 
\restylefloat{figure}

\begin{document}

\floatstyle{boxed} 
\restylefloat{figure}

\section{Using boxed}
\begin{figure}[h]
    \centering
    \includegraphics[width=0.35\textwidth]{images/eiffel_tower}
    \caption{Some caption}
\end{figure}

\floatstyle{myRoundBox} 
\restylefloat{figure}
\section{Using myRoundBox}
\begin{figure}[h]
    \centering
    \includegraphics[width=0.35\textwidth]{images/eiffel_tower}
    \caption{Some caption}
\end{figure}
\end{document}
share|improve this answer
add comment

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.