9

I read about week list in the PGF/TikZ manual, but I couldn't find an example that arranges the days of the week vertically:

June 1997

M   2  9 16 23 30
T   3 10 17 24
W   4 11 18 25
T   5 12 19 26
F   6 13 20 27
S   7 14 21 28
S 1 8 15 22 29

Could you help me with an example of how to create a week list arrangement like this?

1

2 Answers 2

8

Here's a new style vertical week list, which is adapted from the week list style found in the TikZ source code. The day labels are adapted from the answer to Weekday captions with the TikZ library "calendar".

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calendar}

 \makeatletter
\tikzstyle{week list}=[%
  execute before day scope={%
    \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
      {%
        % On first of month, except when first date in calendar.
        \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@month@xshift}%
        \pgftransformxshift{\pgf@x}
      }%
    }{}%
  }, 
  execute at begin day scope={%
    \pgfmathsetlength\pgf@y{\tikz@lib@cal@yshift}%
    \pgf@y=\pgfcalendarcurrentweekday\pgf@y%
    \pgftransformyshift{-\pgf@y}%
  },
  execute after day scope={%
    \ifdate{Sunday}{%
      \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@xshift}%
      \pgftransformxshift{\pgf@x}
    }{}%
  }
]

\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
    execute before day scope={ \ifdate{day of month=1}{%
      \pgfmathsetlength\pgf@ya{\tikz@lib@cal@yshift}%
      \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
      \pgftransformxshift{\pgf@xa}
      \foreach \d/\l in {0/M,1/T,2/W,3/T,4/F,5/S,6/S} {
        \pgf@ya=\d\pgf@ya%
        \pgftransformxshift{-\pgf@xa}%
        \pgftransformyshift{-\pgf@ya}%
        \node[every day,day heading, anchor=base]{\l};%
      } 
    }{}%
  }%
]
\makeatother


\begin{document}
\begin{tikzpicture}
\calendar[
    dates=1997-06-01 to 1997-06-last,
    week list,
    day letter headings,
    day heading/.style={gray, xshift=-1em},
    month label above left,
    month text=\%mt \%y0
];
\end{tikzpicture}
\end{document}
8

You could use \pgftransformyshift for shifting days down. Here's an example style arranging the days vertically:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\tikzstyle{week list downward}=[%
  execute before day scope={%
    \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{%
      \pgftransformxshift{1.5em}}%
    }{}}, 
  execute after day scope={%
    \ifdate{Sunday}{%
      \pgftransformyshift{6em}
      \pgftransformxshift{1.5em}
    }{\pgftransformyshift{-1em}}},
]
\begin{document}
  \tikz\calendar [dates=2012-01-01 to 2012-03-last,week list downward];
\end{document}

weekly calender with vertically arranged days

1
  • Thanks, great example of \pgftransformyshift!
    – Gambhiro
    Jan 2, 2012 at 10:04

You must log in to answer this question.

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