15

Using this code:

\documentclass[11pt,BCOR8mm,final,a4paper]{scrbook}
\usepackage[germanb]{babel}
\usepackage[latin1]{inputenc}
\usepackage{tikz,geometry}
\usetikzlibrary{positioning}
\usetikzlibrary{calendar}

% code used: https://tex.stackexchange.com/questions/10186/weekday-captions-with-the-tikz-library-calendar
% with the correction of Torbjørn T.

\makeatletter%
\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}%
  \pgftransformyshift{-\pgf@ya}
  \foreach \d/\l in {0/M,1/D,2/M,3/D,4/F,5/S,6/S} {
    \pgf@xa=\d\pgf@xa%
    \pgftransformxshift{\pgf@xa}%
    \pgftransformyshift{\pgf@ya}%
    \node[every day,day heading]{\l};%
  } 
}{}%
}%
]

\makeatother%


\begin{document}
\begin{center}

\begin{tikzpicture}

\calendar[dates=2017-07-01 to 2017-07-last,
    week list,
    month label above centered,
    day xshift = 0.8cm,
    day headings=blue,
    if={(equals=07-10) [nodes={draw,thick}]},
    if={(equals=07-11) [nodes={draw,thick}]},
    if={(equals=07-12) [nodes={draw,thick}]},
    if={(equals=07-19) [nodes={draw,thick}]},
    if={(equals=07-20) [nodes={draw,thick}]},
    if={(equals=07-21) [nodes={draw,thick}]},
    day letter headings
];

\end{tikzpicture}
\end{center}
\end{document}

leads to:

enter image description here

but I would like to have a result like this one:

enter image description here

Anyway, is this possible? I have no idea...

Thanks a lot

1 Answer 1

15

You can refer the current node with cal-\%y0-\%m0-\%d0 if the calendar is named cal and use it in combination with execute at end day scope (source: answer to TikZ-calendar: How to refer to the node of current date?).

I created the tikzstyles triangle nw, triangle ne, triangle sw, triangle se and rectangle.

I used tikzset instead of tikzstyle (see Should \tikzset or \tikzstyle be used to define TikZ styles?).

\documentclass[11pt,BCOR8mm,final,a4paper]{scrbook}
\usepackage[germanb]{babel}
\usepackage[latin1]{inputenc}
\usepackage{tikz,geometry}
\usetikzlibrary{positioning}
\usetikzlibrary{calendar}

\usepackage{ifthen}

\makeatletter
\tikzset{
    % code used: https://tex.stackexchange.com/questions/10186/weekday-captions-with-the-tikz-library-calendar
    % with the correction of Torbjørn T.
    day headings/.style={
        day heading/.style={#1}
    },
    day heading/.style={},
    day letter headings/.style={
        execute before day scope={
            \ifdate{day of month=1}{%
                \pgfmathsetlength{\pgf@ya}{\tikz@lib@cal@yshift}%
                \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
                \pgftransformyshift{-\pgf@ya}
                \foreach \d/\l in {0/M,1/D,2/M,3/D,4/F,5/S,6/S} {
                    \pgf@xa=\d\pgf@xa%
                    \pgftransformxshift{\pgf@xa}%
                    \pgftransformyshift{\pgf@ya}%
                    \node[every day,day heading]{\l};%
                }
            }{}%
        }%
    },
    %
    % new border styles
    rectangle/.style={
        nodes={draw,thick}
    },
    triangle nw/.style={
        execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.south west) |- (cal-\%y0-\%m0-\%d0.north east) -- cycle;}
    },
    triangle ne/.style={
        execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.north west) -| (cal-\%y0-\%m0-\%d0.south east) -- cycle;}
    },
    triangle sw/.style={
        execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.north west) |- (cal-\%y0-\%m0-\%d0.south east) -- cycle;}
    },
    triangle se/.style={
        execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.south west) -| (cal-\%y0-\%m0-\%d0.north east) -- cycle;}
    },
}
\makeatother

\begin{document}
\begin{center}
\begin{tikzpicture}
    \calendar (cal) [
        dates=2017-07-01 to 2017-07-last,
        week list,
        month label above centered,
        day xshift = 0.8cm,
        day headings=blue,
        if={(equals=07-10) [rectangle]},
        if={(equals=07-11) [rectangle]},
        if={(equals=07-12) [triangle nw]},
        if={(equals=07-19) [triangle se]},
        if={(equals=07-20) [rectangle]},
        if={(equals=07-21) [rectangle]},
        day letter headings
    ];
\end{tikzpicture}
\end{center}
\end{document}

enter image description here

0

You must log in to answer this question.

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