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?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityYou can define your own \floatstyle
. In this case I took the definition from the float
package and adjusted it to use the mdframed
package environment to draw the frame.
Here is a comparison of using \floatstyle{boxed}
and \floatstyle{myRoundBox}
:
tikzsetting
to illustrate some of the customization that are possible -- see the mdframed
documentation for more options.\vspace{\abovecaptionskip}
in \def\@fs@mid{}
as per How to frame a figure in Lyx.\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{\vspace{\abovecaptionskip}}%
\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/EiffelTall}
\caption{Some caption}
\end{figure}
\floatstyle{myRoundBox}
\restylefloat{figure}
\section{Using myRoundBox}
\begin{figure}[h]
\centering
\includegraphics[width=0.35\textwidth]{../images/EiffelTall}
\caption{Some caption}
\end{figure}
\end{document}
\vspace{\abovecaptionskip}
in \def\@fs@mid{}
you get some space between image and caption.
Jun 14, 2014 at 17:47
mdframed
.fancybox
package provides a\ovalbox
macro which might be useful here.