Fork me on GitHub

DIN-A4 doublesided year calendar

  1 % DIN-A4 doublesided year calendar
  2 % Author: Robert Krause
  3 % License : Creative Commons attribution license
  4 % Submitted to TeXample.net on 13 July 2012
  5 \documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
  6 \usepackage[utf8]{inputenc}
  7 \usepackage[ngerman]{babel}
  8 \usepackage[T1]{fontenc}
  9 \usepackage{tikz}             % Use the calendar.sty style
 10 
 11 %\usepackage{translator}    % German Month and Day names
 12 \usepackage{fancyhdr}        % header and footer
 13 \usepackage{fix-cm}        % Large year in header
 14 
 15 \usepackage[landscape, headheight = 2cm, margin=.5cm,
 16   top = 3.2cm, nofoot]{geometry}
 17 \usetikzlibrary{calc}
 18 \usetikzlibrary{calendar}
 19 %%%<
 20 \usepackage{verbatim}
 21 \usepackage[tightpage]{preview}
 22 \PreviewEnvironment{tikzpicture}
 23 \setlength\PreviewBorder{5pt}%
 24 %%%>
 25 \begin{comment}
 26 :Title: A calender for doublesided DIN-A4
 27 Tags: Calendar library;Calendars
 28 :Author: Robert Krause
 29 
 30 An example how the calendar package can be used to provide
 31 an doublesided calendar for the whole year.
 32 \end{comment}
 33 
 34 \renewcommand*\familydefault{\sfdefault}
 35 
 36 % User defined
 37 \def\year{2015}
 38 % Names of Holidays are inserted by employing this macro
 39 \def\termin#1#2{
 40   \node [anchor=north west, text width= 3.4cm] at
 41     ($(cal-#1.north west)+(3em, 0em)$) {\tiny{#2}};
 42 }
 43 
 44 %Header
 45 \renewcommand{\headrulewidth}{0.0pt}
 46 \setlength{\headheight}{10ex}
 47 \chead{
 48   \fontsize{60}{70}\selectfont\textbf{\year}
 49   \Large\textbf{Calendar}\hfill
 50 }
 51 %Footer
 52 \cfoot{\footnotesize\texttt{http://www.cnblogs.com/wangshixi12/}}
 53 
 54 
 55 
 56 \begin{document}
 57 \pagestyle{fancy}
 58 \begin{center}
 59 \begin{tikzpicture}[every day/.style={anchor = north}]
 60 \calendar[
 61   dates=\year-01-01 to \year-06-30,
 62   name=cal,
 63   day yshift = 3em,
 64   day code=
 65   {
 66     \node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
 67     minimum height= .53cm, text width = 4.4cm, draw = black]{\tikzdaytext};
 68     \draw (-1.8cm, -.1ex) node[anchor = west]{\footnotesize%
 69       \pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
 70   },
 71   execute before day scope=
 72   {
 73     \ifdate{day of month=1}
 74     {
 75       % Shift right
 76       \pgftransformxshift{4.8cm}
 77       % Print month name
 78       \draw (0,0)node [shape=rectangle, minimum height= .53cm,
 79         text width = 4.4cm, fill = white, text= black, draw = black,  text centered]
 80         {\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
 81     }{}
 82     \ifdate{workday}
 83     {
 84       % normal days are white
 85       \tikzset{every day/.style={fill=white}}
 86       % Vacation (Germany, Baden-Wuerrtemberg) gray background
 87       \ifdate{between=2012-12-24 and 2015-01-05}{%
 88         \tikzset{every day/.style={fill=white}}}{}
 89       \ifdate{between=2015-03-25 and 2015-04-05}{%
 90         \tikzset{every day/.style={fill=white}}}{}
 91       \ifdate{between=2015-05-21 and 2015-06-01}{%
 92         \tikzset{every day/.style={fill=white}}}{}
 93       \ifdate{between=2015-07-25 and 2015-09-07}{%
 94         \tikzset{every day/.style={fill=white}}}{}
 95       \ifdate{between=2015-10-28 and 2015-10-30}{%
 96         \tikzset{every day/.style={fill=white}}}{}
 97       \ifdate{between=2015-12-23 and 2014-01-04}{%
 98         \tikzset{every day/.style={fill=white}}}{}
 99     }{}
100     % Saturdays and half holidays (Christma's and New year's eve)
101     \ifdate{Saturday}{\tikzset{every day/.style={fill=white}}}{}
102     \ifdate{equals=12-24}{\tikzset{every day/.style={fill=white}}}{}
103     \ifdate{equals=12-31}{\tikzset{every day/.style={fill=white}}}{}
104     % Sundays and full holidays
105     \ifdate{Sunday}{\tikzset{every day/.style={fill=white}}}{}
106     \ifdate{equals=01-01}{\tikzset{every day/.style={fill=white}}}{}
107     \ifdate{equals=01-06}{\tikzset{every day/.style={fill=white}}}{}
108     \ifdate{equals=05-01}{\tikzset{every day/.style={fill=white}}}{}
109     \ifdate{equals=10-03}{\tikzset{every day/.style={fill=white}}}{}
110     \ifdate{equals=11-01}{\tikzset{every day/.style={fill=white}}}{}
111     \ifdate{equals=12-25}{\tikzset{every day/.style={fill=white}}}{}
112     \ifdate{equals=12-26}{\tikzset{every day/.style={fill=white}}}{}
113     % Christian holidays
114     \ifdate{equals=2015-03-29}{\tikzset{every day/.style={fill=white}}}{}
115     \ifdate{equals=2015-04-01}{\tikzset{every day/.style={fill=white}}}{}
116     \ifdate{equals=2015-05-09}{\tikzset{every day/.style={fill=white}}}{}
117     \ifdate{equals=2015-05-20}{\tikzset{every day/.style={fill=white}}}{}
118     \ifdate{equals=2015-05-30}{\tikzset{every day/.style={fill=white}}}{}
119   },
120  execute at begin day scope=
121   {
122     % each day is shifted down according to the day of month
123     \pgftransformyshift{-.53*\pgfcalendarcurrentday cm}
124   }
125 ];
126 \end{tikzpicture}
127 % Repeat the whole thing for the second page
128 \pagebreak
129 \begin{tikzpicture}[every day/.style={anchor = north}]
130 \calendar[dates=\year-07-01 to \year-12-31,
131   name=cal,
132   day yshift = 3em,
133   day code=
134   {
135     \node[name=\pgfcalendarsuggestedname,every day,shape=rectangle,
136       minimum height= .53cm, text width = 4.4cm, draw = black]{\tikzdaytext};
137     \draw (-1.8cm, -.1ex) node[anchor = west]
138     {
139       \footnotesize\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}
140     };
141   },
142   execute before day scope=
143   {
144     \ifdate{day of month=1} {
145     % Shift right
146     \pgftransformxshift{4.8cm}
147     % Print month name
148     \draw (0,0)node [shape=rectangle, minimum height= .53cm,
149       text width = 4.4cm, fill = white, text= black, draw = black, text centered]
150     {
151       \textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}
152     };
153   }{}
154   \ifdate{workday}
155   {
156     \tikzset{every day/.style={fill=white}}
157     % Vacation (Germany Baden-Wuerrtemberg)
158     \ifdate{between=2012-12-24 and 2015-01-05}{%
159       \tikzset{every day/.style={fill=white}}}{}
160     \ifdate{between=2015-03-25 and 2015-04-05}{%
161       \tikzset{every day/.style={fill=white}}}{}
162     \ifdate{between=2015-05-21 and 2015-06-01}{%
163       \tikzset{every day/.style={fill=white}}}{}
164     \ifdate{between=2015-07-25 and 2015-09-07}{%
165       \tikzset{every day/.style={fill=white}}}{}
166     \ifdate{between=2015-10-28 and 2015-10-30}{%
167       \tikzset{every day/.style={fill=white}}}{}
168     \ifdate{between=2015-12-23 and 2014-01-04}{%
169       \tikzset{every day/.style={fill=white}}}{}
170   }{}
171   % Sundays and full holidays
172   \ifdate{Sunday}{\tikzset{every day/.style={fill=white}}}{}
173   \ifdate{equals=01-01}{\tikzset{every day/.style={fill=white}}}{}
174   \ifdate{equals=01-06}{\tikzset{every day/.style={fill=white}}}{}
175   \ifdate{equals=05-01}{\tikzset{every day/.style={fill=white}}}{}
176   \ifdate{equals=10-03}{\tikzset{every day/.style={fill=white}}}{}
177   \ifdate{equals=11-01}{\tikzset{every day/.style={fill=white}}}{}
178   \ifdate{equals=12-25}{\tikzset{every day/.style={fill=white}}}{}
179   \ifdate{equals=12-26}{\tikzset{every day/.style={fill=white}}}{}
180   },
181   execute at begin day scope=
182   {
183    % Each day is shifted down according to the day of month
184     \pgftransformyshift{-.53*\pgfcalendarcurrentday cm}
185   }
186 ];
187 
188 \end{tikzpicture}
189 \end{center}
190 \end{document}
View Code

 

posted @ 2015-04-27 11:11  小奔奔  阅读(166)  评论(0编辑  收藏  举报