Graphics, Figures & Tables ⇒ How to add a shadow under a picture ?
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
Re: How to add a shadow under a picture ?
I would define a macro for that, in the preamble. Within the figure environment, I would call that macro. So further changes or adjustments would be easy and consistent.
Stefan
Stefan
LaTeX.org admin
NEW: TikZ book now 40% off at Amazon.com for a short time.

Re: How to add a shadow under a picture ?
Hmm, I'm ain't an expert on this. How do you suggest to define that macro ?
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
How to add a shadow under a picture ?
Macros are an important strength of LaTeX. Define a macro once, and use it many times. For example, in the preamble:
Later, in the document:
Macros are not just for saving typing, but for consistency and easy changes.
Stefan
Code: Select all
Code, edit and compile here:
\newcommand{\shadowpicture}[1]{%\shadowsize=1pt\fboxrule=0pt\fboxsep=0pt\color{gray}\shadowbox{\fboxsep=6pt\fcolorbox{white}{white}{#1}}\normalcolor}
Code: Select all
Code, edit and compile here:
\begin{figure}[H]\centering\shadowpicture{\includegraphics[height=8cm]{picture.jpg}}\caption{Another caption.}\end{figure}
Stefan
LaTeX.org admin
Re: How to add a shadow under a picture ?
Works perfectly well !
Thanks Stefan ! (by the way, see the preview in my last message, on the previous page...)

Thanks Stefan ! (by the way, see the preview in my last message, on the previous page...)
- Stefan Kottwitz
- Site Admin
- Posts: 10345
- Joined: Mon Mar 10, 2008 9:44 pm
How to add a shadow under a picture ?
The preview looks nice!
Regarding macros, try defining macros for all which you possibly need several times, also to make a logical document. For example, I would not even use
Stefan
Regarding macros, try defining macros for all which you possibly need several times, also to make a logical document. For example, I would not even use
\textbf
or \textit
in a document - but I would define \keyword
etc. for such emphasis. These macros could call \textbf etc. And I could change that for the whole document whenever I like.Stefan
LaTeX.org admin
How to add a shadow under a picture ?
I found a very nice solution on http://tex.stackexchange.com/questions/ ... ssian-blur
It certainly looks like its exactly what you are looking for, and I was also. Next thing is I'd like to make this part of a class or a module.
Let me know how you go.
Cheers
Here is the code
It certainly looks like its exactly what you are looking for, and I was also. Next thing is I'd like to make this part of a class or a module.
Let me know how you go.
Cheers
Here is the code
Code: Select all
Code, edit and compile here:
\documentclass{article}% put all this in the preamble\usepackage{tikz}\usetikzlibrary{shadows,calc}% code adapted from http://tex.stackexchange.com/a/11483/3954% some parameters for customization\def\shadowshift{3pt,-3pt}\def\shadowradius{6pt}\colorlet{innercolor}{black!60}\colorlet{outercolor}{gray!05}% this draws a shadow under a rectangle node\newcommand\drawshadow[1]{\begin{pgfonlayer}{shadow}\shade[outercolor,inner color=innercolor,outer color=outercolor] ($(#1.south west)+(\shadowshift)+(\shadowradius/2,\shadowradius/2)$) circle (\shadowradius);\shade[outercolor,inner color=innercolor,outer color=outercolor] ($(#1.north west)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$) circle (\shadowradius);\shade[outercolor,inner color=innercolor,outer color=outercolor] ($(#1.south east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$) circle (\shadowradius);\shade[outercolor,inner color=innercolor,outer color=outercolor] ($(#1.north east)+(\shadowshift)+(-\shadowradius/2,-\shadowradius/2)$) circle (\shadowradius);\shade[top color=innercolor,bottom color=outercolor] ($(#1.south west)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$) rectangle ($(#1.south east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$);\shade[left color=innercolor,right color=outercolor] ($(#1.south east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$) rectangle ($(#1.north east)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$);\shade[bottom color=innercolor,top color=outercolor] ($(#1.north west)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$) rectangle ($(#1.north east)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$);\shade[outercolor,right color=innercolor,left color=outercolor] ($(#1.south west)+(\shadowshift)+(-\shadowradius/2,\shadowradius/2)$) rectangle ($(#1.north west)+(\shadowshift)+(\shadowradius/2,-\shadowradius/2)$);\filldraw ($(#1.south west)+(\shadowshift)+(\shadowradius/2,\shadowradius/2)$) rectangle ($(#1.north east)+(\shadowshift)-(\shadowradius/2,\shadowradius/2)$);\end{pgfonlayer}}% create a shadow layer, so that we don't need to worry about overdrawing other things\pgfdeclarelayer{shadow}\pgfsetlayers{shadow,main}\newcommand\shadowimage[2][]{%\begin{tikzpicture}\node[anchor=south west,inner sep=0] (image) at (0,0) {\includegraphics[#1]{#2}};\drawshadow{image}\end{tikzpicture}}% end of the preamble stuff
-
- Posts: 51
- Joined: Sat Oct 22, 2016 3:43 pm
How to add a shadow under a picture ?
This looks great! Can this also be used somehow to have the same effect on a box filled with text (minipage)?
Stef
Stef