5

I will build the calendar in other langauge (thai) with tikzlibrary. I can change the \pgfcalendarmonthname but the \pgfcalendarweekdayshortname, I can't. The following code has errors.

    \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}
3

This happens because \pgfcalendarcurrentweekday uses zero-based indexing (Monday = 0), but you haven't defined the appropriate case in your \ifcase statement. Use

\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}
4
  • 2
    Monday is day 0? That's really weird. – egreg Sep 11 '13 at 9:13
  • @egreg: Do you mean the zero-based indexing, or the fact that the week starts on Monday? The latter is in line with the ISO specification (and zero-based indexing is not really that weird, is it?) – Jake Sep 11 '13 at 9:22
  • 1
    @Jake So it's the ISO to be weird; not the first instance, IMHO. Sunday should be day 0, if history is taken into account, or day 1, according to other traditions. – egreg Sep 11 '13 at 9:31
  • 2
    @egreg I think that's only respected in US calendars nowadays. If you change the settings of calendars from EU to US, sunday comes first. How do I know? because I have to use Outlook at work. Somebody save me – percusse Sep 11 '13 at 10:30

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.