14

Currently I have some basic code using the tikz calendar library:

\usepackage{tikz}
\usetikzlibrary{calendar}
\tikz
\calendar [dates=2014-01-01 to 2014-1-last,
           week list, month label above left] 
if (Sunday) [red];

which produces this:

Week list

Is there anyway I can create a "fortnight list" arrangement, so that I get something resembling the following, i.e. putting two weeks on the same row?

Fortnight list

1 Answer 1

13
+50

You can define a tikzstyle to achieve that.

enter image description here

\documentclass{article}

\usepackage{tikz}
    \usetikzlibrary{calendar}

\makeatletter
\tikzstyle{biweek list}=[%
    execute at begin day scope={%
        \pgftransformyshift{-0.6cm}%
        \pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
        \pgf@x=\pgfcalendarcurrentweekday\pgf@x%
        \pgftransformxshift{\pgf@x}%
        \pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
        \ifcsname pgfcalendarbiweek\endcsname%
            \pgf@x=7\pgf@x%
            \pgftransformxshift{\pgf@x}%
        \fi%
    },
    execute after day scope={%
        \ifdate{Sunday}{%
            \ifcsname pgfcalendarbiweek\endcsname%
                \let\pgfcalendarbiweek\undefined%
                \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
                \pgftransformyshift{-\pgf@y}%
            \else%
                \let\pgfcalendarbiweek\relax%
            \fi%
        }{}%
    },
    execute at end day scope={%
            \pgfmathsetlength\pgf@y{\tikz@lib@cal@yshift}%
            \pgftransformyshift{1cm}%
        }
]

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

\begin{document}

\tikz
\calendar[
    dates=1997-06-01 to 1997-08-last,
    biweek list,
    biweek day letter headings,
    month label above left,
    month text=\bfseries\large\%mt \%y0
] if (Sunday) [red];

\end{document}

Based on a solution by Jake.

2
  • Works great, thanks! One small problem: things doesn't seem to be working quite right for >1 month e.g. dates=1997-06-01 to 1997-07-last, even if I have month yshift=5cm. This isn't an urgent requirement though, as currently I just need 1 month at any one time.
    – imnothere
    Nov 22, 2013 at 16:08
  • @LianTzeLim I've just added a fix for that.
    – masu
    Nov 22, 2013 at 18:55

You must log in to answer this question.

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