4

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

1 Answer 1

7

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

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

You must log in to answer this question.

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