%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright 2012 Robert Krause
% Copyright @COPYRIGHTDATE@ Louis Paternault
% License : Creative Commons Attribution License
%
% Produced by `scal` version @VERSION@.
% http://git.framasoft.org/spalax/scal
%
% Compile it using `lualatex`
%
% History:
% This file has been posted by original author Robert Krause on TeXample.net
% [1] on 13 July 2012. I (Louis Paternault) used it as a base for this
% template, for the scal software.
%
% [1] http://www.texample.net/tikz/examples/a-calender-for-doublesided-din-a4/
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Compile it using LuaLaTeX
%$ lualatex $basename

\documentclass[10pt]{article}

\IfFileExists{hyperref.sty}{
  \usepackage[
    pdftitle={Calendar for years
        2014
    },
    pdfcreator={LuaLaTeX, using a file generated by `scal` version @VERSION@},
  ]{hyperref}
}{
  % Hyperref not loaded
}

\usepackage{fontspec}
\renewcommand{\familydefault}{\sfdefault}

\usepackage[english]{babel}
\usepackage[english]{translator} % Internationalized  Month and Day names

\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{calendar}

\usepackage[a4paper, landscape, margin=.5cm]{geometry}

\newcommand{\cellwidth}{\textwidth/1}
\newcommand{\cellheight}{\textheight/34}
\newcommand{\cellsep}{2pt}

% Names of Holidays are inserted by employing this macro. Arguments:
% - #1: First day of holidays
% - #2: Holiday name
\def\printholiday#1#2{
    \node [anchor=north west, align=right, text width={\cellwidth-\cellsep-7pt}] at
    ($(cal-#1.north west)$) {\tiny{#2\par}};
}

% Display weeks
% - #1 Day in which week is to be written
% - #2 Week number (as LaTeX code)
\def\printweek#1#2{
    \node [anchor=east, align=center, color=gray] at
    ($(cal-#1.east)$) {{#2\par}};
}

% Display the year. Arguments are:
% - #1: Year
% - #2: First day of year
% - #3: First day of last month of year
\newcommand{\printyear}[3]{
  \draw[fill=red!70, draw=none]
    ($(cal-#1-#2-01.north west)+(0, {2*\cellheight})$)
    rectangle
    ($(cal-#1-#3-01.south east)+(0, {2*\cellheight})$)
    node[midway, text=white]{\textbf{#1}};
}

\pagestyle{empty}

\begin{document}


\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\pgftransformyshift{\cellheight}
\calendar[
  dates=2014-3-01 to 2014-3-last,
  name=cal,
  day yshift = \cellheight,
  day code=
  {
    \node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
    minimum height= \cellheight, draw=black, text width = {\cellwidth-\cellsep-7pt}]{};
    \draw ($(\pgfcalendarsuggestedname.west)+(0  em,0)$)           node[anchor=west, color=gray]{\tikzdaytext};
    \draw ($(\pgfcalendarsuggestedname.west)+(1.5em,0)$) node[anchor=west, color=gray]{\footnotesize \pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
  },
  execute before day scope=
  {
    \ifdate{day of month=1}
    {
      % Shift right
      \pgftransformxshift{\cellwidth}
      % Print month name 
      \draw (0,0) node [shape=rectangle, minimum height= \cellheight,
          text width = {\cellwidth-\cellsep-7pt}, fill = red!70, text= white, draw = red!70, text centered]
        {\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
    }{}
    \ifdate{workday}
    {
      % normal days are white
      \tikzset{every day/.style={fill=white}}
      % Holidays
      \ifdate{between=2014-03-25 and 2014-03-25}{%
        \tikzset{every day/.style={fill=gray!30}}}{}
    }{}
    % Saturdays
    \ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
    % Sundays
    \ifdate{Sunday}{\tikzset{every day/.style={fill=red!20}}}{}
  },
 execute at begin day scope=
  {
    % each day is shifted down according to the day of month
    \pgftransformyshift{-{\cellheight * \number\pgfcalendarcurrentday}}
  }
];

% Print name of Holidays
    \printholiday{2014-03-25}{This is a holiday}

% Print week numbers
  \printweek{2014-03-05}{10}
  \printweek{2014-03-12}{11}
  \printweek{2014-03-19}{12}
  \printweek{2014-03-26}{13}

% Print years
  \printyear{2014}{03}{03}
\end{tikzpicture}
\end{center}
\end{document}
