Example: Birthday calendar

Published 2012-11-18 | Author: Hakon Malmedal
A birthday calendar made with TikZ

Download as: [PDF] [TEX]

Birthday calendar

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% Birthday calendar
% Author: Hakon Malmedal
\documentclass[fontsize=20pt]{scrartcl}
\usepackage[norsk]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[margin=1cm,a4paper,landscape]{geometry}
\pagestyle{empty}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{calendar,fit}
\usepackage{expl3,xparse}
%% Adapted from http://tex.stackexchange.com/a/10199/4771
\makeatletter%
\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
execute before day scope={ \ifdate{day of month=1}{%
\pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
\pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
\pgftransformyshift{-\pgf@ya}
\foreach \d/\l in {0/Mandag,1/Tirsdag,2/Onsdag,3/Torsdag,%
4/Fredag,5/Lørdag,6/Søndag} {
\pgf@xa=\d\pgf@xa%
\pgftransformxshift{\pgf@xa-\cellwidth/2}%
\pgftransformyshift{\pgf@ya}%
\node[above=-0.5ex,day heading]{\l};%
}
}{}%
}%
]
\makeatother%
%% End
%% Adapted from pgf source
\def\pgfcalendarmonthname#1{%
\translate{\ifcase#1\or Januar\or Februar\or Mars\or April\or
Mai\or Juni\or Juli\or August\or September\or Oktober\or
November\or Desember\fi}%
}
\makeatletter
\tikzstyle{month label above centered}=[%
execute before day scope={%
\ifdate{day of month=1}{%
{
\pgfmathsetlength{\pgf@xa}{\tikz@lib@cal@xshift}%
\pgf@xb=\tikz@lib@cal@width\pgf@xa%
\advance\pgf@xb by-\pgf@xa%
\pgf@xb=.5\pgf@xb%
\pgftransformxshift{\pgf@xb}%
\pgftransformxshift{-\cellwidth/2}%
\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
\pgftransformyshift{0.333\pgf@y}
\tikzmonthcode%
}
}{}},
every month/.append style={anchor=base}
]
\makeatother
%% End
\ExplSyntaxOn
%% Adapted from http://tex.stackexchange.com/a/56214/4771
%%
% first of all we define the user level commands
\NewDocumentCommand{\addtext}{ m }{ \bdaycal_input_add:n { #1 } }
\NewDocumentCommand{\addtextyear}{ mm }{ \bdaycal_input_add_y:nn { #1 } { #2 } }
\NewDocumentCommand{\showtext}{ }{ \bdaycal_output_direct: }
% allocate variable:
% a sequence for global storage of the inputs;
\seq_new:N \g_bdaycal_input_seq
% store globally an input in the sequence
\cs_new:Npn \bdaycal_input_add:n #1
{
\seq_gput_right:Nn \g_bdaycal_input_seq { #1 }
}
\cs_new:Npn \bdaycal_input_add_y:nn #1 #2
{
\seq_gput_right:Nn \g_bdaycal_input_seq { #1 ~ ( \int_to_arabic:n
{ \pgfcalendarifdateyear - #2 } ) }
}
% how to output in direct order; we simply do a mapping function calling
% \bdaycal_print:n after incrementing the counter
\cs_new_protected:Npn \bdaycal_output_direct:
{
\seq_map_inline:Nn \g_bdaycal_input_seq
{
\bdaycal_print:n { ##1 }
}
\seq_gclear:N \g_bdaycal_input_seq
}
% the printing macro; change here for adapting to your wishes
 

Comments

Adding comments is currently not enabled.