commit
669823a7ac
2 changed files with 213 additions and 0 deletions
-
5.gitignore
-
208run.py
@ -0,0 +1,5 @@ |
|||||
|
*.pdf |
||||
|
*.log |
||||
|
*.synctex.gz |
||||
|
*.aux |
||||
|
*.tex |
@ -0,0 +1,208 @@ |
|||||
|
#!/usr/bin/python |
||||
|
|
||||
|
from datetime import timedelta |
||||
|
from datetime import date |
||||
|
import locale |
||||
|
|
||||
|
start_year = 2020 |
||||
|
start_date = date(start_year, 01, 01) |
||||
|
end_date = date(start_year, 12, 31) |
||||
|
|
||||
|
|
||||
|
def main(): |
||||
|
# german |
||||
|
locale.setlocale(locale.LC_TIME, "de_DE") |
||||
|
|
||||
|
fd = open("calender.tex", "w") |
||||
|
tex_write_header(fd) |
||||
|
|
||||
|
tex_write_calender_overview(fd) |
||||
|
|
||||
|
tex_write_weekly(fd) |
||||
|
|
||||
|
tex_write_footer(fd) |
||||
|
|
||||
|
|
||||
|
def tex_write_header(fd): |
||||
|
# \usepackage{fontspec}{} |
||||
|
fd.write(''' |
||||
|
\\documentclass[12pt,twoside]{scrartcl} |
||||
|
%%%%%%%% |
||||
|
% |
||||
|
% Latex-Vorlage fuer einen eigenen Wochenkalender |
||||
|
% Author Philipp Schoenberger |
||||
|
|
||||
|
\\usepackage[german, english]{babel} |
||||
|
\\usepackage[labelformat=empty]{caption} |
||||
|
\\usepackage{mathtools} |
||||
|
\\usepackage{xcolor} |
||||
|
\\usepackage{textcomp} |
||||
|
\\usepackage{marvosym} |
||||
|
\\usepackage[clock]{ifsym} |
||||
|
\\usepackage{geometry} |
||||
|
\\geometry{ |
||||
|
a5paper, |
||||
|
left=10mm, |
||||
|
top=10mm, |
||||
|
} |
||||
|
|
||||
|
\\newcommand\\myhrulefill[2][0pt]{\\leavevmode\\leaders\\hrule height #2 depth #1\\hfill\\kern0pt} |
||||
|
|
||||
|
|
||||
|
\\begin{document}{} |
||||
|
''') |
||||
|
|
||||
|
|
||||
|
def tex_write_footer(fd): |
||||
|
fd.write(''' |
||||
|
\\end{document} |
||||
|
''') |
||||
|
|
||||
|
|
||||
|
def tex_write_calender_overview(fd): |
||||
|
fd.write(''' |
||||
|
|
||||
|
\\thispagestyle{empty} |
||||
|
\\vspace*{-2em} |
||||
|
%\\renewcommand{\\arraystretch}{0.9} |
||||
|
%\\setlength{\\tabcolsep}{0.9mm} |
||||
|
\\begin{center} |
||||
|
\\Huge\\textbf{Jahres\\"ubersicht\\ ''') |
||||
|
fd.write(str(start_year)) |
||||
|
fd.write('''} |
||||
|
\\end{center} |
||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%% |
||||
|
% begin overview calender |
||||
|
\\renewcommand{\\arraystretch}{1.0} |
||||
|
\\setlength{\\tabcolsep}{0.9mm} |
||||
|
''') |
||||
|
for month in range(1, 12 + 1): |
||||
|
m = date(start_year, month, 01) |
||||
|
|
||||
|
if (month - 1) % 2 == 0: |
||||
|
fd.write('\\ \\newline\n\r') |
||||
|
|
||||
|
fd.write('''\\begin{minipage}[t]{0.5\\textwidth} |
||||
|
\\centering |
||||
|
''') |
||||
|
fd.write('\\textbf{\\large ' + m.strftime('%B') + '} ') |
||||
|
fd.write('''\\\\ |
||||
|
\\vspace{3mm} |
||||
|
\\tiny |
||||
|
\\begin{tabular}{ccccc|cc||} |
||||
|
''') |
||||
|
|
||||
|
# print weeknames |
||||
|
for i in range(0, 6 + 1): |
||||
|
curr_date = date(start_year, month, 01) |
||||
|
curr_date = curr_date + timedelta(days=i - curr_date.weekday()) |
||||
|
|
||||
|
fd.write('\\textbf{' + curr_date.strftime('%a') + '} ') |
||||
|
if i == 6: |
||||
|
fd.write('\\\\\n\r') |
||||
|
else: |
||||
|
fd.write(' & ') |
||||
|
|
||||
|
fd.write('\\hline') |
||||
|
|
||||
|
curr_date = date(start_year, month, 01) |
||||
|
weekline = " " + " &" * curr_date.weekday() |
||||
|
next_date = curr_date |
||||
|
while curr_date.month == next_date.month: |
||||
|
curr_date = next_date |
||||
|
next_date = curr_date + timedelta(days=1) |
||||
|
|
||||
|
weekline = weekline + " " + str(curr_date.day) |
||||
|
if (curr_date.weekday() == 6): # sunday |
||||
|
weekline = weekline + "\\\\\n\r " |
||||
|
else: |
||||
|
weekline = weekline + "&" |
||||
|
|
||||
|
weekline = weekline + (" &" * (5 - curr_date.weekday())) + "\\\\\n\r" |
||||
|
|
||||
|
fd.write(weekline) |
||||
|
|
||||
|
fd.write(''' |
||||
|
\\end{tabular} |
||||
|
\\end{minipage}''') |
||||
|
# if (month == 6): |
||||
|
# fd.write('\\newpage\n\r') |
||||
|
|
||||
|
fd.write(''' |
||||
|
% end overview calender |
||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%% |
||||
|
''') |
||||
|
|
||||
|
|
||||
|
def tex_write_weekly(fd): |
||||
|
print_start_date = start_date - timedelta(days=start_date.weekday()) |
||||
|
print_end_date = end_date + timedelta(days=6 - end_date.weekday()) |
||||
|
|
||||
|
print print_start_date.isoformat() |
||||
|
print print_end_date.isoformat() |
||||
|
|
||||
|
fd.write(''' |
||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%% |
||||
|
% begin real calender |
||||
|
\\flushleft |
||||
|
''') |
||||
|
|
||||
|
curr_date = print_start_date - timedelta(days=1) |
||||
|
|
||||
|
while True: |
||||
|
next_date = curr_date + timedelta(days=1) |
||||
|
if (print_end_date == next_date): |
||||
|
break |
||||
|
curr_date = next_date |
||||
|
|
||||
|
if curr_date.weekday() == 0: |
||||
|
fd.write('' + curr_date.strftime('%B')) |
||||
|
last_weekday = curr_date + timedelta(days=6) |
||||
|
fd.write('~' + curr_date.strftime('%Y')) |
||||
|
|
||||
|
if (curr_date.month != last_weekday.month): |
||||
|
fd.write(' \\/*') |
||||
|
fd.write('~' + last_weekday.strftime('%Y')) |
||||
|
fd.write('\\hrule') |
||||
|
|
||||
|
fd.write(''' |
||||
|
\\parbox[t][0.115\\paperheight]{\\textwidth}{ |
||||
|
\\flushleft |
||||
|
\\textbf{ |
||||
|
\\small ''') |
||||
|
fd.write('' + curr_date.strftime('%d')) |
||||
|
fd.write(' - ') |
||||
|
fd.write('' + curr_date.strftime('%A')) |
||||
|
fd.write(''' |
||||
|
} |
||||
|
\\hspace{5mm}~ |
||||
|
\\myhrulefill{0.5pt} |
||||
|
\\linebreak |
||||
|
\\noindent |
||||
|
\\begin{minipage}[t][2.3cm]{0.48\\textwidth} |
||||
|
\\hspace*{1.2cm} ~ |
||||
|
\\end{minipage} |
||||
|
\\begin{minipage}[t][6.1cm]{0.48\\textwidth} |
||||
|
\\begin{flushright} |
||||
|
~ |
||||
|
\\end{flushright} |
||||
|
\\end{minipage} |
||||
|
} |
||||
|
''') |
||||
|
|
||||
|
# start new page if sunday |
||||
|
if curr_date.weekday() == 6: |
||||
|
fd.write('\\newpage\n\r') |
||||
|
for i in range(1, 18): |
||||
|
fd.write('\\hspace{8mm}\n\r') |
||||
|
fd.write('\\myhrulefill{0.5pt}\n\r') |
||||
|
fd.write('\\newpage\n\r') |
||||
|
|
||||
|
fd.write(''' |
||||
|
% end real calender |
||||
|
%%%%%%%%%%%%%%%%%%%%%%%%%%% |
||||
|
''') |
||||
|
|
||||
|
|
||||
|
if __name__ == "__main__": |
||||
|
main() |
Write
Preview
Loading…
Cancel
Save
Reference in new issue