1

I´d like to have the day numbers in devanagari digits with polyglossia. The latter provides \devanagaridigits{} to convert digits but simply doing \devanagaridigits{\tikzdaytext} in \pgfkeys{/tikz/day code= {...}} is not working.

here is my mwe:

\documentclass{beamer}

\mode<presentation>
{    \usetheme{metropolis}    }

\geometry{verbose,papersize={160mm,90mm}}

\usepackage{fontsize,fix-cm}

\usepackage{polyglossia}
\newfontfamily\devanagarifontsf[Script=Devanagari]{NotoSansDevanagari}

\setmainlanguage{sanskrit}
\setmainfont[Script=Devanagari]{NotoSansDevanagari}
 
\usepackage{tikz}
\usetikzlibrary{calendar,fit}

\pgfkeys{/tikz/day code =
  {
    \node (lower right) at (0,0) [above left,font=\large] {
      \tikzdaytext};  
% here \devanagaridigits{\tikzdaytext} is not working

    \node (upper left) at (-\cellwidth,\cellheight)
    [below right,align=left,text width=\cellwidth-\pgflinewidth,
    font=\tiny,black] {};
    \node (lower left) at (-\cellwidth,0) {};
    \node[rounded corners, draw,
          fit=(lower right) (upper left) (lower left),
          inner sep=1mm] {};
  }
}

\pgfkeys{/tikz/inner sep = 0pt}
\pgfkeys{/tikz/day xshift=\cellwidth+2mm+2mm}
\pgfkeys{/tikz/day yshift=\cellheight+2mm+2mm}

\newlength{\cellheight}
\setlength{\cellheight}{5mm}
\newlength{\cellwidth}
\setlength{\cellwidth}{7mm}

\begin{document}
\begin{frame}{दिनदर्शिका}

  \begin{tikzpicture}
    \calendar (mycal) [dates=\year-10-29 to \year-11-2,
    day list right];
  \end{tikzpicture}

\end{frame}
\end{document}
0

1 Answer 1

1

The default \tikzdaytext is the shorthand \%d- (shortest representation, i.e. without leading zero) which is not expandable by default.

You will need to use either

  • \%d0 or \pgfcalendarcurrentday, a macro that just contains the day number but with leading zero, or
  • \number\%d0\relax which turns the digits to a number losing the leading zero.

In the first case, we'd need to expand \%d0 properly (twice actually)

\expandafter\devanagaridigits\expanded{{\%d0}}

but we don't need that with \pgfcalendarcurrentday.

Code

% !TeX TS-program = lualatex
\documentclass{beamer}
\mode<presentation>{\usetheme{metropolis}}
\geometry{verbose,papersize={160mm,90mm}}
\usepackage{fontsize,fix-cm}
\usepackage{polyglossia}
\newfontfamily\devanagarifontsf[Script=Devanagari]{NotoSansDevanagari}
\setmainlanguage{sanskrit}
\setmainfont[Script=Devanagari]{NotoSansDevanagari}
\usepackage{tikz}
\usetikzlibrary{calendar}
\tikzset{
  my calendar/.style={
    day list right,
    days={
      anchor=base, font=\large,
      text width=7mm-2*(\pgfkeysvalueof{/pgf/inner xsep}),
      align=right, text depth=+0pt,
      rounded corners, draw,
    },
    day xshift=7mm+4mm,
    day yshift=5mm+4mm,
  },
  use devanagari zerofill/.style={
    day text=\devanagaridigits{\pgfcalendarcurrentday}},
  use devanagari shortest/.style={
    day text=\devanagaridigits{\number\%d0\relax}},
}
\begin{document}
\begin{frame}{दिनदर्शिका}
\tikz\calendar[my calendar] (mycal) [
   dates=\year-10-29 to \year-11-2,
];

\tikz\calendar[my calendar, use devanagari zerofill] (mycal) [
   dates=\year-10-29 to \year-11-2,
];

\tikz\calendar[my calendar, use devanagari shortest] (mycal) [
   dates=\year-10-29 to \year-11-2,
];
\end{frame}
\end{document}

Output

enter image description here

3
  • nice! ...another point, you have changed my day code = {} with days={}. This way, can I add the day name just above the square, and other features such as a drawing for bank holidays? Is there a way to force the display of the month label even if only a few last days are displayed? For example i want a label saying october above the 29, 30, 31. And november above 1, 2. With month above label left only november appears. Nothing at all if i do month above label right, I mean not even 'october' Commented Oct 20, 2023 at 16:11
  • @user1850133 Sure. The day code is preset with a node of style every day which days appends to. So, doing days={label={above:\%mt}} adds a label to each node with the full name of the month. (You probably need to change the font size for that.) The provided keys place only one single “label” per month. We can't use those. For changing the single days because they land on a specific date, the another look into the manual. That's half of the point of the calendar library/module. Commented Oct 20, 2023 at 17:09
  • AFAIK, label instances are very limited. The base textbox needs to be adjusted manually its text depth otherwise boxes are aligned but the text that they contain are not. This is why i used \node's. It seems with days={...} I can't do days={\node [above, text depth=.25ex, text height=1.5ex] {\%wt} }, is it? Commented Oct 22, 2023 at 10:36

You must log in to answer this question.

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