Last active
December 7, 2017 17:15
-
-
Save StSav012/dbdb99e043bff228e299f1a27e0962e7 to your computer and use it in GitHub Desktop.
Calendar Generator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[a4paper,landscape,14pt]{extarticle} | |
\usepackage[utf8]{inputenc} | |
\usepackage[T2A,T1]{fontenc} | |
\usepackage[russian,english]{babel} | |
\usepackage{color} | |
\usepackage{tabularx} | |
\usepackage[margin=1cm]{geometry} | |
\usepackage{pgffor,etoolbox} | |
\usepackage{hyperref} | |
\hypersetup{pdftex, pdftitle=Calendar, pdfauthor=StSav012} | |
\pagenumbering{gobble} | |
\setlength\tabcolsep{2mm} | |
\def\holidays{} % (optional) list of holidays to mark | |
\forcsvlist{\listadd\holidays}{ | |
January1, January2, January3, January4, January5, January8, | |
February23, | |
March8, March9, | |
April30, | |
May1, May2, May9, | |
June11, June12, | |
November4, November5, | |
December31, | |
} | |
\def\notholidays{} % (optional) list of the working days that are not supposed to be | |
\forcsvlist{\listadd\notholidays}{ | |
April28, | |
June9, | |
December29, | |
} | |
\newenvironment{calendarmonth}{ | |
\newcommand\russian[1]{\raggedleft{\selectlanguage{russian}##1}\arraybackslash} | |
\newcommand\english[1]{\raggedright{\selectlanguage{english}##1}\arraybackslash} | |
\newcommand\anyday{\color[rgb]{0.0,0.0,0.0}} | |
\newcommand\holiday{\color[rgb]{0.8,0.2,0.2}} | |
\newcommand\week{\color[rgb]{0.2,0.2,0.8}} | |
\newcommand\head{\bfseries\centering\Huge} | |
\renewcommand{\tabularxcolumn}[1]{>{\centering}m{##1}} | |
\renewcommand{\arrayrulewidth}{2.5pt} | |
\newcolumntype{W}{>{\week\centering\arraybackslash}X} | |
\newcolumntype{D}{>{\anyday\bfseries\centering\arraybackslash}X} | |
\newcolumntype{H}{>{\holiday\bfseries\centering\arraybackslash}X} | |
\newcommand{\header}[3]{ | |
\renewcommand{\arraystretch}{2} | |
\begin{tabularx}{\textwidth}{XXXXXXXX} | |
\hline | |
\multicolumn{3}{X}{\head \english{##1}} & | |
\multicolumn{2}{X}{\head ##3} & | |
\multicolumn{3}{X}{\head \russian{##2}} \\ | |
\end{tabularx} | |
\renewcommand{\arraystretch}{1.2} | |
} | |
\newcommand{\calendarday}{ | |
\addtocounter{day}{1} | |
\ifnumgreater{\value{day}}{\mdc}{ | |
}{ | |
\ifnumgreater{\value{day}}{0}{ | |
\xifinlist{\emn\theday}{\holidays}{\holiday}{} | |
\xifinlist{\emn\theday}{\notholidays}{\anyday}{} | |
\theday | |
}{ | |
} | |
\addtocounter{wd}{1} | |
} | |
} | |
\newcommand{\weekdays}{ | |
\renewcommand{\arraystretch}{1.2} | |
{ | |
\small | |
\begin{tabularx}{\textwidth}{WDDDDDHH} | |
\hline | |
\english{Week} & | |
\english{Monday} & | |
\english{Tuesday} & | |
\english{Wednesday} & | |
\english{Thursday} & | |
\english{Friday} & | |
\english{Saturday} & | |
\english{Sunday} | |
\\ | |
\russian{Неделя} & | |
\russian{Понедельник} & | |
\russian{Вторник} & | |
\russian{Среда} & | |
\russian{Четверг} & | |
\russian{Пятница} & | |
\russian{Суббота} & | |
\russian{Воскресенье} | |
\\ | |
\hline | |
\end{tabularx} | |
} | |
} | |
\renewcommand{\arraystretch}{2} | |
}{ | |
\renewcommand{\arraystretch}{1.2} | |
} | |
\title{Auto Generated Calendar} | |
\author{StSav012} | |
\date{2017-12-06} | |
\begin{document} | |
\newcounter{year} | |
\setcounter{year}{2018} % set manually to the year you want to get the Calendar for | |
\newcounter{week} | |
\setcounter{week}{1} | |
\newcounter{day} | |
\newcounter{iwd} | |
\setcounter{iwd}{1} % set manually to the initial day of the year counting from Monday | |
\newcounter{wd} | |
\setcounter{wd}{\value{iwd}} | |
\newcounter{FebDays} | |
\ifnumodd{\value{year}}{\setcounter{FebDays}{28}}{\ifnumodd{\value{year}/2}{\setcounter{FebDays}{28}}{\setcounter{FebDays}{29}}} | |
\begin{center} | |
\foreach \emn/\rmn/\mdc in {January/Январь/31, | |
February/Февраль/\theFebDays, | |
March/Март/31, | |
April/Апрель/30, | |
May/Май/31, | |
June/Июнь/30, | |
July/Июль/31, | |
August/Август/31, | |
September/Сентябрь/30, | |
October/Октябрь/31, | |
November/Ноябрь/30, | |
December/Декабрь/31 | |
}{ | |
\begin{calendarmonth} | |
\setcounter{iwd}{\value{wd}} | |
\ifnumequal{\value{iwd}}{1}{}{\addtocounter{week}{-1}} | |
\header{\emn}{\rmn}{\theyear} | |
\weekdays{} | |
\setcounter{day}{1} | |
\addtocounter{day}{-\value{iwd}} | |
\whileboolexpr{test{\ifnumless{\value{day}}{\mdc}}} { | |
\ifnumgreater{\value{iwd}+\mdc}{35}{\ifnumless{\value{day}}{1}{\large}{\ifnumgreater{\value{day}+7}{\mdc}{\large}{\Huge}}}{\Huge} | |
\setcounter{wd}{1} | |
\begin{tabularx}{\textwidth}{WDDDDDHH} | |
\ifnumgreater{\value{week}}{0}{\theweek}{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
& | |
\calendarday{} | |
\\ \hline | |
\end{tabularx} | |
\addtocounter{week}{1} | |
} | |
\end{calendarmonth} | |
\clearpage | |
} | |
\end{center} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment