- The template works if you replace old
day code
. Your errors are due to placing it outside of the calender environment.
- I started in the 2nd half of 2015 and the 1st half of 2015. To shift the cycle, initialize the
\cleanerID
to some value from 0 to 29. For the given requirement, it's 18.
- To pause and start, you can use the
at most
and at least
keywords of \ifdate
- To change two names, it just looked up the dates and changed them manually (via
equals=<reference>
) and colored them differently to show the effect.
Code
% DIN-A4 doublesided year calendar
% Author: Robert Krause
% License : Creative Commons attribution license
% Submitted to TeXample.net on 13 July 2012
\documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz} % Use the calendar.sty style
\usepackage{translator} % German Month and Day names
\usepackage{fancyhdr} % header and footer
\usepackage{fix-cm} % Large year in header
\usepackage[landscape, headheight = 2cm, margin=.5cm,
top = 3.2cm, nofoot]{geometry}
\usetikzlibrary{calc}
\usetikzlibrary{calendar}
\renewcommand*\familydefault{\sfdefault}
% User defined
\def\year{2015}
\def\nextyear{2016}
% Names of Holidays are inserted by employing this macro
\def\termin#1#2{
\node [anchor=north west, text width= 3.4cm] at
($(cal-#1.north west)+(3em, 0em)$) {\tiny{#2}};
}
%Header
\renewcommand{\headrulewidth}{0.0pt}
\setlength{\headheight}{10ex}
\chead{
%\fontsize{60}{70}\selectfont\textbf{\year}
\Large\textbf{Cleaning Plan}\hfill
}
%Footer
%\cfoot{\footnotesize\texttt{http://www.texample.net/}}
\pagenumbering{gobble}
% === Macro that returns a name if given a number from 0 to 29, "Error!" otherwise
\newcommand{\Person}[1]{%
\ifcase#1
Bryant Romans \or
Latricia Stoneman \or
Wilmer Lytton \or
Tommie Lenahan \or
Antonio Hoggard \or
Edward Lanctot \or
Chassidy Hyndman \or
Marianela Wojciechowski \or
Edna Kreitzer \or
Harrison Cruze \or
Marna Meloy \or
Georgene Joly \or
Ken Denley \or
William Loeffler \or
Young Spinelli \or
Glendora Bruss \or
Kraig Calloway \or
Chantal Callejas \or
Eleni Graziani \or
Ilene Crumpler \or
Ali Valliere \or
Sonya Barlett \or
Frederick Delacruz \or
Kayce Foti \or
Orval Kirchner \or
Corrinne Cahoon \or
Modesto Mulloy \or
Alessandra Rodenberger \or
Bernita Redman \or
Iola Eudy \else
Error! \fi
}
\xdef\cleanerID{18}
\begin{document}
\pagestyle{fancy}
\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=\year-07-01 to \year-12-31,
name=cal,
day yshift = 3em,
day code=
{ %=== Define macro that holds cleaners name on cleaning days, empty otherwise
\ifdate{Monday,Wednesday,Saturday}%
{ \ifdate{at most=\year-12-09}
{ \xdef\InsertName{\Person{\cleanerID}}
\pgfmathtruncatemacro{\newCleanerID}{mod(\cleanerID+1,30)}
\xdef\cleanerID{\newCleanerID}
}
{ \xdef\InsertName{}
}
}
{ \xdef\InsertName{}
}
\ifdate{equals=\year-07-04}
{ \xdef\InsertName{Iola Eudy}
\tikzset{every day/.style={fill=cyan!50!blue}}
}{}
\ifdate{equals=\year-07-27}
{ \xdef\InsertName{Ilene Crumpler}
\tikzset{every day/.style={fill=cyan!50!blue}}
}{}
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
%=== Insert the cleaners name here
\draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday} \InsertName
};
},
execute before day scope=
{
\ifdate{day of month=1}
{
% Shift right
\pgftransformxshift{4.8cm}
% Print month name
\draw (0,0)node [shape=rectangle, minimum height= .53cm,
text width = 4.4cm, fill = black, text= white, draw = black, text centered]
{\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}
};
}{}
\ifdate{workday}
{
% normal days are white
\tikzset{every day/.style={fill=white}}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
% Sundays and full holidays
\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{-.53*\pgfcalendarcurrentday cm}
}
];
\end{tikzpicture}
% Repeat the whole thing for the second page
%\pagebreak
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[dates=\nextyear-01-01 to \nextyear-06-30,
name=cal,
day yshift = 3em,
day code=
{ %=== Define macro that holds cleaners name on cleaning days, empty otherwise
\ifdate{Monday,Wednesday,Saturday}%
{ \ifdate{at least=\nextyear-01-03}
{ \xdef\InsertName{\Person{\cleanerID}}
\pgfmathtruncatemacro{\newCleanerID}{mod(\cleanerID+1,30)}
\xdef\cleanerID{\newCleanerID}
}
{ \xdef\InsertName{}
}
}
{ \xdef\InsertName{}
}
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
%=== Insert the cleaners name here
\draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday} \InsertName
};
},
execute before day scope=
{
\ifdate{day of month=1} {
% Shift right
\pgftransformxshift{4.8cm}
% Print month name
\draw (0,0)node [shape=rectangle, minimum height= .53cm,
text width = 4.4cm, fill = black, text= white, draw = black, text centered]
{
\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}
};
}{}
\ifdate{workday}
{
\tikzset{every day/.style={fill=white}}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
% Sundays and full holidays
\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{-.53*\pgfcalendarcurrentday cm}
}
];
\end{tikzpicture}
\end{center}
\end{document}
Output
Edit 1: Probably you wanted it a little more like this:
- it starts on 18. November 2015 and runs until October 2016.
- The chrismas break is excluded
- lene Crumpler and Iola Eudy have been swapped, but that was done manually
Code
% DIN-A4 doublesided year calendar
% Author: Robert Krause
% License : Creative Commons attribution license
% Submitted to TeXample.net on 13 July 2012
\documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{tikz} % Use the calendar.sty style
\usepackage{translator} % German Month and Day names
\usepackage{fancyhdr} % header and footer
\usepackage{fix-cm} % Large year in header
\usepackage[landscape, headheight = 2cm, margin=.5cm,
top = 3.2cm, nofoot]{geometry}
\usetikzlibrary{calc}
\usetikzlibrary{calendar}
\renewcommand*\familydefault{\sfdefault}
% User defined
\def\year{2015}
\def\nextyear{2016}
% Names of Holidays are inserted by employing this macro
\def\termin#1#2{
\node [anchor=north west, text width= 3.4cm] at
($(cal-#1.north west)+(3em, 0em)$) {\tiny{#2}};
}
%Header
\renewcommand{\headrulewidth}{0.0pt}
\setlength{\headheight}{3ex}
\chead{
%\fontsize{60}{70}\selectfont\textbf{\year}
\Large\textbf{Cleaning Plan}\hfill
}
%Footer
%\cfoot{\footnotesize\texttt{http://www.texample.net/}}
\pagenumbering{gobble}
% === Macro that returns a name if given a number from 0 to 29, "Error!" otherwise
\newcommand{\Person}[1]{%
\ifcase#1
Bryant Romans \or
Latricia Stoneman \or
Wilmer Lytton \or
Tommie Lenahan \or
Antonio Hoggard \or
Edward Lanctot \or
Chassidy Hyndman \or
Marianela Wojciechowski \or
Edna Kreitzer \or
Harrison Cruze \or
Marna Meloy \or
Georgene Joly \or
Ken Denley \or
William Loeffler \or
Young Spinelli \or
Glendora Bruss \or
Kraig Calloway \or
Chantal Callejas \or
Eleni Graziani \or
Ilene Crumpler \or
Ali Valliere \or
Sonya Barlett \or
Frederick Delacruz \or
Kayce Foti \or
Orval Kirchner \or
Corrinne Cahoon \or
Modesto Mulloy \or
Alessandra Rodenberger \or
Bernita Redman \or
Iola Eudy \else
Error! \fi
}
\xdef\cleanerID{18}
\begin{document}
\pagestyle{fancy}
\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=\year-11-01 to \nextyear-04-30,
name=cal,
day yshift = 3em,
day code=
{ %=== Define macro that holds cleaners name on cleaning days, empty otherwise
\ifdate{Monday,Wednesday,Saturday}%
{ \ifdate{between=\year-11-18 and \year-12-09, at least=\nextyear-01-03}
{ \xdef\InsertName{\Person{\cleanerID}}
\pgfmathtruncatemacro{\newCleanerID}{mod(\cleanerID+1,30)}
\xdef\cleanerID{\newCleanerID}
}
{ \xdef\InsertName{}
}
}
{ \xdef\InsertName{}
}
\ifdate{equals=\year-11-21}
{ \xdef\InsertName{Iola Eudy}
\tikzset{every day/.style={fill=cyan!50!blue!50}}
}{}
\ifdate{equals=\nextyear-01-06}
{ \xdef\InsertName{Ilene Crumpler}
\tikzset{every day/.style={fill=cyan!50!blue!50}}
}{}
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
%=== Insert the cleaners name here
\draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday} \InsertName
};
},
execute before day scope=
{
\ifdate{day of month=1}
{
% Shift right
\pgftransformxshift{4.8cm}
% Print month name
\draw (0,0)node [shape=rectangle, minimum height= .53cm,
text width = 4.4cm, fill = black, text= white, draw = black, text centered]
{\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth} \pgfcalendarcurrentyear}
};
}{}
\ifdate{workday}
{
% normal days are white
\tikzset{every day/.style={fill=white}}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
% Sundays and full holidays
\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{-.53*\pgfcalendarcurrentday cm}
}
];
\end{tikzpicture}
% Repeat the whole thing for the second page
%\pagebreak
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[dates=\nextyear-05-01 to \nextyear-10-31,
name=cal,
day yshift = 3em,
day code=
{ %=== Define macro that holds cleaners name on cleaning days, empty otherwise
\ifdate{Monday,Wednesday,Saturday}%
{ \ifdate{at least=\nextyear-01-03}
{ \xdef\InsertName{\Person{\cleanerID}}
\pgfmathtruncatemacro{\newCleanerID}{mod(\cleanerID+1,30)}
\xdef\cleanerID{\newCleanerID}
}
{ \xdef\InsertName{}
}
}
{ \xdef\InsertName{}
}
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
%=== Insert the cleaners name here
\draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday} \InsertName
};
},
execute before day scope=
{
\ifdate{day of month=1} {
% Shift right
\pgftransformxshift{4.8cm}
% Print month name
\draw (0,0)node [shape=rectangle, minimum height= .53cm,
text width = 4.4cm, fill = black, text= white, draw = black, text centered]
{
\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth} \pgfcalendarcurrentyear}
};
}{}
\ifdate{workday}
{
\tikzset{every day/.style={fill=white}}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=red!10}}}{}
% Sundays and full holidays
\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{-.53*\pgfcalendarcurrentday cm}
}
];
\end{tikzpicture}
\end{center}
\end{document}
Output
Best Answer
To get a different year, one could simply use
\year=2017
. But if this was undesirable then a\currentyear
macro could be used (optionally as a default argument to the\calperiod
macro).To get the year typeset at the corners of the matrix, I have used
append after command
. This requires that\currentyear
be set outside the scope of the matrix. Also a bit of extra space is required at the bottom of the matrix to avoid some overlapping with the year labels.