-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOL-calendar-mods.sty
109 lines (102 loc) · 3.35 KB
/
OL-calendar-mods.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
\RequirePackage{graphicx}
\RequirePackage{relsize}
\RequirePackage{xcolor}
\newcommand{\SundayColor}{red}
\newcommand{\monthcolor}{blue}
\newcommand{\watermarkfile}{example-grid-100x100pt}
\newcommand{\addwatermark}{%
\node[inner sep=0pt,opacity=0.2,yshift=-1em]{\includegraphics[width=7em]{\watermarkfile}};%
}
\RequirePackage{etoolbox}
\newtoggle{sundayweek}
\newtoggle{dayheadings}
\def\dhlist{0/M,1/T,2/W,3/T,4/F,5/S,6/S}
\AtBeginDocument{
\iftoggle{sundayweek}
{\renewcommand\dhlist{0/S,1/M,2/T,3/W,4/T,5/F,6/S}}{}
}
% http://www.texample.net/tikz/examples/changing-the-default-calendar-layout/
\tikzstyle{week list sunday}=[
% Note that we cannot extend from week list,
% the execute before day scope is cumulative
execute before day scope={%
\ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{
% On first of month, except when first date in calendar.
\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
\pgftransformyshift{-\pgf@y}
}}{}%
},
execute at begin day scope={%
% Because for TikZ Monday is 0 and Sunday is 6,
% we can't directly use \pgfcalendercurrentweekday,
% but instead we define \c@pgf@counta (basically) as:
% (\pgfcalendercurrentweekday + 1) % 7
\pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
\ifnum\pgfcalendarcurrentweekday=6
\c@pgf@counta=0
\else
\c@pgf@counta=\pgfcalendarcurrentweekday
\advance\c@pgf@counta by 1
\fi
\pgf@x=\c@pgf@counta\pgf@x
% Shift to the right position for the day.
\pgftransformxshift{\pgf@x}
},
execute after day scope={
% Week is done, shift to the next line.
\ifdate{Saturday}{
\pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
\pgftransformyshift{-\pgf@y}
}{}%
},
% This should be defined, glancing from the source code.
tikz@lib@cal@width=7
]
% http://tex.stackexchange.com/a/10199/226
\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
yshift=0.5em,
month code={\node[every month,yshift=1.5em]
{\tikzmonthtext};},
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 \dhlist {
\pgf@xa=\d\pgf@xa%
\pgftransformxshift{\pgf@xa}%
\pgftransformyshift{0.85\pgf@ya}%
\node[every day,day heading,font=\relsize{-1}\bfseries,text=\monthcolor!80!black]{\l};%
}
}{}%
}%
]
% \newcount\colorcounter
% \colorcounter=1
% \newcommand{\stepmncolor}{%
% \ifcase\colorcounter\relax
% \or \global\renewcommand{\monthcolor}{RoyalBlue}%
% \or \global\renewcommand{\monthcolor}{OLGreen}%
% \or \global\renewcommand{\monthcolor}{Tomato}%
% \or \global\renewcommand{\monthcolor}{DarkOrchid}%
% \else \global\renewcommand{\monthcolor}{BrickRed}\colorcounter=0%
% \fi
% \global\advance\colorcounter by 1
% }
\tikzset{%
every calendar/.style={
at={(-7ex,4.5ex)},
day xshift=3ex,
day yshift=2.75ex,
\iftoggle{dayheadings}
{day letter headings}
{},
\iftoggle{sundayweek}
{week list sunday} % Sunday is first day of week
{week list}, % Sunday is last day of week
month label above centered,
month text={\bfseries\textcolor{\monthcolor}{\%mt} \%y0},
if={(Sunday) [\SundayColor]}
},
}