2

I have a matrix (formed by calendar) in a tikz picture. I have separated some days in the matrix by 3 rectangular blocks but the edges are overlapping. How can I prevent edges overlap? Thank you. bkarpuz

enter image description here

\documentclass[10pt]{standalone}

\usepackage{tikz}

\usetikzlibrary{calendar,backgrounds}

\begin{document}

\begin{tikzpicture}
\matrix{
  \calendar (sep18) [dates=2018-09-01 to 2018-09-last,week list,month label above centered]; \\
};
\begin{scope}[on background layer]
 \draw[draw=none,fill=orange,opacity=0.3] (sep18-2018-09-17.north west) -- (sep18-2018-09-23.north east)
   -- (sep18-2018-09-30.south east) -- (sep18-2018-09-24.south west) -- cycle;
 \draw[draw=black] (sep18-2018-09-17.north west) rectangle (sep18-2018-09-21.south east);
 \draw[draw=black] (sep18-2018-09-24.north west) rectangle (sep18-2018-09-24.south east);
 \draw[draw=black] (sep18-2018-09-25.north west) rectangle (sep18-2018-09-27.south east);
\end{scope}
\end{tikzpicture}

\end{document} 
3

First option, play with day xshift and day yshift until you faind the correct value to avoid overlapping:

\documentclass[10pt]{standalone}

\usepackage{tikz}

\usetikzlibrary{calendar,backgrounds, calc}

\begin{document}

\begin{tikzpicture}
\matrix{
  \calendar (sep18) [dates=2018-09-01 to 2018-09-last,week list,month label above centered, day xshift=4ex, day yshift=3.15ex]; \\
};
\begin{scope}[on background layer]
 \fill[orange,opacity=0.3] (sep18-2018-09-17.north west) rectangle (sep18-2018-09-30.south east);
 \draw[draw=black] (sep18-2018-09-17.north west) rectangle (sep18-2018-09-21.south east);
 \draw[draw=black] (sep18-2018-09-24.north west) rectangle (sep18-2018-09-24.south east);
 \draw[draw=black] (sep18-2018-09-25.north west) rectangle (sep18-2018-09-27.south east);
\end{scope}
\end{tikzpicture}

\end{document} 

enter image description here

Second option: draw rectangles based in middle coordinates between days and not on overlapping anchors.

\documentclass[10pt]{standalone}

\usepackage{tikz}

\usetikzlibrary{calendar,backgrounds, calc}

\begin{document}

\begin{tikzpicture}
\matrix{
  \calendar (sep18) [dates=2018-09-01 to 2018-09-last,week list,month label above centered]; \\
};
\begin{scope}[on background layer]
 \fill[orange,opacity=0.3] (sep18-2018-09-17.north west) rectangle (sep18-2018-09-30.south east);

 \coordinate (aux1) at ($(sep18-2018-09-21.south east)!.5!(sep18-2018-09-28.north east)$);
 \coordinate (aux2) at ($(sep18-2018-09-21.south east)!.5!(sep18-2018-09-29.north west)$);
 \draw[draw=black] (sep18-2018-09-17.north west) rectangle (aux1|-aux2);

 \draw[draw=black] ($(sep18-2018-09-17.south west)!.5!(sep18-2018-09-24.north west)$) rectangle ($(sep18-2018-09-24.south east)!.5!(sep18-2018-09-25.south west)$) coordinate (aux3);

 \draw[draw=black] (aux3) rectangle (aux1|-aux2);

\end{scope}
\end{tikzpicture}

\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.