13

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

13

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.

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

\usepackage{ifthen}

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

\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\makeatletter%
\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%
\tikzstyle{rectangle}=[
    nodes={draw,thick}
]
\tikzstyle{triangle nw}=[
    execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.south west) |- (cal-\%y0-\%m0-\%d0.north east) -- cycle;}
]
\tikzstyle{triangle ne}=[
    execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.north west) -| (cal-\%y0-\%m0-\%d0.south east) -- cycle;}
]
\tikzstyle{triangle sw}=[
    execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.north west) |- (cal-\%y0-\%m0-\%d0.south east) -- cycle;}
]
\tikzstyle{triangle se}=[
    execute at end day scope={\draw[thick] (cal-\%y0-\%m0-\%d0.south west) -| (cal-\%y0-\%m0-\%d0.north east) -- cycle;}
]

\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.