2

Given the example of tikzfoldingdodecahedron calendar at TeXample. Here's my MWE:

\documentclass{article}
% Folding + calendar example from the PGF manual.

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usetikzlibrary{calendar,folding}
\begin{document}
\sffamily\scriptsize
\begin{tikzpicture}
 [transform shape, every calendar/.style={at={(-8ex,4ex)},
 week list,
 month label above centered,
 month text=\bfseries\textcolor{red}{\%mt} \%y0,
 if={(Sunday) [black!50]}
 }]
 \tikzfoldingdodecahedron
 [
 folding line length=2.5cm,
     face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
     face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
     face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
     face 4={ \calendar [dates=\the\year-04-01 to \the\year-04-last];},
     face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
     face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
     face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
     face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
     face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
     face 10={\calendar [dates=\the\year-10-01 to \the\year-10-last];},
     face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
     face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];}
 ];
 \end{tikzpicture}
 \end{document}

I'd like to change the background color of specific month-faces according to my own choice. I'd tried to modify the relevant part like so:

\tikzfoldingdodecahedron[
    folding line length=2.5cm, fold/.style=dotted, every face/.fill=green
    face 1={\node(name)[] ...

However, it only fills the first face white and not as specified green (see below).

Screenshot of non-green calendar face

I also checked the tikz & pgf manual at page 660/661 but it wasn't helpful for this case.

So in essence, my question is:

How can we modify the original example to have colorful background colors of individual choice? Anybody has an idea to make my life colorful again?

  • 1
    Please edit your question to make your code compilable. As is, the code doesn't do anything to any face of anything - and that is, of course, to be expected. – cfr Nov 25 '17 at 19:20
  • I'm not sure, but I don't think this can be done. You can colour the nodes which make up the calendar, of course. But I don't think you can colour the polygons which contain them. – cfr Nov 26 '17 at 2:45
  • @cfr I added a MWE. – hatze Nov 26 '17 at 12:52
2

The faces are not really constructed: the content is just centered on the face and each edge is drawn separately. This makes it difficult to fill the faces with a specific colour. I have a slightly modified version which makes it possible to fill all faces with a specific colour, or all faces of a given size with a specific colour. However, if I understand you correctly, you want to colour specific faces. In that case I think the best solution is to explicitly draw the face as its content.

To make this easier you can use this command which draws the pentagon with the specified side length centred on the current position.

\newlength{\fll} %folding line length
\setlength{\fll}{2.5cm}
\newcommand{\colouredpentagon}[1]{\path[fill=#1] (-.5\fll,-0.68819\fll) --
++(\fll,0) -- ++(72:\fll) -- ++(144:\fll) -- ++(-144:\fll) -- 
(-.5\fll,-0.68819\fll) -- cycle;}

This can probably be done in a nicer way, but as a quick solution it should suffice.

Below is an example repeating your code for the calendar, but now colouring two faces.

\documentclass{standalone}
% Folding + calendar example from the PGF manual.

\usepackage{tikz}
\usepackage[utf8]{inputenc}
\usetikzlibrary{calendar,folding}
\begin{document}
\sffamily\scriptsize
\newlength{\fll} %folding line length
\setlength{\fll}{2.5cm}
\newcommand{\colouredpentagon}[1]{\path[fill=#1] (-.5\fll,-0.68819\fll) -- ++(\fll,0) -- ++(72:\fll) -- ++(144:\fll) -- ++(-144:\fll) -- (-.5\fll,-0.68819\fll) -- cycle;}
\begin{tikzpicture}
 [transform shape, every calendar/.style={at={(-8ex,4ex)},
 week list,
 month label above centered,
 month text=\bfseries\textcolor{red}{\%mt} \%y0,
 if={(Sunday) [black!50]}
 }]
 \tikzfoldingdodecahedron
 [
 folding line length=2.5cm,
     face 1={ \calendar [dates=\the\year-01-01 to \the\year-01-last];},
     face 2={ \calendar [dates=\the\year-02-01 to \the\year-02-last];},
     face 3={ \calendar [dates=\the\year-03-01 to \the\year-03-last];},
     face 4={ \colouredpentagon{yellow} \calendar [dates=\the\year-04-01 to \the\year-04-last];},
     face 5={ \calendar [dates=\the\year-05-01 to \the\year-05-last];},
     face 6={ \calendar [dates=\the\year-06-01 to \the\year-06-last];},
     face 7={ \calendar [dates=\the\year-07-01 to \the\year-07-last];},
     face 8={ \calendar [dates=\the\year-08-01 to \the\year-08-last];},
     face 9={ \calendar [dates=\the\year-09-01 to \the\year-09-last];},
     face 10={\colouredpentagon{pink} \calendar [dates=\the\year-10-01 to \the\year-10-last];},
     face 11={\calendar [dates=\the\year-11-01 to \the\year-11-last];},
     face 12={\calendar [dates=\the\year-12-01 to \the\year-12-last];}
 ];
 \end{tikzpicture}
 \end{document}

This should result in the following calendar: Calendar with two coloured faces

|improve this answer|||||

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.