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'd like to create a wall calendar where the bottom of each page is a tikzpicture, stretching the list of days always to the \linewidth, as if it was justified text.

How can I set a calendar style that will xshift the days just so? I got as far as you can see below, but since day xshift={0.0322\linewidth} is fixed, it only works for 31 day months.

calendar months

\documentclass[11pt]{article}

\usepackage[showframe]{geometry}

\usepackage{tikz}
\usetikzlibrary{calendar}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\definecolor{gold}{RGB}{199,147,22}

\begin{document}

\raggedright

\makeatletter

\tikzset{
  every calendar/.style={
    day list right,
    day xshift={0.0322\linewidth},
    month text={\color{gold}\%mt \%y0},
    month label above left,
    execute at begin day scope={
      \ifdate{Sunday}{\color{red}}
    }
  }
}

\makeatother

\raggedright

\tikz\calendar[dates=2013-01-01 to 2013-01-last];
\tikz\calendar[dates=2013-02-01 to 2013-02-last];
\tikz\calendar[dates=2013-03-01 to 2013-03-last];
\tikz\calendar[dates=2013-04-01 to 2013-04-last];
\tikz\calendar[dates=2013-05-01 to 2013-05-last];

\end{document}
share|improve this question
add comment

1 Answer 1

up vote 12 down vote accepted

You can use the execute after day scope to execute some code to extract the number of days in the current month and perform a \pgftransformxshift accordingly:

\documentclass[11pt]{article}

\usepackage[showframe]{geometry}

\usepackage{tikz}
\usetikzlibrary{calendar}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\definecolor{gold}{RGB}{199,147,22}

\begin{document}

\raggedright


\tikzset{
  every calendar/.style={
    day list right,
    day xshift={0pt},
    month text={\color{gold}\%mt \%y0},
    month label above left,
    execute at begin day scope={
      \ifdate{Sunday}{\color{red}}
    },
    execute after day scope=   
    {
      \pgfcalendarjuliantodate{\pgfcalendarendjulian}{\currentyear}{\currentmonth}{\lastday}
      \pgftransformxshift{\textwidth/\lastday}
    }
  }
}



\tikz\calendar[dates=2013-01-01 to 2013-01-last];
\tikz\calendar[dates=2013-02-01 to 2013-02-last];
\tikz\calendar[dates=2013-03-01 to 2013-03-last];
\tikz\calendar[dates=2013-04-01 to 2013-04-last];
\tikz\calendar[dates=2013-05-01 to 2013-05-last];

\end{document}

If you want the space between each day to be equal (which looks much nicer in this case), a little more calculation is needed:

\documentclass[11pt]{article}

\usepackage[showframe]{geometry}

\usepackage{tikz,calc}
\usetikzlibrary{calendar}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\definecolor{gold}{RGB}{199,147,22}

\begin{document}

\raggedright
\makeatletter
\tikzset{
  every calendar/.style={
    day list right,
    day xshift={0pt},
    month text={\color{gold}\%mt \%y0},
    every month/.append style={inner xsep=0pt},
    every day/.append style={anchor=east, inner xsep=0pt},
    month label above left,
    if=(Sunday) [red],
    execute before day scope={
    \ifdate{day of month=1}{
        \pgftransformxshift{-\widthof{01}}
    }{
            \pgfcalendarjuliantodate{\pgfcalendarendjulian}{\currentyear}{\currentmonth}{\lastday}
        \pgfmathparse{(\textwidth-\widthof{123456789}-\widthof{10111213141516171819202122232425262728}-\widthof{30}*(\lastday-28))/(\lastday-1)}
        \pgftransformxshift{\pgfmathresult}     
        \let\%=\pgfcalendarshorthand
        \setlength{\pgf@xc}{\widthof{\%d-}}
        \pgftransformxshift{\pgf@xc}
        }
    }
  }
}



\tikz\calendar[dates=2013-01-01 to 2013-01-last];
\tikz\calendar[dates=2013-02-01 to 2013-02-last];
\tikz\calendar[dates=2013-03-01 to 2013-03-last];
\tikz\calendar[dates=2013-04-01 to 2013-04-last];
\tikz\calendar[dates=2013-05-01 to 2013-05-last];
\end{document}
share|improve this answer
    
Thanks, this is great! –  Nyiti Nov 30 '11 at 7:49
add comment

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.