我看到了这个问题:使用葡萄牙语的 Tikz 日历作为教学大纲并尝试将其翻译成波斯语(太阳回历)。
下面的示例代码运行良好,但问题是这样的:例如“Dey”(波斯历法的一个月)的第一天等于 12 月 22 日,而下个月(“Bahman”)的第一天等于 1 月 21 日。
我如何定义日历以使这些属性发挥作用?
多谢!
\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}
答案1
很难翻译它们,因为二月可能有 28 天,而十二月有 31 天,很难找到这两者之间的关系。tikz
在这种情况下不要使用。您可以自己添加一些新命令并修改日历。
我曾经需要过类似的东西。我得到的是:
\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}
这是源头。