8

I'm able to generate a tikz node with shadow (lower right) on the node, but this is different than shading not the entire node, but just the circle and edges like in the picture below.

enter image description here

The shadow on each edge is not really the problem, but the shadow in the nodes, that is dropped by the circle not only externally but also inside the node is something that I was not able to do in Tikz.

Minimum working tex:

\documentclass{article}
\usepackage{tikz}
\usepackage{fullpage}
\usetikzlibrary{shadows}

\begin{document}

\begin{tikzpicture}[main/.style = {draw, circle, text=black, 
                                   fill=white, circular drop shadow={opacity=0.25}}] 
\node[main] (1) {$x_1$}; 
\end{tikzpicture} 

\end{document}

enter image description here

2
  • If you don't want the shadow inside fill the node with bg-color, probably white. – Harald Lichtenstein May 12 at 19:14
  • @Harald Lichtenstein: He does want the shadow inside. – hpekristiansen May 12 at 19:50
8

There are probably better ways to do this, but here I use a fuzzy ring 15 percent fading:

\documentclass[tikz, border=0.1cm]{standalone}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}[
main/.style = {draw, circle, text=black,  
preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 15 percent, opacity=0.25}
}] 
\node[main] (1) {$x_1$}; 
\end{tikzpicture} 
\end{document}

Node with fuzzy ring shadow


Edit:

The solution only works for circles and ellipses - not for e.g. polygons as shown here:

\documentclass[tikz, border=0.1cm]{standalone}
\usetikzlibrary {fadings, shapes}
\begin{document}
\begin{tikzpicture}[
main/.style = {draw, regular polygon, text=black,  
preaction={draw, ultra thick, transform canvas={yshift=-0.2ex}, path fading=fuzzy ring 15 percent, opacity=0.25}
}] 
\node[main] (1) {$x_1$}; 
\end{tikzpicture} 
\end{document}

Pentagon with bad shadow

To make a more general solution, one could implement a shifted version of glow as shown in this answer(by me): https://tex.stackexchange.com/a/569645/8650

1
  • Thanks, this is quite similar to what I was looking for. Now I'll try and play with this solution. – Antonio Caruso May 12 at 21:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.