如何导入 iCal 格式并在 Tikz 中制作时间表?

如何导入 iCal 格式并在 Tikz 中制作时间表?

我有 .ics 格式的文件。我想用 LaTeX 导入它并将其转换为时间表(自动)。有什么建议吗?我找到了一个关于如何在 Tikz 中创建时间表的最小工作示例。由于我不知道如何导入 .ics 文件,我无法对其进行任何更改。

%!TEX encoding = UTF-8 Unicode
% Author: Laurent Dutriaux
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier} % Utilisation des polices texte
\usepackage{tikz}
\usetikzlibrary[positioning]
\usetikzlibrary{patterns}
\usepackage[french]{babel} % styles français
\title{A simple Timetable}
\author{Laurent Dutriaux}
\date{\today}
\newcommand{\daywidth}{2.2 cm}
\begin{document}

\maketitle

\begin{tikzpicture}[x=\daywidth, y=-1cm, node distance=0 cm,outer sep = 0pt]
% Style for Days
\tikzstyle{day}=[draw, rectangle,  minimum height=1cm, minimum width=\daywidth, fill=yellow!20,anchor=south west]
% Style for hours
\tikzstyle{hour}=[draw, rectangle, minimum height=1 cm, minimum width=1.5 cm, fill=yellow!30,anchor=north east]

% Styles for events
% Duration of sequences
\tikzstyle{hours}=[rectangle,draw, minimum width=\daywidth, anchor=north west,text centered,text width=5 em]
\tikzstyle{1hour}=[hours,minimum height=1cm]
\tikzstyle{2hours}=[hours,minimum height=2cm]
\tikzstyle{3hours}=[hours,minimum height=3cm]
%Style for type of sequence 
\tikzstyle{Ang2h}=[2hours,fill=green!20]
\tikzstyle{Phys2h}=[2hours,fill=red!20]
\tikzstyle{Math2h}=[2hours,fill=blue!20]
\tikzstyle{TIPE2h}=[2hours,fill=blue!10]
\tikzstyle{TP2h}=[2hours, pattern=north east lines, pattern color=magenta]
\tikzstyle{G3h}=[3hours, pattern=north west lines, pattern color=magenta!60!white]
\tikzstyle{Planche}=[1hour,fill=white]
% Positioning labels for days and hours
\node[day] (lundi) at (1,8) {Lundi};
\node[day] (mardi) [right = of lundi] {Mardi};
\node[day] (mercredi) [right = of mardi] {Mercredi};
\node[day] (jeudi) [right = of mercredi] {Jeudi};
\node[day] (vendredi) [right = of jeudi] {Vendredi};
\node[hour] (8-9) at (1,8) {8-9};
\node[hour] (9-10) [below = of 8-9] {9-10};
\node[hour] (10-11) [below= of 9-10] {10-11};
\node[hour] (11-12) [below = of 10-11] {11-12};
\node[hour] (12-13) [below  = of 11-12] {12-13};
\node[hour] (13-14) [below = of 12-13] {13-14};
\node[hour] (14-15) [below = of 13-14] {14-15};
\node[hour] (15-16) [below = of 14-15] {15-16};
\node[hour] (16-17) [below = of 15-16] {16-17};
\node[hour] (17-18) [below = of 16-17] {17-18};
\node[hour] (18-19) [below = of 17-18] {18-19};
%Position of sequences
\node[Ang2h] at (1,10) {Anglais};
\node[Phys2h] at (1,8) {Physique};
\node[Phys2h] at (2,8) {Physique};
\node[Phys2h] at (4,8) {Physique};
\node[Phys2h] at (5,10) {Physique};
\node[Math2h] at (2,10) {Maths};
\node[Math2h] at (2,14) {Maths};
\node[Math2h] at (3,8) {Maths};
\node[Math2h] at (4,10) {Maths};
\node[Math2h] at (5,8) {Maths};
\node[TIPE2h] at (1,14) {TIPE};
\node[TIPE2h] at (1,16) {TIPE};
\node[TIPE2h] at (2,16) {TIPE};
\node[TIPE2h] at (3,10) {TIPE};
\node[TIPE2h] at (5,14) {TIPE};
\node[TIPE2h] at (5,16) {TIPE};
\node[TP2h] at (3,14) {Phys ou SI};
\node[TP2h] at (3,16) {SI ou Phys};
\node[Planche] at (1,13) {Planche};
\node[Planche] at (1,18) {Colle};
\node[Planche] at (4,13.5) {Planche};
\end{tikzpicture}


\end{document}

那么我该如何导入 .ics 文件并根据它制作时间表呢?如果可以在 latex 表中导入 ics 文件,那就太好了(我喜欢经典的设计)。

事实上,我不是唯一一个有这个问题的人。这里还有另一个人有同样的挣扎。但没有人有答案。

希望您有个主意?这项任务最大的麻烦(对我来说)是将数据包含在 LaTeX 中,然后对其进行排序(以便将其放在正确的位置)。

提前非常感谢您!

PS!我希望时间刻度位于 y 轴上,其中 x=0,日期位于 x 轴上,其中 y=0。然后将主题放在带有 SUMMARY\DESCRIPTION\LOCATION 的方框中。我很乐意提供帮助 - 也许可以提供帮助 - 但首先,我必须学会如何导入 .ics 文件以及如何构造/标记它,以便我可以使用 tikz 或“仅”一个表格。

这里是数据文件:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//skema.derfor.dk//EN
BEGIN:VEVENT
UID:1@314159265
DTSTAMP:20150824T160000
DTSTART:20150824T160000
DTEND:20150824T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:2@314159265
DTSTAMP:20150831T160000
DTSTART:20150831T160000
DTEND:20150831T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:3@314159265
DTSTAMP:20150907T160000
DTSTART:20150907T160000
DTEND:20150907T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:4@314159265
DTSTAMP:20150914T160000
DTSTART:20150914T160000
DTEND:20150914T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:5@314159265
DTSTAMP:20150921T160000
DTSTART:20150921T160000
DTEND:20150921T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:6@314159265
DTSTAMP:20150928T160000
DTSTART:20150928T160000
DTEND:20150928T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:7@314159265
DTSTAMP:20151005T160000
DTSTART:20151005T160000
DTEND:20151005T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:8@314159265
DTSTAMP:20151102T160000
DTSTART:20151102T160000
DTEND:20151102T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:9@314159265
DTSTAMP:20151109T160000
DTSTART:20151109T160000
DTEND:20151109T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:10@314159265
DTSTAMP:20151116T160000
DTSTART:20151116T160000
DTEND:20151116T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:11@314159265
DTSTAMP:20151123T160000
DTSTART:20151123T160000
DTEND:20151123T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:12@314159265
DTSTAMP:20151130T160000
DTSTART:20151130T160000
DTEND:20151130T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:13@314159265
DTSTAMP:20151207T160000
DTSTART:20151207T160000
DTEND:20151207T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:14@314159265
DTSTAMP:20151214T160000
DTSTART:20151214T160000
DTEND:20151214T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:15@314159265
DTSTAMP:20150826T100000
DTSTART:20150826T100000
DTEND:20150826T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:16@314159265
DTSTAMP:20150902T100000
DTSTART:20150902T100000
DTEND:20150902T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:17@314159265
DTSTAMP:20150909T100000
DTSTART:20150909T100000
DTEND:20150909T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:18@314159265
DTSTAMP:20150916T100000
DTSTART:20150916T100000
DTEND:20150916T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:19@314159265
DTSTAMP:20150923T100000
DTSTART:20150923T100000
DTEND:20150923T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:20@314159265
DTSTAMP:20150930T100000
DTSTART:20150930T100000
DTEND:20150930T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:21@314159265
DTSTAMP:20151007T100000
DTSTART:20151007T100000
DTEND:20151007T120000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:22@314159265
DTSTAMP:20151030T110000
DTSTART:20151030T110000
DTEND:20151030T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:23@314159265
DTSTAMP:20151106T110000
DTSTART:20151106T110000
DTEND:20151106T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:24@314159265
DTSTAMP:20151113T110000
DTSTART:20151113T110000
DTEND:20151113T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:25@314159265
DTSTAMP:20151120T110000
DTSTART:20151120T110000
DTEND:20151120T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:26@314159265
DTSTAMP:20151127T110000
DTSTART:20151127T110000
DTEND:20151127T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:27@314159265
DTSTAMP:20151204T110000
DTSTART:20151204T110000
DTEND:20151204T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:28@314159265
DTSTAMP:20151211T110000
DTSTART:20151211T110000
DTEND:20151211T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater V (1514-121) 
END:VEVENT
BEGIN:VEVENT
UID:29@314159265
DTSTAMP:20150825T130000
DTSTART:20150825T130000
DTEND:20150825T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:30@314159265
DTSTAMP:20150901T130000
DTSTART:20150901T130000
DTEND:20150901T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:31@314159265
DTSTAMP:20150908T130000
DTSTART:20150908T130000
DTEND:20150908T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:32@314159265
DTSTAMP:20150915T130000
DTSTART:20150915T130000
DTEND:20150915T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:33@314159265
DTSTAMP:20150922T130000
DTSTART:20150922T130000
DTEND:20150922T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:34@314159265
DTSTAMP:20150929T130000
DTSTART:20150929T130000
DTEND:20150929T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:35@314159265
DTSTAMP:20151006T130000
DTSTART:20151006T130000
DTEND:20151006T180000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K20) 
END:VEVENT
BEGIN:VEVENT
UID:36@314159265
DTSTAMP:20151029T080000
DTSTART:20151029T080000
DTEND:20151029T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:37@314159265
DTSTAMP:20151105T080000
DTSTART:20151105T080000
DTEND:20151105T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:38@314159265
DTSTAMP:20151112T080000
DTSTART:20151112T080000
DTEND:20151112T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:39@314159265
DTSTAMP:20151119T080000
DTSTART:20151119T080000
DTEND:20151119T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:40@314159265
DTSTAMP:20151126T080000
DTSTART:20151126T080000
DTEND:20151126T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:41@314159265
DTSTAMP:20151203T080000
DTSTART:20151203T080000
DTEND:20151203T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:42@314159265
DTSTAMP:20151210T080000
DTSTART:20151210T080000
DTEND:20151210T130000
SUMMARY:Quantumchemistry
DESCRIPTION:
LOCATION:Lecture Theater (1540-K26) 
END:VEVENT
BEGIN:VEVENT
UID:43@314159265
DTSTAMP:20150824T140000
DTSTART:20150824T140000
DTEND:20150824T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:44@314159265
DTSTAMP:20150831T140000
DTSTART:20150831T140000
DTEND:20150831T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:45@314159265
DTSTAMP:20150907T140000
DTSTART:20150907T140000
DTEND:20150907T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:46@314159265
DTSTAMP:20150914T140000
DTSTART:20150914T140000
DTEND:20150914T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:47@314159265
DTSTAMP:20150921T140000
DTSTART:20150921T140000
DTEND:20150921T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:48@314159265
DTSTAMP:20150928T140000
DTSTART:20150928T140000
DTEND:20150928T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:49@314159265
DTSTAMP:20151005T140000
DTSTART:20151005T140000
DTEND:20151005T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:50@314159265
DTSTAMP:20151102T140000
DTSTART:20151102T140000
DTEND:20151102T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:51@314159265
DTSTAMP:20151109T140000
DTSTART:20151109T140000
DTEND:20151109T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:52@314159265
DTSTAMP:20151116T140000
DTSTART:20151116T140000
DTEND:20151116T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:53@314159265
DTSTAMP:20151123T140000
DTSTART:20151123T140000
DTEND:20151123T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:54@314159265
DTSTAMP:20151130T140000
DTSTART:20151130T140000
DTEND:20151130T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:55@314159265
DTSTAMP:20151207T140000
DTSTART:20151207T140000
DTEND:20151207T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:56@314159265
DTSTAMP:20151214T140000
DTSTART:20151214T140000
DTEND:20151214T160000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater II (1514-110) 
END:VEVENT
BEGIN:VEVENT
UID:57@314159265
DTSTAMP:20150825T090000
DTSTART:20150825T090000
DTEND:20150825T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:58@314159265
DTSTAMP:20150901T090000
DTSTART:20150901T090000
DTEND:20150901T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:59@314159265
DTSTAMP:20150908T090000
DTSTART:20150908T090000
DTEND:20150908T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:60@314159265
DTSTAMP:20150915T090000
DTSTART:20150915T090000
DTEND:20150915T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:61@314159265
DTSTAMP:20150922T090000
DTSTART:20150922T090000
DTEND:20150922T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:62@314159265
DTSTAMP:20150929T090000
DTSTART:20150929T090000
DTEND:20150929T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:63@314159265
DTSTAMP:20151006T090000
DTSTART:20151006T090000
DTEND:20151006T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:64@314159265
DTSTAMP:20151103T090000
DTSTART:20151103T090000
DTEND:20151103T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:65@314159265
DTSTAMP:20151110T090000
DTSTART:20151110T090000
DTEND:20151110T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:66@314159265
DTSTAMP:20151117T090000
DTSTART:20151117T090000
DTEND:20151117T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:67@314159265
DTSTAMP:20151124T090000
DTSTART:20151124T090000
DTEND:20151124T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:68@314159265
DTSTAMP:20151201T090000
DTSTART:20151201T090000
DTEND:20151201T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:69@314159265
DTSTAMP:20151208T090000
DTSTART:20151208T090000
DTEND:20151208T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:70@314159265
DTSTAMP:20151215T090000
DTSTART:20151215T090000
DTEND:20151215T120000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:71@314159265
DTSTAMP:20150827T120000
DTSTART:20150827T120000
DTEND:20150827T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:72@314159265
DTSTAMP:20150903T120000
DTSTART:20150903T120000
DTEND:20150903T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:73@314159265
DTSTAMP:20150910T120000
DTSTART:20150910T120000
DTEND:20150910T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:74@314159265
DTSTAMP:20150917T120000
DTSTART:20150917T120000
DTEND:20150917T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:75@314159265
DTSTAMP:20150924T120000
DTSTART:20150924T120000
DTEND:20150924T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:76@314159265
DTSTAMP:20151001T120000
DTSTART:20151001T120000
DTEND:20151001T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:77@314159265
DTSTAMP:20151008T120000
DTSTART:20151008T120000
DTEND:20151008T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:78@314159265
DTSTAMP:20151029T120000
DTSTART:20151029T120000
DTEND:20151029T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:79@314159265
DTSTAMP:20151105T120000
DTSTART:20151105T120000
DTEND:20151105T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:80@314159265
DTSTAMP:20151112T120000
DTSTART:20151112T120000
DTEND:20151112T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:81@314159265
DTSTAMP:20151119T120000
DTSTART:20151119T120000
DTEND:20151119T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:82@314159265
DTSTAMP:20151126T120000
DTSTART:20151126T120000
DTEND:20151126T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:83@314159265
DTSTAMP:20151203T120000
DTSTART:20151203T120000
DTEND:20151203T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:84@314159265
DTSTAMP:20151210T120000
DTSTART:20151210T120000
DTEND:20151210T150000
SUMMARY:Electromagnetic Field Theory
DESCRIPTION:Lessons
LOCATION:IT-lab 2 Chemistry (1510) 
END:VEVENT
BEGIN:VEVENT
UID:85@314159265
DTSTAMP:20150824T100000
DTSTART:20150824T100000
DTEND:20150824T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:86@314159265
DTSTAMP:20150831T100000
DTSTART:20150831T100000
DTEND:20150831T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:87@314159265
DTSTAMP:20150907T100000
DTSTART:20150907T100000
DTEND:20150907T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:88@314159265
DTSTAMP:20150914T100000
DTSTART:20150914T100000
DTEND:20150914T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:89@314159265
DTSTAMP:20150921T100000
DTSTART:20150921T100000
DTEND:20150921T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:90@314159265
DTSTAMP:20150928T100000
DTSTART:20150928T100000
DTEND:20150928T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:91@314159265
DTSTAMP:20151005T100000
DTSTART:20151005T100000
DTEND:20151005T110000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:92@314159265
DTSTAMP:20150826T140000
DTSTART:20150826T140000
DTEND:20150826T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:93@314159265
DTSTAMP:20150902T140000
DTSTART:20150902T140000
DTEND:20150902T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:94@314159265
DTSTAMP:20150909T140000
DTSTART:20150909T140000
DTEND:20150909T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:95@314159265
DTSTAMP:20150916T140000
DTSTART:20150916T140000
DTEND:20150916T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:96@314159265
DTSTAMP:20150923T140000
DTSTART:20150923T140000
DTEND:20150923T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:97@314159265
DTSTAMP:20150930T140000
DTSTART:20150930T140000
DTEND:20150930T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:98@314159265
DTSTAMP:20151007T140000
DTSTART:20151007T140000
DTEND:20151007T160000
SUMMARY:Relativity
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater I (1514-213) 
END:VEVENT
BEGIN:VEVENT
UID:99@314159265
DTSTAMP:20151102T120000
DTSTART:20151102T120000
DTEND:20151102T140000
SUMMARY:Complex Analysis
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater VI (1510-213) 
END:VEVENT
BEGIN:VEVENT
UID:100@314159265
DTSTAMP:20151109T120000
DTSTART:20151109T120000
DTEND:20151109T140000
SUMMARY:Complex Analysis
DESCRIPTION:Oral Lessons
LOCATION:Lecture Theater VI (1510-213) 
END:VEVENT
END:VCALENDAR

答案1

我编写了一个简短的 Python 脚本和一个 Jinja 模板,尝试自动生成您需要的时间表。以下是正在进行的工作:

日历的早期 WIP

在继续之前,我可以检查一下时间是否正确吗?我不确定我是否正确处理了日期和时间:特别是周四量子化学和电磁场理论之间似乎有重叠。

作为参考,这里是当前的 Python 代码:

#generate_tikz.py
'''Requirements:
arrow for datetime handling
ics package for reading ICS file,
jinja2 for the templating'''

import arrow
from ics import Calendar
from jinja2 import Environment, FileSystemLoader
from collections import Counter

with open('cal.ics', 'rt') as f:
    cal = Calendar(iter(f))

env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('cal.tpl')

days = [dict() for i in range(5)] 
for event in cal.events:
    day = event.begin.weekday()
    if day >= 5: #weekend
        continue
    days[day][event.begin.hour] = event

from pprint import pprint
pprint(days)

names = Counter(event.name for day in days for event in day.values() )
names = [x[0] for x in names.most_common()]
colors = ['red', 'green', 'blue', 'orange', 'purple', 'brown', 'gray']

with open("cal.tex", "wt") as f:
    f.write(template.render(
        days=days, names=zip(names, colors)
    ))

这是 Jinja 模板:

{# saved as cal.tpl #}
%See http://tex.stackexchange.com/q/268780/82389
\documentclass[draft, a4paper]{article}
\usepackage[top=5mm, bottom=5mm, left=5mm, right=5mm]{geometry}
%\usepackage{showframe}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

%Options for timetable contents
\def\firsthour{8}
\def\lasthour{19}
\def\daynames{Monday, Tuesday, Wednesday, Thursday, Friday}

%Options for timetable drawing
\def\daywidth{3.4cm}   %approx \textwidth / 6
\def\hourheight{2.2cm} %approx \textheight / (\lasthour - \firsthour + 1)

\begin{document}

\centering
\begin{tikzpicture}[
    x=\daywidth, y=-\hourheight,
    block/.style={
        draw, text width=\daywidth, minimum height=\hourheight, inner sep=0pt, align=flush center
    },
    hour/.style ={block, fill=yellow!40, font=\bfseries\Large,
        text width=0.6*\daywidth, xshift=0.2*\daywidth},
    day/.style  ={block, fill=yellow!40, font=\bfseries\Large,
        minimum height=0.5*\hourheight, yshift=-0.25*\hourheight},
    event details/.style={
        align=flush center,
        inner xsep=0pt, inner ysep=1pt,
        rectangle split, rectangle split parts=3,
        text width=0.95*\daywidth
    },
    name/.style ={font=\normalsize},
    desc/.style ={font=\small\itshape},
    loc/.style  ={font=\small},
    hours/.style={minimum height=#1*\hourheight}
]

{%- for name, color in names -%}
    \tikzset{ {{name}}/.style={block, fill={{color}}!20, draw={{color}}!50!black, thick} }
{% endfor %}

\draw[help lines, xshift=0.5*\daywidth, yshift=0.5*\hourheight]
    (0, \firsthour) grid [xstep=\daywidth, ystep=\hourheight] (5, \lasthour);

\pgfmathtruncatemacro\secondhour{\firsthour + 1}
\foreach \end[remember=\end as \start (initially \firsthour)] in {\secondhour, ..., \lasthour} {
    \node[hour] at (0, \start) {\start--\end};
}

\foreach \day[count=\daynum] in \daynames {
    \node[day] at (\daynum, \firsthour-1) {\day};
}

{%- for day in days -%}
    {%- set dayloop = loop -%}
    {%- for time, event in day.items() -%}
        {%- set duration = event.duration.seconds / 3600 -%}
        {%- set y = time  + (duration - 1) / 2 -%}
    \node[{{event.name}}, hours={{duration}}] at ( {{ dayloop.index }} , {{ y }} ) {};

    \node[event details] at ( {{ dayloop.index }} , {{ y }} ) {
        \nodepart[name]{one}   \strut {{ event.name }} 
        \nodepart[desc]{two}   \strut {{ event.description }}
        \nodepart[loc] {three} \strut {{ event.location }}
    };
    {%- endfor %}
{% endfor %}

\end{tikzpicture}
\end{document}

如果您的系统上装有最新版本的 Python,则可以用以下命令安装所需的软件包:pip install ics jinja2 然后使用以下命令运行脚本:python generate_tikz.py 最后,调用 pdflatex cal.tex 生成 pdf。

如果您无法在您的系统上执行此操作,我在下面提供了输出 TeX 代码。

%cal.tex
%See http://tex.stackexchange.com/q/268780/82389
\documentclass[draft, a4paper]{article}
\usepackage[top=5mm, bottom=5mm, left=5mm, right=5mm]{geometry}
%\usepackage{showframe}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}

%Options for timetable contents
\def\firsthour{8}
\def\lasthour{19}
\def\daynames{Monday, Tuesday, Wednesday, Thursday, Friday}

%Options for timetable drawing
\def\daywidth{3.4cm}   %approx \textwidth / 6
\def\hourheight{2.2cm} %approx \textheight / (\lasthour - \firsthour + 1)

\begin{document}

\centering
\begin{tikzpicture}[
    x=\daywidth, y=-\hourheight,
    block/.style={
        draw, text width=\daywidth, minimum height=\hourheight, inner sep=0pt, align=flush center
    },
    hour/.style ={block, fill=yellow!40, font=\bfseries\Large,
        text width=0.6*\daywidth, xshift=0.2*\daywidth},
    day/.style  ={block, fill=yellow!40, font=\bfseries\Large,
        minimum height=0.5*\hourheight, yshift=-0.25*\hourheight},
    event details/.style={
        align=flush center,
        inner xsep=0pt, inner ysep=1pt,
        rectangle split, rectangle split parts=3,
        text width=0.95*\daywidth
    },
    name/.style ={font=\normalsize},
    desc/.style ={font=\small\itshape},
    loc/.style  ={font=\small},
    hours/.style={minimum height=#1*\hourheight}
]\tikzset{ Quantumchemistry/.style={block, fill=red!20, draw=red!50!black, thick} }
\tikzset{ Electromagnetic Field Theory/.style={block, fill=green!20, draw=green!50!black, thick} }
\tikzset{ Relativity/.style={block, fill=blue!20, draw=blue!50!black, thick} }
\tikzset{ Complex Analysis/.style={block, fill=orange!20, draw=orange!50!black, thick} }


\draw[help lines, xshift=0.5*\daywidth, yshift=0.5*\hourheight]
    (0, \firsthour) grid [xstep=\daywidth, ystep=\hourheight] (5, \lasthour);

\pgfmathtruncatemacro\secondhour{\firsthour + 1}
\foreach \end[remember=\end as \start (initially \firsthour)] in {\secondhour, ..., \lasthour} {
    \node[hour] at (0, \start) {\start--\end};
}

\foreach \day[count=\daynum] in \daynames {
    \node[day] at (\daynum, \firsthour-1) {\day};
}\node[Quantumchemistry, hours=2.0] at ( 1 , 16.5 ) {};

    \node[event details] at ( 1 , 16.5 ) {
        \nodepart[name]{one}   \strut Quantumchemistry 
        \nodepart[desc]{two}   \strut 
        \nodepart[loc] {three} \strut Lecture Theater V (1514-121)
    };\node[Relativity, hours=1.0] at ( 1 , 10.0 ) {};

    \node[event details] at ( 1 , 10.0 ) {
        \nodepart[name]{one}   \strut Relativity 
        \nodepart[desc]{two}   \strut Oral Lessons
        \nodepart[loc] {three} \strut Lecture Theater I (1514-213)
    };\node[Complex Analysis, hours=2.0] at ( 1 , 12.5 ) {};

    \node[event details] at ( 1 , 12.5 ) {
        \nodepart[name]{one}   \strut Complex Analysis 
        \nodepart[desc]{two}   \strut Oral Lessons
        \nodepart[loc] {three} \strut Lecture Theater VI (1510-213)
    };\node[Electromagnetic Field Theory, hours=2.0] at ( 1 , 14.5 ) {};

    \node[event details] at ( 1 , 14.5 ) {
        \nodepart[name]{one}   \strut Electromagnetic Field Theory 
        \nodepart[desc]{two}   \strut Oral Lessons
        \nodepart[loc] {three} \strut Lecture Theater II (1514-110)
    };
\node[Electromagnetic Field Theory, hours=3.0] at ( 2 , 10.0 ) {};

    \node[event details] at ( 2 , 10.0 ) {
        \nodepart[name]{one}   \strut Electromagnetic Field Theory 
        \nodepart[desc]{two}   \strut Lessons
        \nodepart[loc] {three} \strut IT-lab 2 Chemistry (1510)
    };\node[Quantumchemistry, hours=5.0] at ( 2 , 15.0 ) {};

    \node[event details] at ( 2 , 15.0 ) {
        \nodepart[name]{one}   \strut Quantumchemistry 
        \nodepart[desc]{two}   \strut 
        \nodepart[loc] {three} \strut Lecture Theater (1540-K20)
    };
\node[Quantumchemistry, hours=2.0] at ( 3 , 10.5 ) {};

    \node[event details] at ( 3 , 10.5 ) {
        \nodepart[name]{one}   \strut Quantumchemistry 
        \nodepart[desc]{two}   \strut 
        \nodepart[loc] {three} \strut Lecture Theater (1540-K26)
    };\node[Relativity, hours=2.0] at ( 3 , 14.5 ) {};

    \node[event details] at ( 3 , 14.5 ) {
        \nodepart[name]{one}   \strut Relativity 
        \nodepart[desc]{two}   \strut Oral Lessons
        \nodepart[loc] {three} \strut Lecture Theater I (1514-213)
    };
\node[Quantumchemistry, hours=5.0] at ( 4 , 10.0 ) {};

    \node[event details] at ( 4 , 10.0 ) {
        \nodepart[name]{one}   \strut Quantumchemistry 
        \nodepart[desc]{two}   \strut 
        \nodepart[loc] {three} \strut Lecture Theater (1540-K26)
    };\node[Electromagnetic Field Theory, hours=3.0] at ( 4 , 13.0 ) {};

    \node[event details] at ( 4 , 13.0 ) {
        \nodepart[name]{one}   \strut Electromagnetic Field Theory 
        \nodepart[desc]{two}   \strut Lessons
        \nodepart[loc] {three} \strut IT-lab 2 Chemistry (1510)
    };
\node[Quantumchemistry, hours=2.0] at ( 5 , 11.5 ) {};

    \node[event details] at ( 5 , 11.5 ) {
        \nodepart[name]{one}   \strut Quantumchemistry 
        \nodepart[desc]{two}   \strut 
        \nodepart[loc] {three} \strut Lecture Theater V (1514-121)
    };


\end{tikzpicture}
\end{document}

答案2

我贡献了一种使用纯 TikZ 绘制时间表的简单方法。

在此处输入图片描述


为什么说这个代码简单呢?因为基本上它只是从缩放网格开始

在此处输入图片描述

\begin{tikzpicture}[xscale=4,yscale=1]
\draw (0,0) grid (5,-5);
\end{tikzpicture}

node然后,每对时间/工作都用一个颜色框和一个(容易心算的)点来绘制

在此处输入图片描述

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[xscale=4,yscale=1]
\draw (0,0) grid (5,-5);

\draw[fill=cyan!20] (1,-2) rectangle +(1,-3);
\path (1.5,-3.5) node[align=center]
{\bfseries ODEs MAT2314\\
    Room 204T4\\
    \itshape Pedagogic Math\\
    Dept. of Maths};
\end{tikzpicture}
\end{document}

下午的时间与早上的时间相似,只是时间偏移了(0,-6)

完整代码如下。

\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[xscale=4,yscale=1]
\foreach \itext[count=\i from 2] in {Monday,Tuesday,Wednesday,Thursday,Friday}
\path (\i-1.5,0) node[above=2mm,scale=1.5]{\texttt \itext};

% Morning
\begin{scope} 
\draw (0,0) grid (5,-5);
\foreach \i[count=\j from 7] in {1,...,6}
\path (0,-\i+1) node[left=2mm,scale=1.2]{\bfseries \j \,h};

\draw[fill=cyan!20] (1,-2) rectangle +(1,-3);
\path (1.5,-3.5) node[align=center]
{\bfseries ODEs MAT2314\\
Room 204T4\\
\itshape Pedagogic Math\\
Dept. of Maths};
\end{scope}

% Afternoon
\begin{scope}[shift={(0,-6)}]
\draw (0,0) grid (5,-5);
\foreach \i[count=\j from 13] in {1,...,6}
\path (0,-\i+1) node[left=2mm,scale=1.2]{\bfseries \j \,h};

\draw[fill=yellow] (4,0) rectangle +(1,-2);
\path (4.5,-1) node[align=center]
{\bfseries ODES MAT1259\\
Room 403T5\\
K62 TNS\\
Dept. of Biology};
\end{scope}

\path (current bounding box.north)
node[above=5mm,blue,scale=1.8,xscale=1.5,align=center]
{\bfseries TIME TABLE 2020}
;
\end{tikzpicture}
\end{document}

相关内容