14

How can I use pgfgantt to typeset a calendar for 2013? I would like to have calendar that displays the day-dates of the corresponding months; instead of the number 1 to 365 it should give 1,...,31,1,...,28,1,...31 and so on.

Also it would be great if Saturdays and Sundays among these dates could be highlighted with a different background. So far I have the following:

\documentclass{article}

\usepackage[paperwidth=300cm, paperheight=50cm,left=1cm,right=1cm,top=5cm,bottom=5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}

\begin{document}

\begin{ganttchart}[hgrid, vgrid, x unit=0.8cm]{365}
\gantttitle{Projektplan}{365} \\
\gantttitlelist{1,...,365}{1} \\
\ganttbar{Task 1}{2}{5} \\
\end{ganttchart}

\end{document}
1
13

A small shortcut to what David has provided (which is fantastic considering he doesn't even use PGF :D ).

\documentclass{article}
\usepackage[paperwidth=300cm, paperheight=50cm,
            left=1cm,right=1cm,top=5cm,bottom=5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfgantt}
\usetikzlibrary{calendar}

\protected\def\zzz#1{%
\pgfcalendarifdate{2012-12-31+#1}{weekend}% Test if it's a weekend
{\textcolor{red}{\pgfcalendarifdateday}}% Typeset with red color
{\pgfcalendarifdateday}% Or just the number
}


\begin{document}


\begin{ganttchart}[hgrid, vgrid, x unit=0.8cm]{365}
\gantttitle{Projektplan}{365} \\
\gantttitlelist[
title list options={var=\y, evaluate=\y as \x using {"\zzz{\y}"}}
]{1,...,365}{1} \\
\ganttbar{Task 1}{2}{5} \\
\end{ganttchart}

\end{document}

enter image description here

12

enter image description here

\documentclass{article}

\usepackage[paperwidth=300cm, paperheight=50cm,left=1cm,right=1cm,top=5cm,bottom=5cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{pgfgantt}
\usepackage{pgfcalendar}


\newcount\startdate
\newcount\daynum
\pgfcalendardatetojulian{2012-01-01}{\startdate}

\protected\def\zzz{%
\pgfcalendarjuliantodate{\numexpr\startdate\relax}{\year}{\month}{\day}%
\pgfcalendarjuliantoweekday\startdate\daynum
\day
{\ifnum\daynum=6\color{red}%
\pgfcalendarweekdayshortname{\daynum}%
\fi}%
\global\advance\startdate1}

\begin{document}

\begin{ganttchart}[hgrid, vgrid, x unit=0.8cm]{365}
\gantttitle{Projektplan}{365} \\
\gantttitlelist[
title list options={var=\y,evaluate=\y  as \x using 
"{\zzz}"}
]{1,...,365}{1} \\
\ganttbar{Task 1}{2}{5} \\
\end{ganttchart}

\end{document}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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