share
TeX - LaTeXHow can we draw a Hannukah Menorah with decorations, using TikZ?
[+42] [2] Simd
[2012-12-06 19:47:32]
[ tikz-pgf fun ]
[ https://tex.stackexchange.com/questions/85844/how-can-we-draw-a-hannukah-menorah-with-decorations-using-tikz ]

In the spirit of the festive season and How can we draw a Christmas tree with decorations, using TikZ? [1], I would like to use TikZ for drawing a Hannukah Menorah. There are many different styles of Menorah including

enter image description here

and

enter image description here

amongst others. Of course only the most greedy person would also ask for the number of candles to be an option within the TikZ code and it would be plain lunacy for one to expect the flames to actually flicker.

Update. Here is another colourful example.

enter image description here

(2) While I'm not able to attempt an answer, I find that this is a very good idea. - egreg
[+46] [2012-12-07 11:09:56] Claudio Fiandrino [ACCEPTED]

Here is my humble attempt:

enter image description here

The code:

\documentclass[x11names]{article}
\usepackage[width=16cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,shadows,decorations,decorations.pathmorphing,
   hobby,shapes.geometric}

% original code by percusse:
% http://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines#49961
\makeatletter
\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=3mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
        }
    }
    \state{final}{}
}
\makeatother

\tikzset{candle decoration/.style={decorate, decoration={random steps,segment length=2pt,amplitude=0.3pt}}}
\tikzset{candle shadow/.style={drop shadow={shadow xshift=.4ex,shadow yshift=-.3ex}}}
\tikzset{stick candle/.style={
            draw,decorate, decoration={penciline,amplitude=3pt},rectangle, 
            anchor=north, minimum width=0.5cm, minimum height=#1,
            left color=white, right color=Honeydew2!80
            },
            stick candle/.default={2cm}
}

\tikzset{candle support style/.style={
            draw,rectangle, 
            decorate, decoration={penciline,amplitude=1.5pt},
            anchor=north, minimum width=0.9cm, minimum height=0.2cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

\tikzset{candle base style/.style={
            draw,semicircle,rotate=183,
            candle decoration,
            minimum width=0.6cm, minimum height=0.2cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

\newcounter{candles}
\setcounter{candles}{1}
\tikzset{candle/.code={
        \draw[candle decoration, left color=Gold1!20, right color=Goldenrod1, candle shadow]
        (0,1) to[curve through={(-0.1,0.5)..(-0.2,0) .. (0.2,0) .. (0.1,0.5)}] (0,1);       
        \draw[draw=none,candle decoration, fill=LemonChiffon1]
        (0,0.45) to[curve through={(-0.05,0.25)..(-0.1,0) .. (0.1,0) .. (0.05,0.25)}] (0,0.45);
        \draw[decorate, decoration=penciline](0,0.125)--(0,-0.25)node(candle\thecandles){};     
        \node[stick candle=#1, candle shadow] (candlesupport\thecandles) at (candle\thecandles){}; 
        \node[candle support style, below=-0.1cm of candlesupport\thecandles](basecandle\thecandles) {};
        \node[candle base style, below=0.275cm of basecandle\thecandles](downbasecandle\thecandles){};
        \stepcounter{candles}
    }
}

\tikzset{candelabrum style/.style={
            anchor=north,draw,trapezium, trapezium stretches=true, 
            candle decoration,
            minimum height=5cm, minimum width=0.9cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

% original code by Paul Gaborit:
% tex.stackexchange.com/questions/72784/arrow-with-two-colors-with-tikz/#72793
\tikzset{
  double path/.style args={#1 colored by #2 and #3}{
    -,line join=bevel,line cap=rect,
    shorten >=0.04cm,
    shorten <=0.04cm,
    line width=#1,#2, % first path
    postaction={draw,-,#3,line width=(#1)/1.5,
                shorten <=(#1)/4,shorten >=2*(#1)/4}, % second path
  }
}

\tikzset{candelabrum branch/.style={
        double path=3pt colored by black!80!Goldenrod1 and Goldenrod1!60,bend #1,
        candle decoration,
    }
}

\begin{document}
\begin{tikzpicture}[remember picture]
\foreach \xpos in {0,1.2,2.4,3.6}{
\begin{scope}[xshift=\xpos cm,yshift=-1cm]
\node[candle=1cm]{};
\end{scope}
}
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
\node[candle]{};
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
\foreach \xpos in {0,1.2,2.4,3.6}{
\begin{scope}[xshift=\xpos cm,yshift=-1cm]
\node[candle=1cm]{};
\end{scope}
}
\end{tikzpicture}
% Candelabrum
\begin{tikzpicture}[remember picture, overlay]
\node[candelabrum style] (candelabrum) at (downbasecandle5.north){};
%\node[candelabrum base] at (candelabrum.south){};
\draw[left color=Goldenrod1!40, right color=Goldenrod2,candle decoration, candle shadow]
($(candelabrum.bottom left corner)-(0.4,0.6)$) parabola[bend at end] (candelabrum.bottom left corner)--
(candelabrum.bottom right corner) parabola ($(candelabrum.bottom right corner)+(0.4,-0.6)$)
--($(candelabrum.bottom left corner)-(0.4,0.6)$);
\draw[left color=Goldenrod1!40, right color=Goldenrod2,candle decoration, candle shadow]($(candelabrum.bottom left corner)-(0.4,0.6)$)-- ($(candelabrum.bottom right corner)+(0.4,-0.6)$)-- ($(candelabrum.bottom right corner)+(0.4,-0.9)$)--($(candelabrum.bottom left corner)-(0.4,0.9)$)--cycle;
% left
\path (downbasecandle1.north)edge[candelabrum branch=right](candelabrum.195);
\path (downbasecandle2.north)edge[candelabrum branch=right](candelabrum.115);
\path (downbasecandle3.north)edge[candelabrum branch=right](candelabrum.100);
\path (downbasecandle4.north)edge[candelabrum branch=right](candelabrum.97);
% right
\path (downbasecandle6.north)edge[candelabrum branch=left](candelabrum.83);
\path (downbasecandle7.north)edge[candelabrum branch=left](candelabrum.80);
\path (downbasecandle8.north)edge[candelabrum branch=left](candelabrum.65);
\path (downbasecandle9.north)edge[candelabrum branch=left](candelabrum.345);
\end{tikzpicture}
\end{document}

Disclaimer

Since I started drawing candles, at a given moment I stuck in shifting them with scope: from that the awful attempt with several tikzpictures needed to be remembered. This means that two compilation runs are necessary.


A very simple animation:

enter image description here

The code:

\documentclass[x11names]{beamer}
\usepackage{lmodern}
\setbeamertemplate{navigation symbols}{}
\usepackage{textpos}
\usepackage{tikz}
\usetikzlibrary{calc,positioning,shadows,decorations,decorations.pathmorphing,
   hobby,shapes.geometric}

% Animations:
% http://tex.stackexchange.com/questions/84513/highlighting-in-beamer-using-tikz-nodes/#84608
\tikzset{
    alt/.code args={<#1>#2#3}{%
      \alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}} 
    },
}

\tikzset{
  background shade/.style={#1},
  background shade/.default={left color=Gold1!20, right color=Goldenrod1},
  shade on/.style={alt=#1{}{background shade}},
}


% original code by percusse:
% http://tex.stackexchange.com/questions/39296/simulating-hand-drawn-lines#49961
\makeatletter
\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=3mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{0pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{1pt}{1pt}}
        }
    }
    \state{final}{}
}
\makeatother

\tikzset{candle decoration/.style={decorate, decoration={random steps,segment length=2pt,amplitude=0.3pt}}}
\tikzset{candle shadow/.style={drop shadow={shadow xshift=.4ex,shadow yshift=-.3ex}}}
\tikzset{stick candle/.style={
            draw,decorate, decoration={penciline,amplitude=3pt},rectangle, 
            anchor=north, minimum width=0.5cm, minimum height=#1,
            left color=white, right color=Honeydew2!80
            },
            stick candle/.default={2cm}
}

\tikzset{candle support style/.style={
            draw,rectangle, 
            decorate, decoration={penciline,amplitude=1.5pt},
            anchor=north, minimum width=0.9cm, minimum height=0.2cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

\tikzset{candle base style/.style={
            draw,semicircle,rotate=183,
            candle decoration,
            minimum width=0.6cm, minimum height=0.2cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

\newcounter{candles}
\setcounter{candles}{1}
\tikzset{candle/.code={
        \draw[candle decoration, candle shadow,
        background shade={bottom color=Snow2!30, top color=Snow4},
        shade on=<{1,4,5,7,9,11,14}>]
        (0,1) to[curve through={(-0.1,0.5)..(-0.2,0) .. (0.2,0) .. (0.1,0.5)}] (0,1);       
        \draw[draw=none,candle decoration, fill=LemonChiffon1]
        (0,0.45) to[curve through={(-0.05,0.25)..(-0.1,0) .. (0.1,0) .. (0.05,0.25)}] (0,0.45);
        \draw[decorate, decoration=penciline](0,0.125)--(0,-0.25)node(candle\thecandles){};     
        \node[stick candle=#1, candle shadow] (candlesupport\thecandles) at (candle\thecandles){}; 
        \node[candle support style, below=-0.1cm of candlesupport\thecandles](basecandle\thecandles) {};
        \node[candle base style, below=0.275cm of basecandle\thecandles](downbasecandle\thecandles){};
        \stepcounter{candles}
    }
}

\tikzset{candelabrum style/.style={
            anchor=north,draw,trapezium, trapezium stretches=true, 
            candle decoration,
            minimum height=5cm, minimum width=0.9cm,
            left color=Goldenrod1!40, right color=Goldenrod2,
            candle shadow
            },
}

% original code by Paul Gaborit:
% tex.stackexchange.com/questions/72784/arrow-with-two-colors-with-tikz/#72793
\tikzset{
  double path/.style args={#1 colored by #2 and #3}{
    -,line join=bevel,line cap=rect,
    shorten >=0.04cm,
    shorten <=0.04cm,
    line width=#1,#2, % first path
    postaction={draw,-,#3,line width=(#1)/1.5,
                shorten <=(#1)/4,shorten >=2*(#1)/4}, % second path
  }
}

\tikzset{candelabrum branch/.style={
        double path=3pt colored by black!80!Goldenrod1 and Goldenrod1!60,bend #1,
        candle decoration,
    }
}

\begin{document}
\begin{frame}
\begin{textblock}{2}[0.5,0.5](3,-1)
\scalebox{0.7}{
\begin{tikzpicture}[remember picture]
\pgfmathsetseed{12345}   
\foreach \xpos in {0,1.2,2.4,3.6}{
\begin{scope}[xshift=\xpos cm,yshift=-1cm]
\node[candle=1cm]{};
\end{scope}
}
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
\pgfmathsetseed{12345}   
\node[candle]{};
\end{tikzpicture}
\begin{tikzpicture}[remember picture]
\pgfmathsetseed{12345}   
\foreach \xpos in {0,1.2,2.4,3.6}{
\begin{scope}[xshift=\xpos cm,yshift=-1cm]
\node[candle=1cm]{};
\end{scope}
}
\end{tikzpicture}
% Candelabrum
\begin{tikzpicture}[remember picture, overlay]
\pgfmathsetseed{12345}   
\node[candelabrum style] (candelabrum) at (downbasecandle5.north){};
%\node[candelabrum base] at (candelabrum.south){};
\draw[left color=Goldenrod1!40, right color=Goldenrod2,candle decoration, candle shadow]
($(candelabrum.bottom left corner)-(0.4,0.6)$) parabola[bend at end] (candelabrum.bottom left corner)--
(candelabrum.bottom right corner) parabola ($(candelabrum.bottom right corner)+(0.4,-0.6)$)
--($(candelabrum.bottom left corner)-(0.4,0.6)$);
\draw[left color=Goldenrod1!40, right color=Goldenrod2,candle decoration, candle shadow]($(candelabrum.bottom left corner)-(0.4,0.6)$)-- ($(candelabrum.bottom right corner)+(0.4,-0.6)$)-- ($(candelabrum.bottom right corner)+(0.4,-0.9)$)--($(candelabrum.bottom left corner)-(0.4,0.9)$)--cycle;
% left
\path (downbasecandle1.north)edge[candelabrum branch=right](candelabrum.195);
\path (downbasecandle2.north)edge[candelabrum branch=right](candelabrum.115);
\path (downbasecandle3.north)edge[candelabrum branch=right](candelabrum.100);
\path (downbasecandle4.north)edge[candelabrum branch=right](candelabrum.97);
% right
\path (downbasecandle6.north)edge[candelabrum branch=left](candelabrum.83);
\path (downbasecandle7.north)edge[candelabrum branch=left](candelabrum.80);
\path (downbasecandle8.north)edge[candelabrum branch=left](candelabrum.65);
\path (downbasecandle9.north)edge[candelabrum branch=left](candelabrum.345);
\end{tikzpicture}
}
\end{textblock}
\end{frame}
\end{document}

(2) It is a better Menorah than both of the example pictures I gave! - Simd
Thanks!! :) To be honest, I tried to replicate as much as possible the second example: happy that it is better! - Claudio Fiandrino
I was too polite to mention the missing smiley face... :) - Simd
(1) For a while I was sure nobody noticed the missing smiley :) - Claudio Fiandrino
Beautiful animation! All that is missing is a way to specify the number of candles. - Simd
@ClaudioFiandrino: Why am I getting ! I can't find file `tikzlibrarydecorations.'.\pgf@temp ->decorations. pathmorphing l.6 ...ions. pathmorphing, hobby,shapes.geometric} when I try to execute your code? - Sony
@Sony: perhaps you have an outdated version of pgf. Could you check the version? - Claudio Fiandrino
@Raphael: you are right!! Actually there's a method, a manual one: remove from \foreach \xpos in {0,1.2,2.4,3.6} one or more candles, starting from the 0 from the left and from the 3.6 for the right; then, remove also the related \path (downbasecandle1.north)edge[candelabrum branch=right](candelabrum.195);. But it's not very comfortable, I see. - Claudio Fiandrino
@ClaudioFiandrino: I have the stable (2.10) version that comes with TexLive 2012. I uploaded the CVS, according to tex.stackexchange.com/questions/68608/update-tikz-pgf-on-mac and the complaint reduced to the lack of hobby only. - Sony
@Sony: If you miss the hobby package it means that your distribution has not been updated after September, because the hobby package has been released on September 3. - Claudio Fiandrino
A reference to find the hobby package: Where in the world is tikzlibraryhobby.code.tex? - Claudio Fiandrino
(1) As it's the last night of Hannukah, I have accepted your beautiful picture. However, I should say the other answer was also great and amazingly succinct! - Simd
1
[+28] [2012-12-08 15:35:04] Paul Gaborit

Sobriety and simplicity are good!

Here is my last attempt (edit: correct order) with animation (adapted from http://commons.wikimedia.org/wiki/File:Menorah.svg):

enter image description here

\documentclass[margin=2mm,tikz]{standalone}
\def\arraycandles{{0,4,3,2,1,-1,-2,-3,-4}}
\def\candlepath{
  to[out=0,in=-45] ++(0,5mm) to[out=-90,in=180] ++(0,-5mm)
  to[out=20,in=-45] ++(.3mm,2mm) to[out=-90,in=160] ++(-.3mm,-2mm)
}
\begin{document}
\foreach \day in {1,...,8}{%
  \begin{tikzpicture}[line width=2mm]
    \foreach \pos in {1,...,4}{
      \draw (0:\pos * 6mm) arc(0:-180:\pos * 6mm);
    }
    \foreach \pos in  {-4,...,4}{
      \fill
      (\pos * 6mm,.25mm) ++(1mm,0) -- ++(1mm,2mm) -- ++(-4mm,0) -- ++(1mm,-2mm) -- cycle
      (\pos * 6mm,2.5mm) ++(1mm,0) -- ++(1mm,2mm) -- ++(-4mm,0) -- ++(1mm,-2mm) -- cycle;
    }
    \draw (0,0) -- (0,4 * -6mm - 6mm);
    \fill (0,4 * -6mm - 5mm)
    -- ++(-10mm,-2mm) -- ++(0,-1mm) -- ++(20mm,0) -- ++(0,1mm) -- cycle;
    \foreach \candlenum in {0,...,\day}{
      \pgfmathtruncatemacro{\pos}{\arraycandles[\candlenum]}
      \draw[line width=.3mm,line join=miter,miter limit=20] (\pos*6mm,5mm)\candlepath;
    }
  \end{tikzpicture}%
}%
\end{document}

I think you're missing a couple of candles. - NVaughan
The Hannukah Menorah has to be able to hold exactly 9 candles (including the central one). On the n'th night it should have one in the middle and n starting from the far left. So this evening (the first night) it should have a total of 2 candles. - Simd
(2) @Raphael, I learned a different order. The central (shamash) candle is always present, just as you said. But on night n you have n additional candles starting at the far right, not the far left. (So in typesetting terms, these non-central candles are always flush right.) On any given night, the candles you have are lit from left to right. Random Googling seems to agree with me, as does Wikipedia. Are you sure of your order? Maybe there are multiple different traditions for this? - Ben Liblit
(2) @BenLiblit Thanks! I am certainly not sure. My family tends to take a fairly random attitude to the specifics of the holidays and I have learned over the years that it is often in a very small minority. However, bear in mind that Hebrew is written right to left and English left to right. I can imagine it swapped at some point in the diaspora. - Simd
2