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 using the pgfgantt package to create a timeline. This is what I've got so far:

\documentclass[landscape]{article}
\usepackage[dvipsnames,usenames]{xcolor}
\usepackage{tikz}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\renewcommand{\familydefault}{\sfdefault}
\definecolor{barblue}{RGB}{153,204,254}
\begin{document}
    \begin{tikzpicture}[x=1cm,y=1cm]
        \begin{ganttchart}%
            [canvas={fill=none, draw=black!5, line width=.75pt},
            hgrid style={draw=black!5, line width=.75pt},
            vgrid={draw=black!5, line width=.75pt},
            title={draw=none, fill=none},
            title label font=\bfseries\footnotesize,
            title label anchor={below=-2pt},
            include title in canvas=false,
            bar={draw=none, fill=barblue},
            ]{33}
        \gantttitle[title label anchor={below left=-2pt and -3pt}]{Date:}{0}
        \gantttitlelist[title list options={%
            var=\y, evaluate=\y as \x%
            using "\pgfcalendarweekdayshortname{\y}"%
        }]{0,...,6}{1} \\
        \ganttbar{Task 1}{1}{7} \\
        \ganttbar{Task 2}{8}{14} \\
        \ganttbar{Task 3}{15}{21} \\
        \end{ganttchart}
    \end{tikzpicture}
\end{document}

The result is this: Gantt chart

This is not exactly what I'm expecting. I'd also like to have the date of the current day beside the name of the day (for example: Mon, 1.8.). And this should be repeated for several weeks. For example I'd like to have a timeline for five weeks, starting from today without manually filling in all the dates. I don't know if this is possible with these packages but I'd really appreciate any help.

share|improve this question
    
You accidentally created two unregistered accounts which I merged now together. Please register your account to avoid this in the future. Then you will also be able to comment to all answers of your question(s). Please don't post feedback as "answer" post. Thank you. –  Martin Scharrer Sep 22 '11 at 6:38

1 Answer 1

up vote 7 down vote accepted

You can use the \pgfcalendar macro in place of the default \pgffor used by \gantttitlelist as follows:

\documentclass[landscape]{article}
\usepackage[dvipsnames,usenames]{xcolor}
\usepackage{tikz}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}
\renewcommand{\familydefault}{\sfdefault}
\definecolor{barblue}{RGB}{153,204,254}
\begin{document}
    \begin{tikzpicture}[x=1cm,y=1cm]
        \begin{ganttchart}%
            [canvas={fill=none, draw=black!5, line width=.75pt},
            hgrid style={draw=black!5, line width=.75pt},
            vgrid={draw=black!5, line width=.75pt},
            title={draw=none, fill=none},
            title label font=\bfseries\footnotesize,
            title label anchor={below=-2pt},
            include title in canvas=false,
            bar={draw=none, fill=barblue},
            ]{33}
        \gantttitle[title label anchor={below left=-2pt and -3pt}]{Date:}{0}
%        \gantttitlelist[title list options={%
%            var=\y, evaluate=\y as \x%
%            using "\pgfcalendarweekdayshortname{\y}"%
%        }]{0,...,6}{1} \\
        \pgfcalendar{titlecal}{2011-09-21}{2011-10-12}{%
          \gantttitle{\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday} 
          \pgfcalendarcurrentday}{1}}\\
        \ganttbar{Task 1}{1}{7} \\
        \ganttbar{Task 2}{8}{14} \\
        \ganttbar{Task 3}{15}{21} \\
        \end{ganttchart}
    \end{tikzpicture}
\end{document}

The first argument (here "titlecal") is a prefix to the names of the nodes created, which isn't of any particular use here, but then the next two are the starting and stopping dates. You can change the actual text that's displayed using the commands in section 57 of the PGF manual.

share|improve this answer
    
Yes, this looks fine. The problem now is that the timline overflows the paper size. Do you know a solution? Maybe some expression to check if there's still enough space and if not start a new line. Well, this could also been done manually for every week but it would be nice if this could be done automatically. Another point – yes, I know it's not part of my original question – is how can I center the timeline on the paper? I tried it using the center environment but I didn't succeed. –  Frank Sep 21 '11 at 16:30
    
center seems to work for me provided the timeline fits on the page. But I'm afraid automatically breaking a plot doesn't appear to be trivial. (You might like to pose this as a separate question, since it's quite a different issue: I will have a go if I get a chance, and no doubt so will others!) However, you can squeeze quite a lot more on one page by setting title label anchor={rotate=90} and decreasing x: e.g., I can fit five weeks happily on an A4 page this way using x=4mm and \scriptsize font. –  Ant Sep 21 '11 at 18:11
    
Thank you. I'll accept this answer. Although I have an additional question: When I rotate the labels they get aligned on the top. Is there a possibility to align them on the bottom? –  Frank Sep 21 '11 at 20:23
    
Does title label anchor={anchor=base west, rotate=90} do what you want? –  Ant Sep 21 '11 at 20:37
    
You could potentially add an xshift=-10pt or similar in there too, if you want the bottom of the rotated text to line up with the bottom of the "Date: " text. –  Ant Sep 21 '11 at 20:42

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.