19

I'm looking for a way to type a weekly schedule in LaTeX. The only problematic part is that it's possible that there is overlap in entries.

I looked at “LaTeX Classes or Styles for Schedules and/or Calendars?” but it's not the type of schedule/calendar I'm looking for.

I also looked at the schedule.sty package but it doesn't provides a way to deal with overlapping entries.

An example of entries in this schedule would be:

Monday 8am to 12am: Virtual Reality,
Monday 8am to 10am: Real time networks,
Monday 1pm to 4pm : ESOA, ...

Example of output based on the entries above

Does anyone has a way to generate weekly schedules with LaTeX ?

4
  • 2
    Could you maybe draw a sketch how your schedule is supposed to look like. That will make it easier to suggest a good approach.
    – Caramdir
    Feb 10, 2011 at 15:53
  • I added an example of what the output could be like based on the entries i gave. I could be colored or anything, the only functionality i'm looking for is a way to deal with overlapping entries. Feb 11, 2011 at 19:15
  • I have to admit, I typically use OpenOffice Calc for things like that.
    – Caramdir
    Feb 12, 2011 at 17:48
  • If you wanted to do it 'from scratch' then metapost might be a nice latex-friendly tool to use. There is a module that lets you write metapost in a tex file directly.
    – Tom
    Feb 12, 2011 at 18:40

2 Answers 2

26

I couldn't resist: Here is one way to draw this with TikZ. To make it nicer to use, there should be some additional wrapper around it, that automatically calculates the horizontal placement of the nodes. Besides that, the code is astonishingly non-verbose.

\documentclass{article}
\usepackage{tikz}

\begin{document}

% These set the width of a day and the height of an hour.
\newcommand*\daywidth{6cm}
\newcommand*\hourheight{1.2em}

% The entry style will have two options:
% * the first option sets how many hours the entry will be (i.e. its height);
% * the second option sets how many overlapping entries there are (thus
%   determining the width).
\tikzset{entry/.style 2 args={
    draw,
    rectangle,
    anchor=north west,
    line width=0.4pt,
    inner sep=0.3333em,
    text width={\daywidth/#2-0.6666em-0.4pt},
    minimum height=#1*\hourheight,
    align=center
}}

% Start the picture and set the x coordinate to correspond to days and the y
% coordinate to correspond to hours (y should point downwards).
\begin{tikzpicture}[y=-\hourheight,x=\daywidth]

    % First print a list of times.
    \foreach \time/\ustime in {8/8am,9/9am,10/10am,11/11am,12/12pm,13/1pm,14/2pm,15/3pm,16/4pm,17/5pm,18/6pm}
        \node[anchor=north east] at (1,\time) {\ustime};

    % Draw some day dividers.
    \draw (1,6.5) -- (1,19);
    \draw (2,6.5) -- (2,19);
    \draw (3,6.5) -- (3,19);

    % Start Monday.
    \node[anchor=north] at (1.5,6.5) {Monday};
    % Write the entries. Note that the x coordinate is 1 (for Monday) plus an
    % appropriate amount of shifting. The y coordinate is simply the starting
    % time.
    \node[entry={4}{2}] at (1,8) {Virtual Reality};
    \node[entry={3}{2}] at (1.5,8) {Realtime Network};
    \node[entry={3}{1}] at (1,13) {EOSA};

    % The same for Tuesday.
    \node[anchor=north] at (2.5,6.5) {Tuesday};
    \node[entry={3.5}{3}] at (2,9) {Class A};
    \node[entry={2.5}{3}] at (2.33333,9.5) {Class B};
    \node[entry={2.5}{3}] at (2.66667,10) {Class C};
\end{tikzpicture}
\end{document}

result

Of course, you can apply all the power of TikZ to actually make it look better (or worse...). For example, by simply replacing the \tikzset with

\tikzset{entry/.style 2 args={
    xshift=(0.5334em+0.8pt)/2,
    draw,
    line width=0.8pt,
    font=\sffamily,
    rectangle,
    rounded corners,
    fill=blue!20,
    anchor=north west,
    inner sep=0.3333em,
    text width={\daywidth/#2-1.2em-1.6pt},
    minimum height=#1*\hourheight,
    align=center
}}

one obtains

example 2

1
  • I found this to be a good approach that compromises flexibility (basically, everythin is hardcoded) with reusability (style and positioning is abstracted neatly). It is also suitable for automatic generation, I think.
    – Raphael
    Oct 30, 2013 at 15:57
0

Thank you Caramdir. This is how I use it. I've colored the same courses with the same color. And changed the white part for same courses but for different groups. As for the colors I have been inspired by this page: https://99designs.com/blog/creative-inspiration/color-combinations/

\documentclass[12pt]{scrartcl}
\setparsizes{0em}{0.25\baselineskip plus .25\baselineskip}{1em plus 1fil}

\usepackage{geometry}
\geometry{
paper = a4paper,
textwidth = 250mm,
textheight = 160mm,
landscape
}

\usepackage[newcommands]{ragged2e}
%\setlength{\RaggedRightskip}{0pt plus 2cm}

\usepackage[libertinus]{fontsetup}


%\usepackage[ngerman]{babel}
%\selectlanguage{ngerman}
\usepackage{microtype}
%======
\usepackage{tikz}
\usetikzlibrary{math}
%======

\definecolor{co-olive}{HTML}{829079}
\definecolor{co-beige}{HTML}{ede6b9}
\definecolor{co-brown}{HTML}{b9925e}

\colorlet{co-cour}{co-olive!25!white}
\colorlet{co-labA}{co-beige!45!white}
\colorlet{co-labB}{co-beige!30!white}
\colorlet{co-mast}{orange!20!white}
\colorlet{co-lecA}{co-brown!35!white}
\colorlet{co-lecB}{co-brown!20!white}

\begin{document}
\enlargethispage{2cm}
\thispagestyle{empty}

% Start
% These set the width of a day and the height of an hour.
\newcommand*\daywidth{5cm}
\newcommand*\hourheight{1.2cm}

% The entry style will have two options:
% * the first option sets how many hours the entry will be (i.e. its height);
% * the second option sets how many overlapping entries there are (thus
%   determining the width).
\tikzset{entry/.style 2 args={
    draw,
    rectangle,
    rounded corners,
    anchor=north west,
    line width=0.4pt,
    inner xsep=0.3333em,
    inner ysep=0ex,
    text width={\daywidth/#2-0.6666em-0.4pt},
    text height=2.5ex,
    text depth=#1*\hourheight-2.5ex,
    align=left
}}
\vspace*{-2cm}
\begin{center}
    Schedule 2023
\end{center}


% Start the picture and set the x coordinate to correspond to days and the y
% coordinate to correspond to hours (y should point downwards).
\begin{tikzpicture}[y=-\hourheight,x=\daywidth]

    % First print a list of times 9 - 16 o'clock
    \foreach \time/\ustime in {9/9,10/10,11/11,12/12,13/13,14/14,15/15,16/16}{
        % Full hour, added :00
        % changed anchor to mid east
        \node[anchor=mid east] at (0.94,\time) {\ustime:00};
        \draw [thick] (1,\time) -- (6,\time);
        
        % Quarter
        \foreach \qtime/\qmin in {0.25/15,0.5/30,0.75/45}{
          \node[anchor=mid east] at (1,\time+\qtime) {\qmin};
          \draw [thin] (1,\time+\qtime) -- (6,\time+\qtime);
          }
        }
      
  % Adding the times: 17:00
  % And then 15,30
  \node[anchor=mid east] at (0.94,17) {17:00};
  \draw [thick] (1,17) -- (6,17);
     \foreach \qtime/\qmin in {0.25/15,0.5/30}{
         \node[anchor=mid east] at (1,17+\qtime) {\qmin};
          \draw [thin] (1,17+\qtime) -- (6,17+\qtime);
      }
        
\tikzmath{
   \startTime =  8.5; % Vertical line start
   \endTime   = 18;   % Vertical line end
%   
   \xday = 1.5; % x-position of name of days
   \yday = 8.5; % y-position (hour) of name of days
}

    % Draw some day dividers.
    \foreach \i in {1,...,6}
       \draw (\i,\startTime) -- (\i,\endTime);
    

    % Start Monday
    \node[anchor=north] at (\xday,\yday) {Monday};
    % Write the entries. Note that the x coordinate is 1 (for Monday) plus an
    % appropriate amount of shifting. The y coordinate is simply the starting
    % time.

    % Tuesday
    \node[anchor=north] at (\xday+1,\yday) {Tuesday};
    \node[entry={1.5}{1}, fill=co-cour] 
                  at (2,11.5) {Course 3 \\Room 1.23};
    \node[entry={1.5}{2}, fill=co-labA] 
                  at (2,14) {Lab RT 3A\\ S 05.305};
    \node[entry={1.5}{2}, fill=co-mast] 
                  at (2.5,14) {Master\\ Room 1.33};
    \node[entry={1.5}{2}, fill=co-labA] 
                  at (2,15.75) {Lab RT 3A\\ Room 2.34};
    \node[entry={1.5}{2}, fill=co-mast] 
                  at (2.5,15.75) {Master\\ Room 3.45};
                  
   % Wednesday
    \node[anchor=north] at (\xday+2,\yday) {Wednesday};
    \node[entry={1.5}{1}, fill=co-labB] 
                  at (3,14) {Lab RT 3B\\ Room 3.45};
    \node[entry={1.5}{1}, fill=co-labB] 
                  at (3,15.75) {Lab RT 3B\\ Room 3.45};

   % Thursday
    \node[anchor=north] at (\xday+3,\yday) {Thursday};
    \node[entry={1.5}{1}, fill=co-lecA] 
                  at (4,14) {Lecture A\\ Room 3.45};
    \node[entry={1.5}{1}, fill=co-lecB] 
                  at (4,15.75) {Lecture B\\ Room 3.45};
                  
   % Friday
    \node[anchor=north] at (\xday+4,\yday) {Friday};
    \node[entry={1.5}{1}, fill=co-lecB] 
                  at (5,9.75) {Lecture B\\ Room 3.45};
    \node[entry={1.5}{1}, fill=co-lecA] 
                  at (5,11.5) {Lecture A\\ Room 3.45};
    \node[entry={1.5}{1}, fill=co-cour] 
                  at (5,14) {Course 3\\ Room 3.45};
\end{tikzpicture}
\end{document}

enter image description here

1
  • I should add that the tex file has to be compiled with lualatex.
    – Nik
    Sep 14, 2023 at 11:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .