3

Consider this vertical arrangement for a Tikz calendar.
How can I replace the week days name for its capital letter?

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}

\begin{document}

\begin{tikzpicture}
    \calendar[dates=2021-01-01 to 2021-01-last,
        day list downward, 
        day code={
            \node[anchor = east]{\tikzdaytext};
            \draw node[anchor = west, gray]{\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}};
            },
        execute after day scope={
            \ifdate{Sunday}{\pgftransformyshift{1em}}{}},
        ]
        if(weekend) [shape=coordinate]; %  (1)
\end{tikzpicture}

\end{document}

note: (1) is a trick to ignore weekend days.
MWE capture

2 Answers 2

3

Replace \pgfcalendarweekdayshortname by \myweekday and define the latter in the preamble as

\newcommand\myweekday[1]{\ifcase#1M\or T\or W\or T\or F\or S\or S\fi}

enter image description here

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\newcommand\myweekday[1]{\ifcase#1M\or T\or W\or T\or F\or S\or S\fi}
\begin{document}

\begin{tikzpicture}
    \calendar[dates=2021-01-01 to 2021-01-last,
        day list downward, 
        day code={
            \node[anchor = east]{\tikzdaytext};
            \draw node[anchor = west, gray]{\myweekday{\pgfcalendarcurrentweekday}};
            },
        execute after day scope={
            \ifdate{Sunday}{\pgftransformyshift{1em}}{}},
        ]
        if(weekend) [shape=coordinate]; %  (1)
\end{tikzpicture}

\end{document}
1
  • I prefer this solution because it really allows for a replacement. This is useful, for example, for use with other languages.
    – e_moro
    Sep 18, 2021 at 16:05
4

Using \StrLeft from the xstring package:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\usepackage{xstring}

\begin{document}

\begin{tikzpicture}
    \calendar[dates=2021-01-01 to 2021-01-last,
        day list downward, 
        day code={
            \node[anchor = east]{\tikzdaytext};
            \draw node[anchor = west, gray]{\StrLeft{\pgfcalendarweekdayshortname{\pgfcalendarcurrentweekday}}{1}};
            },
        execute after day scope={
            \ifdate{Sunday}{\pgftransformyshift{1em}}{}},
        ]
        if(weekend) [shape=coordinate]; %  (1)
\end{tikzpicture}

\end{document}

enter image description here

You must log in to answer this question.

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