2

Given the following code

\documentclass[a4paper,20pt]{extarticle}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[czech]{babel}
\usepackage[czech]{translator}
\usepackage{graphicx, comment, tikz}
\usetikzlibrary{calendar, shapes.misc} 
\usepackage{pgfkeys,pgfcalendar} 
\usepackage{geometry}
 \geometry{
 left=9mm,
 top=13mm,
 bottom=9mm,
 right=10mm
 }
\newcounter{tgmymo}
\setcounter{tgmymo}{0}
\newcommand{\mymo}[4]{%
    \begin{minipage}{\textwidth}%
        \centering%
        \stepcounter{tgmymo}
        \includegraphics[width=#4\textwidth]{#3}
    \end{minipage}
    
   \vfill

 \begin{center}
  {\textsc{\pgfcalendarmonthname{\value{tgmymo}}} 2024}
 \end{center}
    
    \vfill
    
    \noindent \begin{minipage}[t][10cm][t]{.99\textwidth}\centering
       \begin{tikzpicture}[thick]
    \pgfcalendar{cal}{#1}{#2}{%
        \ifdate{workday}%
        {\tikzset{filling/.style={fill=black!05}}}%
        {\tikzset{filling/.style={fill=orange!20}}}
        %%
        \def\normal{\node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle,rounded corners, text width=.105\textwidth,text height=9.796mm ,align=right] {\\ \pgfcalendarcurrentday};}%
        %%
       \def\bday#1{\node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle, rounded corners, text width=.105\textwidth,text height=9.796mm, align=right] {\\ \textcolor{red}{#1} \textcolor{red}{\pgfcalendarcurrentday}};}%
       
        %% birthdays will come here 
        \ifdate{equals=09-02}{\bday(mum)}{\normal}%
      


        %---end of birthdays     
        \ifdate{Sunday}{\pgftransformyshift{-2.35cm}}{}%
        };
        \end{tikzpicture}\end{minipage}
        \clearpage}
       
\begin{document}
\setlength\parindent{0pt}
\pagestyle{empty}
 \mymo{2024-01-01}{2024-01-last}{example-image}{.55}
 \mymo{2024-02-01}{2024-02-last}{example-image}{.9}
 \mymo{2024-03-01}{2024-03-last}{example-image}{.55}
 \mymo{2024-04-01}{2024-04-last}{example-image}{.55}
 \mymo{2024-05-01}{2024-05-last}{example-image}{.9}
 \mymo{2024-06-01}{2024-06-last}{example-image}{.9}
 \mymo{2024-07-01}{2024-07-last}{example-image}{.55}
 \mymo{2024-08-01}{2024-08-last}{example-image}{.6}
 \mymo{2024-09-01}{2024-09-last}{example-image}{.485}
 \mymo{2024-10-01}{2024-10-last}{example-image}{.55}
 \mymo{2024-11-01}{2024-11-last}{example-image}{.55}
 \mymo{2024-12-01}{2024-12-last}{example-image}{.475}
\end{document}

I want the \bday command to function. I want to pass one argument - the name of the person who has birthday on that particular day and I don't know the proper syntax. Thank you all ♥

2 Answers 2

3

Let's see...

  1. Use \newcommand for your \normal and \bday (it's LaTeX; try to avoid internal TeX things if you can).
  2. When you call \bday use {} to delimit the argument (not ()).
  3. Define the macros at the top level; defining macros inside macros can be done, but it's tricky and unnecessary here.
  4. I adjusted the macro \bday to produce the two-lines output I think you were looking for; not sure if I understood correctly.
\documentclass[a4paper,20pt]{extarticle}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[czech]{babel}
\usepackage[czech]{translator}
\usepackage{graphicx, comment, tikz}
\usetikzlibrary{calendar, shapes.misc}
\usepackage{pgfkeys,pgfcalendar}
\usepackage{geometry}
\geometry{ left=9mm, top=13mm, bottom=9mm, right=10mm }
\newcounter{tgmymo}
\setcounter{tgmymo}{0}
\newcommand\normal{%
    \node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle,rounded corners, text width=.105\textwidth,text height=9.796mm ,align=right] {\\ \pgfcalendarcurrentday};
}%
%%
\newcommand\bday[1]{%
    \node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle, rounded corners, text width=.105\textwidth,text height=9.796mm, align=right] { \textcolor{red}{#1}\\ \textcolor{red}{\pgfcalendarcurrentday}};
}%
\newcommand{\mymo}[4]{%
    \begin{minipage}{\textwidth}%
        \centering%
        \stepcounter{tgmymo}
        \includegraphics[width=#4\textwidth]{#3}
    \end{minipage}

    \vfill

    \begin{center}
        {\textsc{\pgfcalendarmonthname{\value{tgmymo}}} 2024}
    \end{center}

    \vfill

    \noindent
    \begin{minipage}[t][10cm][t]{.99\textwidth}
        \centering
        \begin{tikzpicture}[thick]
            \pgfcalendar{cal}{#1}{#2}{%
                \ifdate{workday}%
                    {\tikzset{filling/.style={fill=black!05}}}%
                    {\tikzset{filling/.style={fill=orange!20}}}
                    %%
                    %% birthdays will come here
                    \ifdate{equals=09-02}{\bday{mum}}{\normal}%



                    %---end of birthdays
                    \ifdate{Sunday}{\pgftransformyshift{-2.35cm}}{}%
                    };
                \end{tikzpicture}
            \end{minipage}
        \clearpage
}

\begin{document}
\setlength\parindent{0pt}
\pagestyle{empty}
\mymo{2024-01-01}{2024-01-last}{example-image}{.55}
\mymo{2024-02-01}{2024-02-last}{example-image}{.9}
\mymo{2024-03-01}{2024-03-last}{example-image}{.55}
\mymo{2024-04-01}{2024-04-last}{example-image}{.55}
\mymo{2024-05-01}{2024-05-last}{example-image}{.9}
\mymo{2024-06-01}{2024-06-last}{example-image}{.9}
\mymo{2024-07-01}{2024-07-last}{example-image}{.55}
\mymo{2024-08-01}{2024-08-last}{example-image}{.6}
\mymo{2024-09-01}{2024-09-last}{example-image}{.485}
\mymo{2024-10-01}{2024-10-last}{example-image}{.55}
\mymo{2024-11-01}{2024-11-last}{example-image}{.55}
\mymo{2024-12-01}{2024-12-last}{example-image}{.475}
\end{document}

enter image description here

1
  • Great explanation and solution, thank you very much!
    – JoudaBouda
    Jul 13, 2023 at 8:28
2

Adaptations

  • define the commands \normal and \bday outside \mymo with \newcommand
  • use curly brackets here \bday{mum}
  • put the line break for \bday between the name and the day
  • I combined parameter 1 and 2 of \mymo to be yyyy-mm

Code

\documentclass[a4paper,20pt]{extarticle}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc} 
\usepackage[czech]{babel}
\usepackage[czech]{translator}
\usepackage{graphicx, comment, tikz}
\usetikzlibrary{calendar, shapes.misc} 
\usepackage{pgfkeys,pgfcalendar} 
\usepackage{geometry}
\geometry{
    left=9mm,
    top=13mm,
    bottom=9mm,
    right=10mm
}
\newcounter{tgmymo}
\setcounter{tgmymo}{0}

\newcommand{\normal}{%
    \node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle,rounded corners, text width=.105\textwidth,text height=9.796mm ,align=right] {\\ \pgfcalendarcurrentday};
}

\newcommand{\bday}[1]{%
    \node (\pgfcalendarsuggestedname) at (\pgfcalendarcurrentweekday*2.52,0) [filling, rectangle, rounded corners, text width=.105\textwidth,text height=9.796mm, align=right] {\textcolor{red}{#1}\\ \textcolor{red}{\pgfcalendarcurrentday}};
}

\newcommand{\mymo}[3]{%
    \begin{minipage}{\textwidth}%
        \centering%
        \stepcounter{tgmymo}
        \includegraphics[width=#3\textwidth]{#2}
    \end{minipage}
    
    \vfill
    
    \begin{center}
        {\textsc{\pgfcalendarmonthname{\value{tgmymo}}} 2024}
    \end{center}
    
    \vfill
    
    \noindent
    \begin{minipage}[t][10cm][t]{.99\textwidth}\centering
        \begin{tikzpicture}[thick]
            \pgfcalendar{cal}{#1-01}{#1-last}{%
                \ifdate{workday}%
                {\tikzset{filling/.style={fill=black!05}}}%
                {\tikzset{filling/.style={fill=orange!20}}}
                
                %% birthdays will come here 
                \ifdate{equals=09-02}{\bday{mum}}{\normal}%
                
                %---end of birthdays     
                \ifdate{Sunday}{\pgftransformyshift{-2.35cm}}{}%
            };
        \end{tikzpicture}
    \end{minipage}
    \clearpage
}

\begin{document}
\setlength\parindent{0pt}
\pagestyle{empty}
\mymo{2024-01}{example-image}{.55}
\mymo{2024-02}{example-image}{.9}
\mymo{2024-03}{example-image}{.55}
\mymo{2024-04}{example-image}{.55}
\mymo{2024-05}{example-image}{.9}
\mymo{2024-06}{example-image}{.9}
\mymo{2024-07}{example-image}{.55}
\mymo{2024-08}{example-image}{.6}
\mymo{2024-09}{example-image}{.485}
\mymo{2024-10}{example-image}{.55}
\mymo{2024-11}{example-image}{.55}
\mymo{2024-12}{example-image}{.475}
\end{document}

You must log in to answer this question.

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