1

I saw this question: Using Tikz Calendar in Portuguese as a Syllabus and tried to translate it to persian (solar hijri).

The below example code works nice, but the problem is this: for example 1st day of "Dey" (one month of persian calendar) is equal to 22th December and 1st day of next month ("Bahman") is equal to 21th of January.

How can I define the calendar to make those properties work?

Thanks a lot!

\documentclass{standalone}    
\usepackage[portuguese]{babel}    
\usepackage{tikz}    
  \usetikzlibrary{calendar}    
\usepackage[portuguese]{translator}

\deftranslation[to=portuguese]{January}{‏آبان}
\deftranslation[to=portuguese]{February}{آذر}
\deftranslation[to=portuguese]{March}{‎Dey‎}
\deftranslation[to=portuguese]{April}{‎Bahman‎}
\deftranslation[to=portuguese]{May}{‎‏اسفند}
\deftranslation[to=portuguese]{June}{فروردین}
\deftranslation[to=portuguese]{July}{اردیبهشت}
\deftranslation[to=portuguese]{August}{خرداد}
\deftranslation[to=portuguese]{September}{تیر}
\deftranslation[to=portuguese]{October}{مرداد}
\deftranslation[to=portuguese]{November}{‎‏شهریور}
\deftranslation[to=portuguese]{December}{مهر}

\deftranslation[to=portuguese]{Mon}{دوشنبه}
\deftranslation[to=portuguese]{Tue}{سه‌شنبه}
\deftranslation[to=portuguese]{Wed}{چهارشنبه}
\deftranslation[to=portuguese]{Thu}{پنج‌شنبه}
\deftranslation[to=portuguese]{Fri}{جمعه}
\deftranslation[to=portuguese]{Sat}{شنبه}
\deftranslation[to=portuguese]{Sun}{یکشنبه}

\newcounter{lecture}
\setcounter{lecture}{1}
‎\usepackage{xepersian}‎‎
\settextfont{Yas}
\begin{document}

\tikz[every day/.style={anchor=east}]
\calendar [dates=2013-3-1 to 2013-3-2,day list downward, month label above left,day text={\%w. \%d=}]
if (Sunday) [black!50,nodes={draw=none}] %Cinza para dias sem aula
if (‎Friday‎) [red]
if (Monday,Tuesday) {\node[anchor=west] at (.5,0) 
  {\stepcounter{lecture}تعطیل \arabic{lecture} \csname lecture \arabic{lecture}\endcsname};};    
\end{document}

mwe_output

  • Does the answer below help you? – Ruben Aug 4 '15 at 2:08
  • ... You could consider then to upvote and accept it. – Ruben Aug 8 '15 at 1:56
0

It's hard to translate them because February can have 28 days and December has 31, and it's hard to find a relation between these two. Don't use tikz in this case. You can add some new commands and modify the calendar by yourself.

Once I needed something like that. This is what I got:

\documentclass{article}
\usepackage[a5paper]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage{ifthen}
\usepackage{forloop}
\usepackage{amsmath}
\usepackage{xepersian}

\settextfont[Scale=1.0]{XB Yas}

\title{تقویم سال ۱۳۹۴}
\author{}
\date{}
\pagenumbering{gobble}

\newcounter{daycount}
\newcounter{monthcount}
\setcounter{daycount}{0}
\setcounter{monthcount}{1}
\newcounter{yearcount}
\setcounter{yearcount}{1394}
\newcounter{dispdaycount}
\setcounter{dispdaycount}{0}
\newcounter{masterDayCount}

\newcommand{\displayday}[1]{
    \ifthenelse{\equal{#1}{1}}{شنبه}{}
    \ifthenelse{\equal{#1}{2}}{یک شنبه}{}
    \ifthenelse{\equal{#1}{3}}{دو شنبه}{}
    \ifthenelse{\equal{#1}{4}}{سه شنبه}{}
    \ifthenelse{\equal{#1}{5}}{چهار شنبه}{}
    \ifthenelse{\equal{#1}{6}}{پنج شنبه}{}
    \ifthenelse{\equal{#1}{7}}{جمعه}{}
}

\newcommand{\displaymonth}[1]{
    \ifthenelse{\equal{#1}{1}}{فروردین}{}
    \ifthenelse{\equal{#1}{2}}{اردیبهشت}{} 
    \ifthenelse{\equal{#1}{3}}{خرداد}{}
    \ifthenelse{\equal{#1}{4}}{تیر}{}
    \ifthenelse{\equal{#1}{5}}{مرداد}{}
    \ifthenelse{\equal{#1}{6}}{شهریور}{}
    \ifthenelse{\equal{#1}{7}}{مهر}{}
    \ifthenelse{\equal{#1}{8}}{آبان}{}
    \ifthenelse{\equal{#1}{9}}{آذر}{}
    \ifthenelse{\equal{#1}{10}}{دی}{} 
    \ifthenelse{\equal{#1}{11}}{بهمن}{}
    \ifthenelse{\equal{#1}{12}}{اسفند}{}
}

\newcommand{\checkdate}[2]{
    \ifthenelse{#2=1 \or #2=2 \or #2=3 \or #2=4 \or #2=5 \or #2=6}
    {
        \ifthenelse{#1>31}
        {        
            \addtocounter{daycount}{-31}
            \addtocounter{monthcount}{1}
        }{}

    }{}

    \ifthenelse{#2=7 \or #2=8 \or #2=9 \or #2=10 \or #2=11}
    {
        \ifthenelse{#1>30}
        {
            \addtocounter{daycount}{-30}
            \addtocounter{monthcount}{1}
        }{}
    }{}

    \ifthenelse{#2=12}
{
        \ifthenelse{#1>29}
        {
            \addtocounter{daycount}{-29}
            \addtocounter{monthcount}{1}
            \addtocounter{yearcount}{1}
        }{}
    }{}
    \ifthenelse{#2>12}
    {
        \setcounter{monthcount}{1}
    }{}
}

\begin{document}
\maketitle

\forloop{masterDayCount}{1}{\value{masterDayCount} < 367}
{
    \addtocounter{daycount}{1}
    \addtocounter{dispdaycount}{1}
    \ifthenelse{\thedispdaycount<7}{\pagebreak}{}   
    \ifthenelse{\thedispdaycount=7}{\vspace{25mm} \color{Red}}{}
    \ifthenelse{\thedispdaycount>7}{\color{black} \pagebreak \setcounter{dispdaycount}{1}}{}

    \checkdate{\thedaycount}{\themonthcount}

    \Huge{\displayday\thedispdaycount} {\thedaycount\displaymonth\themonthcount} {\theyearcount}
}

\end{document}

This is the source.

  • Your answer seems to be a link to another answer on this site. Correct me if I'm wrong... – Ruben Aug 2 '15 at 11:40
  • Moreover the OP requested the use of tikz. I think it is not the best recommendation then to say "drop tikz" ;) – Ruben Aug 2 '15 at 11:41
  • The source was a simple calendar and I changed it to Persian by using the Xepersian package. – Ali Torabi Aug 2 '15 at 12:57

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.