Currently I've this situation:
\newenvironment{inline}[2]{
\begin{figure}[h!]
\caption{#1}\label{#2}
\vspace{10pt}%
}{
\end{figure}
}
How can I set a background color to whole content, which is in the figure?
colorfloats
Currently I've this situation:
\newenvironment{inline}[2]{
\begin{figure}[h!]
\caption{#1}\label{#2}
\vspace{10pt}%
}{
\end{figure}
}
How can I set a background color to whole content, which is in the figure?
Best Answer
You can use the
mdframed
package for this. In the below MWE, I've added an option first argument to theinline
environment which specifies thebackgroundcolor
(default isblack!25
= 25% black):I've only added the
backgroundcolor
option tomdframed
, leaving all the other settings as is (for example, it includes a border). Read themdframed
documentation on how to modify any default settings.Having a caption above the figure, you may be interested in adjusting the lengths
\abovecaptionskip
and\belowcaptionskip
to suit your needs - they are set with the caption-below-float in mind. The defaults are10pt
and0pt
, respectively, in the standard document classes.In the above MWE,
xcolor
provides the colour specification, whilelipsum
provided some dummy text, Lorem Ipsum style.