3

I want to highlight a range of dates in a tikz calendar (e.g. vacations or conferences). My approach currently is to simply (stupidly?) highlight every single day (see the code), but there is for sure a better option.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calendar}

\begin{document}
\begin{tikzpicture}
    \calendar[dates=2018-10-01 to 2018-10-last,
              week list,
              month label above centered]
        if (weekend) [black!50]
        if (equals=2018-10-01) [black!50]
        if (equals=2018-10-02) [black!50]
        if (equals=2018-10-03) [black!50]
        if (equals=2018-10-04) [black!50];
\end{tikzpicture}
\end{document}

As I said, this works (see the screenshot), but is there an option how to specify a range of dates within the if condition (or somewhere else) ?

October

5

For sure! Use if (between=date and date) instead of multiple if (equals=date).

\begin{document}
    \begin{tikzpicture}
    \calendar[dates=2018-10-01 to 2018-10-last,
    week list,
    month label above centered]
    if (weekend) [black!50]
    if (equals=2018-10-01) [black!50]
    if (equals=2018-10-02) [black!50]
    if (equals=2018-10-03) [black!50]
    if (equals=2018-10-04) [black!50]
    if (between=2018-10-15 and 2018-10-18) [red!50];
    \end{tikzpicture}
\end{document}

enter image description here

  • the simple answer I was hoping for, thanks :) – Alf Oct 17 '18 at 10:37

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.