Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question
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 '11 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. –  Thomas Schwery Feb 11 '11 at 19:15
    
I have to admit, I typically use OpenOffice Calc for things like that. –  Caramdir Feb 12 '11 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 '11 at 18:40
add comment

1 Answer

up vote 17 down vote accepted

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

share|improve this answer
    
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 '13 at 15:57
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.