1

problem or question to create a personalized weekly calendar. Is there a smarter way?

I made the code below to create an agenda for my wife. I had some problems, but I managed to do it. But I believe that there must be a smarter way of doing the same thing.

In the loop, I put the beginning of each day of the week and month, for example 10/2 (10 February). 10 (variable diaI is Monday) and variable diaF is equivalent to the end of the week (Sunday). Obviously the title was wrong when it is the 28th (for example), because the sum is 35 ... it is not complicated to arrange, it would be enough to put the value also in the foreach instead of calculating.

But is there a better way to do the same?

\documentclass[12pt]{article}
\usepackage[landscape, a4paper, margin=1.5cm]{geometry}
\usepackage{tgheros,tikz,array}
\usepackage[brazil]{babel}  
\usepackage[brazil]{translator}
\usepackage[utf8]{inputenc}
\usetikzlibrary{calendar}
\begin{document}
    \sffamily

    \newcommand\zero[1]{%
        \pgfmathparse{#1<10?"0":{},int(#1)}\pgfmathresult%
    }

    \newcommand\daytext[2]{%
      \begin{tabular}{|>{\mdseries\tiny}r|p{3cm}|}
        \multicolumn{2}{c}{#1} \\
        \multicolumn{2}{c}{#2\color{black}} \\[1ex]
        \hline
        7:30 & \\\hline
        8:00 & \\\hline
        8:30 & \\\hline
        9:00 & \\\hline
        9:30 & \\\hline
        10:00 & \\\hline
        10:30 & \\\hline
        11:00 & \\\hline
        11:30 & \\\hline
        12:00 & \\\hline
        12:30 & \\\hline
        13:00 & \\\hline
        13:30 & \\\hline
        14:00 & \\\hline
        14:30 & \\\hline
        15:00 & \\\hline
        15:30 & \\\hline
        16:00 & \\\hline
        16:30 & \\\hline
        17:00 & \\\hline
        17:30 & \\\hline
        18:00 & \\\hline
        18:30 & \\\hline
        19:00 & \\\hline
        19:30 & \\\hline
        20:00 & \\\hline
        20:30 & \\\hline
        21:00 & \\\hline
    \end{tabular}
    }

    \foreach [evaluate=\diaF using \diaI+7] \diaI/\Mes in {   
        10/2, 17/2,  24/2,
        2/3,  9/3,   16/3,  23/03, 30/03,
        6/4,  13/4,  20/4,  27/4,
        4/5,  11/5,  18/5,  25/5,
        1/6,  8/6,   15/6,  22/6, 29/6,
        6/7,  13/7,  20/7,  27/7,
        3/8,  10/8,  17/8,  24/8,
        7/9,  14/9,  21/9,  28/9,
        5/10, 12/10, 19/10, 26/10,
        2/11, 9/11,  16/11, 23/11, 30/11,
        7/12, 14/12, 21/12, 28/12}{
        \begin{tikzpicture}
        \node at (9,9) {\Huge Planejamento Rosa Lantmann de \zero{\diaI} até dia \zero{\diaF}/\zero{\Mes}/2020};
        \calendar (cal)
        [dates=2020-\Mes-\diaI to 2020-\Mes-\diaF,day list right,day xshift=4.5cm, 
        month xshift=0pt, day text={\daytext{\%wt}{\Huge\%d-}}]
        if(equals=04-20, 
           equals=04-21,
           equals=05-01,
           equals=09-07,
           equals=09-08,
           equals=10-12,
           equals=11-02,
           equals=11-15,
           equals=12-24,
           equals=12-25,
           equals=12-30) [font=\bfseries,red]
        if(weekend) [red]
        if(Sunday) [shape=coordinate];
        \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

Browse other questions tagged or ask your own question.