texblog

Adding a shadow to a figure in LaTeX

I recently wrote about cropping figures using the graphics bundle. Here is another fancy way to get more out of your figures.

The fancybox package implements commands for various boxes such as a box with round corners. The command shadowbox creates a black box with a shadow. It works with normal text, in math mode as well as with floats such as the figure environment.

To add a shadow to a figure, we need two things. First we load the fancybox package. Next, we add a shadowbox around includegraphics. Note, the box encompasses only the actual content and not the entire float.

\usepackage{fancybox, graphicx}
...
\begin{figure}[ht]
	\shadowbox{\includegraphics{figure-file}}}
\end{figure}

As simple as that.

And here is the result with a minimal working example below.

\documentclass{article}
\usepackage{fancybox}
\begin{document}
\begin{figure}[ht]
	\centering
	\shadowbox{\phantom{\rule{4cm}{3cm}}}
	\caption{Phantom figure}
\end{figure}
\tiny\hfill Created by http://texblog.org
\end{document}

A few clarifications on the minimal working example

Exit mobile version