我有以下代码。
\documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[german]{translator}
\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}
%%%<
\usepackage{verbatim}
\usepackage[tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}%
%%%>
\renewcommand*\familydefault{\sfdefault}
% User defined
\def\year{2022}
% Names of Holidays are inserted by employing this macro
\def\termin#1#2{%
\node [anchor=north east, text width=1.5cm,font=\tiny,align=right] at (cal-#1.north east) {#2};
}
%Header
\renewcommand{\headrulewidth}{0.0pt}
\setlength{\headheight}{7ex}
\chead{
\fontsize{30}{40}\selectfont\textbf{Kalendar \year Sachsen-Anhalt}\hfill
}
\rhead{
\fontsize{20}{30}\selectfont\textbf{Kalendar\textit{\textcolor{red}{pedia\\}}}
\Large\textbf{Ferienkalender}
}
%Footer
\lfoot{\hspace{1em}\footnotesize\texttt{http://www.texample.net/}}
\begin{document}
\pagestyle{fancy}
\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=\year-01-01 to \year-12-31,
name=cal,
day yshift = 3.0em,
day code=
{
% print days name
\node[
name=\pgfcalendarsuggestedname,
every day,
minimum height=.53cm,
text width = 2.1cm,
draw = black,
yshift=-1.5pt]
{\rlap{\tikzdaytext}\hspace{1em} {\footnotesize\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}}};
},
execute before day scope=
{
\ifdate{day of month=1}
{
% Shift right
\pgftransformxshift{2.1cm+0.666em} % 0.666 = 2 * default inner sep of nodes
% Print month name
\node [
minimum height=.53cm,
text width = 2.1cm,
fill = white,
draw = black,
text centered
]
{\strut\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
}{}
\ifdate{workday}
{
% normal days are white
\tikzset{every day/.style={fill=white}}
% Vacation (Germany, Baden-Wuerrtemberg) yellow background
\ifdate{between=2021-12-24 and \year-01-9}{%
\tikzset{every day/.style={fill=yellow!90}}}{}
\ifdate{between=\year-02-12 and \year-02-20}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-04-11 and \year-04-016}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-05-23 and \year-05-28}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-7-14 and \year-8-24}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-12-21 and \year-12-31}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-10-24 and \year-11-5}{%
\tikzset{every day/.style={fill=yellow}}}{}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=yellow!50}}}{font=\bfseries}
% print week day number
% Sundays and full holidays
\ifdate{Sunday}{\tikzset{every day/.style={fill=orange!30}}}{}
\ifdate{equals=01-01}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=01-06}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=04-015}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=4-18}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=5-1}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=5-26}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=6-6}{\tikzset{every day/.style={fill=red!20}}}{}
% Christian holidays
\ifdate{equals=\year-10-3}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-10-31}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-12-25}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-15-26}{\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}
}
];
% names of days....
% Print name of Holidays
\termin{\year-01-03}{\hspace{0.6cm} \textcolor{black}{\textbf{1}}}
\termin{\year-01-01}{\hspace{0.3cm} \textcolor{red}{Neujahr}}
\termin{\year-01-06}{\hspace{0.3cm}\textcolor{red}{ Heilige Drei}\\\hspace{0.3cm}\textcolor{red}{ Könige}}
\termin{\year-02-28}{\hspace{0.3cm}Rosen-\\\hspace{0.3cm}montag}
\termin{\year-03-27}{\hspace{0.3cm}Beginn der\\\hspace{0.3cm}Sommerzeit}
\termin{\year-04-15}{\hspace{0.3cm} \textcolor{red}{Karfreitag}}
\termin{\year-04-17}{\hspace{0.3cm} \textcolor{red}{Ostern}}
\termin{\year-04-18}{\hspace{0.3cm} \textcolor{red}{Oster-}\\\hspace{0.3cm} \textcolor{red}{montag}}
\termin{\year-05-01}{\hspace{0.3cm} \textcolor{red}{Tag der} \\\hspace{0.3cm} \textcolor{red}{Arbeit}}
\termin{\year-05-08}{\hspace{0.3cm} Muttertag}
\termin{\year-05-26}{\hspace{0.3cm} \textcolor{red}{Christi}\\\hspace{0.3cm} \textcolor{red}{ Himmelfahrt}}
\termin{\year-06-05}{\hspace{0.3cm}Pfingsten}
\termin{\year-06-06}{\hspace{0.3cm} \textcolor{red}{Pfingst-}\\\hspace{0.3cm} \textcolor{red}{montag}}
\termin{\year-06-16}{\hspace{0.3cm}Fron-\\\hspace{0.3cm}leichnam}
\termin{\year-10-03}{\hspace{0.3cm} \textcolor{red}{tag der Dt.}\\\hspace{0.3cm} \textcolor{red}{ Einheit}}
\termin{\year-10-30}{\hspace{0.3cm}Ende der\\\hspace{0.3cm}Sommerzeit}
\termin{\year-10-31}{\hspace{0.3cm} \textcolor{red}{Reforma-}\\\hspace{0.3cm}\textcolor{red}{ tionstag}}
\termin{\year-11-01}{\hspace{0.3cm}Aller-\\\hspace{0.3cm}heiligen}
\termin{\year-11-27}{\hspace{0.3cm}1. Advent}
\termin{\year-12-25}{\hspace{0.3cm}\textcolor{red}{ 1. Weih-}\\\hspace{0.3cm} \textcolor{red}{nachtstag}}
\termin{\year-12-26}{\hspace{0.3cm}\textcolor{red}{ 2. Weih-}\\\hspace{0.3cm} \textcolor{red}{nachtstag}}
\termin{\year-12-31}{\hspace{0.3cm} Silvester}
\end{tikzpicture}
\end{center}
\end{document}
答案1
添加:
\foreach \month/\Mo/\label in {%
01/03/1,01/10/2,01/17/3,01/24/4,01/31/5,
02/07/6,02/14/7,02/21/8,02/28/9,
03/07/10,03/14/11,03/21/12,03/28/13,
04/04/14,04/11/15,04/18/16,04/25/17,
05/02/18,05/09/19,05/16/20,05/23/21,05/30/22,
06/06/23,06/13/24,06/20/25,06/27/26,
07/04/27,07/11/28,07/18/29,07/25/30,
08/01/31,08/08/32,08/15/33,08/22/34,08/29/35,
09/05/36,09/12/37,09/19/38,09/26/39,
10/03/40,10/10/41,10/17/42,10/24/43,10/31/44,
11/07/45,11/14/46,11/21/47,11/28/48,
12/05/49,12/12/50,12/19/51,12/26/52
}%
{\termin{\year-\month-\Mo}{\hspace{0.6cm} \textcolor{blue}{\textbf{\label}}}}
编辑代码如下:
\documentclass[landscape,a4paper, ngerman, 10pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[ngerman]{babel}
\usepackage[german]{translator}
\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}
%%%<
\usepackage{verbatim}
\usepackage[tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{10pt}%
%%%>
\renewcommand*\familydefault{\sfdefault}
% User defined
\def\year{2022}
% Names of Holidays are inserted by employing this macro
\def\termin#1#2{%
\node [anchor=north east, text width=1.5cm,font=\tiny,align=right] at (cal-#1.north east) {#2};
}
%Header
\renewcommand{\headrulewidth}{0.0pt}
\setlength{\headheight}{7ex}
\chead{
\fontsize{30}{40}\selectfont\textbf{Kalendar \year Sachsen-Anhalt}\hfill
}
\rhead{
\fontsize{20}{30}\selectfont\textbf{Kalendar\textit{\textcolor{red}{pedia\\}}}
\Large\textbf{Ferienkalender}
}
%Footer
\lfoot{\hspace{1em}\footnotesize\texttt{http://www.texample.net/}}
\begin{document}
\pagestyle{fancy}
\begin{center}
\begin{tikzpicture}[every day/.style={anchor = north}]
\calendar[
dates=\year-01-01 to \year-12-31,
name=cal,
day yshift = 3.0em,
day code=
{
% print days name
\node[
name=\pgfcalendarsuggestedname,
every day,
minimum height=.53cm,
text width = 2.1cm,
draw = black,
yshift=-1.5pt]
{\rlap{\tikzdaytext}\hspace{1em} {\footnotesize\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}}};
},
execute before day scope=
{
\ifdate{day of month=1}
{
% Shift right
\pgftransformxshift{2.1cm+0.666em} % 0.666 = 2 * default inner sep of nodes
% Print month name
\node [
minimum height=.53cm,
text width = 2.1cm,
fill = white,
draw = black,
text centered
]
{\strut\textbf{\pgfcalendarmonthname{\pgfcalendarcurrentmonth}}};
}{}
\ifdate{workday}
{
% normal days are white
\tikzset{every day/.style={fill=white}}
% Vacation (Germany, Baden-Wuerrtemberg) yellow background
\ifdate{between=2021-12-24 and \year-01-9}{%
\tikzset{every day/.style={fill=yellow!90}}}{}
\ifdate{between=\year-02-12 and \year-02-20}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-04-11 and \year-04-016}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-05-23 and \year-05-28}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-7-14 and \year-8-24}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-12-21 and \year-12-31}{%
\tikzset{every day/.style={fill=yellow}}}{}
\ifdate{between=\year-10-24 and \year-11-5}{%
\tikzset{every day/.style={fill=yellow}}}{}
}{}
% Saturdays and half holidays (Christma's and New year's eve)
\ifdate{Saturday}{\tikzset{every day/.style={fill=yellow!50}}}{font=\bfseries}
% print week day number
% Sundays and full holidays
\ifdate{Sunday}{\tikzset{every day/.style={fill=orange!30}}}{}
\ifdate{equals=01-01}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=01-06}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=04-015}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=4-18}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=5-1}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=5-26}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=6-6}{\tikzset{every day/.style={fill=red!20}}}{}
% Christian holidays
\ifdate{equals=\year-10-3}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-10-31}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-12-25}{\tikzset{every day/.style={fill=red!20}}}{}
\ifdate{equals=\year-15-26}{\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}
}
];
% names of days....
% Print name of Holidays
%\termin{\year-01-03}{\hspace{0.6cm} \textcolor{black}{\textbf{1}}}
\termin{\year-01-01}{\hspace{0.3cm} \textcolor{red}{Neujahr}}
\termin{\year-01-06}{\hspace{0.3cm}\textcolor{red}{ Heilige Drei}\\\hspace{0.3cm}\textcolor{red}{ Könige}}
\termin{\year-02-28}{\hspace{0.3cm}Rosen-\\\hspace{0.3cm}montag}
\termin{\year-03-27}{\hspace{0.3cm}Beginn der\\\hspace{0.3cm}Sommerzeit}
\termin{\year-04-15}{\hspace{0.3cm} \textcolor{red}{Karfreitag}}
\termin{\year-04-17}{\hspace{0.3cm} \textcolor{red}{Ostern}}
\termin{\year-04-18}{\hspace{0.3cm} \textcolor{red}{Oster-}\\\hspace{0.3cm} \textcolor{red}{montag}}
\termin{\year-05-01}{\hspace{0.3cm} \textcolor{red}{Tag der} \\\hspace{0.3cm} \textcolor{red}{Arbeit}}
\termin{\year-05-08}{\hspace{0.3cm} Muttertag}
\termin{\year-05-26}{\hspace{0.3cm} \textcolor{red}{Christi}\\\hspace{0.3cm} \textcolor{red}{ Himmelfahrt}}
\termin{\year-06-05}{\hspace{0.3cm}Pfingsten}
\termin{\year-06-06}{\hspace{0.3cm} \textcolor{red}{Pfingst-}\\\hspace{0.3cm} \textcolor{red}{montag}}
\termin{\year-06-16}{\hspace{0.3cm}Fron-\\\hspace{0.3cm}leichnam}
\termin{\year-10-03}{\hspace{0.3cm} \textcolor{red}{tag der Dt.}\\\hspace{0.3cm} \textcolor{red}{ Einheit}}
\termin{\year-10-30}{\hspace{0.3cm}Ende der\\\hspace{0.3cm}Sommerzeit}
\termin{\year-10-31}{\hspace{0.3cm} \textcolor{red}{Reforma-}\\\hspace{0.3cm}\textcolor{red}{ tionstag}}
\termin{\year-11-01}{\hspace{0.3cm}Aller-\\\hspace{0.3cm}heiligen}
\termin{\year-11-27}{\hspace{0.3cm}1. Advent}
\termin{\year-12-25}{\hspace{0.3cm}\textcolor{red}{ 1. Weih-}\\\hspace{0.3cm} \textcolor{red}{nachtstag}}
\termin{\year-12-26}{\hspace{0.3cm}\textcolor{red}{ 2. Weih-}\\\hspace{0.3cm} \textcolor{red}{nachtstag}}
\termin{\year-12-31}{\hspace{0.3cm} Silvester}
% add
\foreach \month/\Mo/\label in {%
01/03/1,01/10/2,01/17/3,01/24/4,01/31/5,
02/07/6,02/14/7,02/21/8,02/28/9,
03/07/10,03/14/11,03/21/12,03/28/13,
04/04/14,04/11/15,04/18/16,04/25/17,
05/02/18,05/09/19,05/16/20,05/23/21,05/30/22,
06/06/23,06/13/24,06/20/25,06/27/26,
07/04/27,07/11/28,07/18/29,07/25/30,
08/01/31,08/08/32,08/15/33,08/22/34,08/29/35,
09/05/36,09/12/37,09/19/38,09/26/39,
10/03/40,10/10/41,10/17/42,10/24/43,10/31/44,
11/07/45,11/14/46,11/21/47,11/28/48,
12/05/49,12/12/50,12/19/51,12/26/52
}%
{\termin{\year-\month-\Mo}{\hspace{0.6cm} \textcolor{blue}{\textbf{\label}}}}
\end{tikzpicture}
\end{center}
\end{document}
输出:TL2019