我想用 Tikz 制作一个清洁日历。我家楼上有 30 个人,我们每周清洁地板三次:星期一、星期三和星期六。
我更改了日历模板,使其看起来像我想要的那样:
% 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}
% 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}
\begin{document}
\pagestyle{fancy}
\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=\year-01-01 to \year-06-30,
name=cal,
day yshift = 3em,
day code=
{
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
\draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
},
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=\year-07-01 to \year-12-31,
name=cal,
day yshift = 3em,
day code=
{
\node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
minimum height= .53cm, text width = 4.4cm, draw = gray]{\tikzdaytext};
\draw (-1.8cm, -.1ex) node[anchor = west]
{
\footnotesize\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}
};
},
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}
住在我这层楼的人的名字:
names=[Bryant Romans; Latricia Stoneman; Wilmer Lytton; Tommie Lenahan; Antonio Hoggard; Edward Lanctot; Chassidy Hyndman; Marianela Wojciechowski; Edna Kreitzer; Harrison Cruze; Marna Meloy; Georgene Joly; Ken Denley; William Loeffler; Young Spinelli; Glendora Bruss; Kraig Calloway; Chantal Callejas; Eleni Graziani; Ilene Crumpler; Ali Valliere; Sonya Barlett; Frederick Delacruz; Kayce Foti; Orval Kirchner; Corrinne Cahoon; Modesto Mulloy; Alessandra Rodenberger; Bernita Redman; Iola Eudy]
我需要帮助的地方
这三十个人必须打扫地板。首先是 Bryan,然后是 Latricia,依此类推。星期一、星期三和星期六。我会列出这三十个人的名单,然后让 LaTeX 日历将数组(从 Bryant 到 Iola)填充到日历中(如果以 Iola 结尾,则应该再次从 Bryan 开始)。我不知道该怎么做!如果你能帮忙就太好了。
此外,我希望从某一天开始暂停工作列表,然后在另一天重复;这样,如果有假期,就不会有人被写为必须做任何事情的人 - 但假期过后,它会从暂停前的下一个名字开始。如果我所在楼层的两个人更改了楼层服务,我想手动更改一些日期。
希望这里有人能帮助我!同时,非常感谢您的关注和参与。
答案1
您可以使用数字来跟踪当前负责清洁的人员。然后,您可以使用数字\ifcase<number>
构造返回与该数字相对应的名称。最后,修改以day code
执行以下操作:如果是清洁日,则检索清洁工的姓名,将其保存在宏中,然后步进计数器;如果不是,则将宏设置为空。最后,将宏添加到日期字符串中。以下只是我添加或更改的部分:
代码
返回名称的宏:
% === 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{0}
更新内容day code
:
day code=
{ %=== Define macro that holds cleaners name on cleaning days, empty otherwise
\ifdate{Monday,Wednesday,Saturday}%
{ \xdef\InsertName{\Person{\cleanerID}}
\pgfmathtruncatemacro{\newCleanerID}{mod(\cleanerID+1,30)}
\xdef\cleanerID{\newCleanerID}
}
{ \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
};
},
输出
正如你所看到的,经过10周,艾奥拉·尤迪是清洁工,它重新开始布莱恩特·罗马斯