Graphics, Figures & TablesAdding a shaded background to a floating box

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jackd
Posts: 1
Joined: Thu Oct 12, 2017 6:05 pm

Adding a shaded background to a floating box

Post by jackd »

Hi all!

I haven't yet been able to figure this out so putting it to the community. I have loaded a module called boxedfloat (http://www.spitzmueller.org/tools/lyx/boxedfloat.module) so that I can add boxes to my document. The float format is preferable since I want them to span a two column file and not interfere with the formatting of the main text. Without using the float module I have a few aesthetic controls over a box including shading th background but I can't figure out a way of shading this extended float type.

Any ideas??


Many thanks

Recommended reading 2024:

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

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

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

eekBR
Posts: 1
Joined: Sun Nov 12, 2017 11:33 pm

Adding a shaded background to a floating box

Post by eekBR »

May I sugest:
https://tex.stackexchange.com/questions ... nvironment

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{mdframed}% http://ctan.org/pkg/mdframed
\usepackage{xcolor}% http://ctan.org/pkg/xcolor
\newenvironment{inline}[3][black!25]{
\begin{figure}[h!]
\begin{mdframed}[backgroundcolor=#1]
\centering\caption{#2}\label{#3}
\vspace{10pt}%
}{%
\end{mdframed}
\end{figure}
}
\begin{document}
\lipsum[1]
\begin{inline}{An image}{image}
\rule{150pt}{100pt}
\end{inline}
\lipsum[2]
\end{document}
Post Reply