TeX - LaTeX Asked by jd6 on January 16, 2021
I’m trying to create a monthly calendar using Tikz.
I am using this template. Everything is working fine, except the fact that I would like to be able to have the numbers of the days from the previous and next months which are in the displayed weeks, like in this example (Figure 7.7). I see that it is possible with PGF. Can I do it with Tikz calendar as well?
In a very simply way with tikZ this can be done using the dates
key and if (<test date>) [<style>]
path of the calendar
command. Both are well documented in the PGFmanual.
There can be more clever solutions. With this solution for example with the following code:
documentclass[border=3mm]{standalone}
usepackage{tikz}
usetikzlibrary{calendar}
newcommand{calOfTheMonth}[4]{%
calendar [dates=2021-0#1-01+-#2 to 2021-0#1-last+#3,week list,month yshift=0pt]
if (between=2021-0#1-01+-#2 and 2021-0#1-01+-1) [gray]
if (between=2021-0#1-last+1 and 2021-0#1-last+#3) [gray];
node[above=3ex,anchor=west] {#4};}
begin{document}
%Explanation of the calOfTheMonth macro
% calOfTheMonth{n. of the month}{days to add before}{days to add after}{name of the month}
tikz
matrix{
calOfTheMonth{1}{4}{0}{January}
calOfTheMonth{2}{0}{0}{February}
calOfTheMonth{3}{0}{4}{March}
calOfTheMonth{4}{3}{2}{April}
calOfTheMonth{5}{5}{6}{May}
calOfTheMonth{6}{1}{4}{June}
calOfTheMonth{7}{3}{1}{July}
calOfTheMonth{8}{6}{5}{August}
calOfTheMonth{9}{2}{3}{September}
calOfTheMonth{10}{4}{0}{October}
calOfTheMonth{11}{0}{5}{November}
calOfTheMonth{12}{2}{2}{December}
};
end{document}
Correct answer by vi pa on January 16, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP