如何更改 \pgfcalendarweekdayshortname 的标签?

如何更改 \pgfcalendarweekdayshortname 的标签?

我将使用 tikzlibrary 在其他语言(泰语)中创建日历。我可以更改,\pgfcalendarmonthname\pgfcalendarweekdayshortname不能。以下代码有错误。

    \documentclass[a4paper,12pt]{article}
    \usepackage{tikz}
    \usetikzlibrary{calendar}
    \usepackage{translator}
    \begin{document}
    % % % % % % % % %%%%%%%%%%%%%%%%%%%% % % % %This is good.
    \def\pgfcalendarmonthname#1{%
    \translate{\ifcase#1\or JJJ\or FFF\or MMM\or AAA\or
    MAY\or JJU\or JJY\or AAU\or SSS\or OOO\or
    NNN\or DDD\fi}}
    % %%%%%%%%%%%%%%% % % % % % % % % % % % % % %This is errors.
    \def\pgfcalendarweekdayshortname#1{%
    \translate{\ifcase#1\or SU\or MN\or TU\or WE\or
    TH\or FR\or SA\fi}}
    % % % % % % % % % % % % % % % % % % % % % % % % % % % % %  
    \begin{tikzpicture}
    \calendar
    [dates=2013-09-01 to 2013-09-last,
    day list downward,
    month label left,
    day code={\node[name=\pgfcalendarsuggestedname,
    every day]{\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}\
    \tikzdaytext};},
    every month/.append style={anchor=base east,xshift=-2em}];
    \end{tikzpicture}
    \end{document}

答案1

发生这种情况的原因是\pgfcalendarcurrentweekday使用从零开始的索引(星期一 = 0),但您尚未在语句中定义适当的情况\ifcase。使用

\def\pgfcalendarweekdayshortname#1{%
\translate{\ifcase#1 MN\or TU\or WE\or
TH\or FR\or SA \or SU\fi}}


\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\usepackage{translator}
\begin{document}
% % % % % % % % %%%%%%%%%%%%%%%%%%%% % % % %This is good.
\def\pgfcalendarmonthname#1{%
\translate{\ifcase#1\or JJJ\or FFF\or MMM\or AAA\or
MAY\or JJU\or JJY\or AAU\or SSS\or OOO\or
NNN\or DDD\fi}}
% %%%%%%%%%%%%%%% % % % % % % % % % % % % % %This is errors.
\def\pgfcalendarweekdayshortname#1{%
\translate{\ifcase#1 MN\or TU\or WE\or
TH\or FR\or SA \or SU\fi}}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % %  
\begin{tikzpicture}
\calendar
[dates=2013-09-01 to 2013-09-last,
day list downward,
month label left,
day code={\node[name=\pgfcalendarsuggestedname,
every day]{\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}    \tikzdaytext};},
every month/.append style={anchor=base east,xshift=-2em}];
\end{tikzpicture}
\end{document}

相关内容