5

I would like to create a list calendar of days showing only Sundays, and be able to annotate the day as well.

The following loathly hack sort of approximates to what I want, but has a number of weaknesses:

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{calendar}

\begin{document}

\begin{tikzpicture}
    \calendar [dates=2013-09-01 to 2013-12-last,
        day list downward, month yshift=1em, day yshift=.3em,
        month label left]
        if(Saturday,workday) [shape=coordinate]
        if (equals=2013-09-01) {\draw (0.5,0) node [anchor=west] {The first Sunday};}
        if (equals=2013-10-06) {\draw (0.5,0) node [anchor=west] {The first Sunday of October};};
\end{tikzpicture}

\end{document}
  1. There must be a better way to show only Sundays.

  2. In the output, the annotation does not have the same baseline as the day number.

  3. The first Sunday of the month aligns with the month label only if that Sunday happens to fall on the first of the month.

1
  • Re 2: The every day node has a preset of anchor=base east so setting the annotation to anchor=base west corrects the vertical alignment. Apr 30, 2013 at 13:49

1 Answer 1

6

Let’s introduce a new style sunday list downward. It quite simple: Only shift down after a Sunday. And shift the month as usual.

Code

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\makeatletter
\tikzset{sunday list downward/.style={%
  execute before day scope={
  \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
        {%
          \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
          \pgftransformyshift{-\pgf@y}
        }%
      }{}%
  },
  execute after day scope={
  \ifdate{Sunday}{%
          \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
          \pgftransformyshift{-\pgf@y}
      }{}%
  },
  tikz@lib@cal@width=1,
  if={(Sunday) [] else [shape=coordinate]}
}}
\makeatother
\tikzset{
    @annote/.style={
        every day/.append style={
            label={[text depth=+.5pt]right:{#1}}
        }
    },
    annote/.style args={#1with#2}{
        if={(equals=#1)[@annote={#2}]}
    },
    annote*/.style args={#1with#2}{
        if={(equals=#1){\annote[]{#2}}}
    }
}
\newcommand*{\annote}[2][]{\node[anchor=base west,at={(0.5,0)},#1] {#2};}
\begin{document}

\begin{tikzpicture}[label distance=.5cm]
    \calendar [dates=2013-09-01 to 2013-12-last,
        sunday list downward,
        day yshift=1.2\baselineskip,
        month yshift=1\baselineskip,
        month label left,
        annote=2013-09-01 with The first Sunday,
        annote=2013-10-06 with The first Sunday of October,
        annote*=2013-10-13 with Yet another Sunday in October
        ];
\end{tikzpicture}
\end{document}

Output

enter image description here

2
  • Wow! Yes some space between the months would be a Good Thing, though I notice that a simple month yshift=1em does not work.
    – sgmoye
    Apr 30, 2013 at 14:53
  • @sgmoye Yes, because I have removed the original content of day list downward, but have included it in the updated answer. Apr 30, 2013 at 15:41

You must log in to answer this question.

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