十二面体日历特定周的颜色

十二面体日历特定周的颜色

我见过这个日历:http://www.texample.net/tikz/examples/feature/paper-folding/ 我想为特定线条(周)添加颜色,但我不知道该怎么做。有什么想法吗?

答案1

为了扩展我的评论,我使用您链接的模板做了一个小例子:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calendar,folding}

\begin{document}
    \sffamily\scriptsize
    \begin{tikzpicture}[transform shape,
        every calendar/.style={
            at={(-8ex,4ex)},
            week list,
            month label above centered, 
            month text=\bfseries\textcolor{red}{\%mt} \%y0,
            if={(Sunday) [black!50]}
        }]
    \calendar [dates=\the\year-01-01 to \the\year-01-last]
    if (between=2013-01-07 and 2013-01-13)[red];
    \end{tikzpicture}
\end{document}

答案2

我的方法是使用星期日(延长和移位)来为规则着色,因为即使第一周也有星期日。通过更改这些节点的宽度并为其着色(不透明度使得其他日子仍然可读),人们可以将所有星期都变成彩色,尽管最后一周

然后我引入了一些变量来获得不同的颜色,这些变量在每个星期日(以及每个月初使用etoolbox和)设置style/.code,因此我的解决方案是

\documentclass{article}
% Folding + calendar example from the PGF manual.
%
% Author: Till Tantau
\usepackage{tikz,etoolbox}
\usetikzlibrary{calendar,folding}
\usepackage[ngerman]{babel}
\usepackage{verbatim}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{5pt}%
%%%>

\begin{comment}
:Title: Foldable dodecahedron with Calendar
:Tags: Calendars; Manual
:Author: Till Tantau

An example of the folding library and the folding library, straight from
the manual.
\end{comment}

\newbool{firstweek}
\setbool{firstweek}{true}
\newbool{evenweek}
\setbool{evenweek}{true}
\begin{document}
    \tikzset{weekstyle/.style={nodes={minimum width=10em,text width=10em,minimum height=1\baselineskip, fill=blak,opacity=.2,text opacity=1,align=right}}}
    \tikzset{checkweekstyle/.code={
        \ifbool{firstweek}
        {
            \global\setbool{firstweek}{false}
            \tikzset{weekstyle/.style={nodes={minimum width=10em,text width=10em,minimum height=1\baselineskip, fill=black,opacity=.2,text opacity=1,align=right}}}
        }{
            \ifbool{evenweek}
            {
                \global\setbool{evenweek}{false}
                \tikzset{weekstyle/.style={nodes={minimum width=10em,text width=10em,minimum height=1\baselineskip, fill=black,opacity=.1,text opacity=1,align=right}}}
            }{
                \global\setbool{evenweek}{true}
                \tikzset{weekstyle/.style={nodes={minimum width=10em,text width=10em,minimum height=0.9\baselineskip, fill=white,opacity=.2,text opacity=1,align=right}}}
            }
        }
        }}
   \sffamily\scriptsize
    \begin{tikzpicture}[transform shape,
        every calendar/.style={
            at={(-8ex,4ex)},
            week list,
            month label above centered, 
            month text=\bfseries\textcolor{blue}{\%mt} \%y0,
            if={(Sunday) [black!50,checkweekstyle,weekstyle]}
        }]
    \tikzset{init/.code={\global\setbool{firstweek}{true}\global\setbool{evenweek}{true}}}
    \tikzfoldingdodecahedron[
        folding line length=2.5cm,
        face 1={ \calendar [init, dates=\the\year-01-01 to \the\year-01-last];},
        face 2={ \calendar [init, dates=\the\year-02-01 to \the\year-02-last];},
        face 3={ \calendar [init, dates=\the\year-03-01 to \the\year-03-last];},
        face 4={ \calendar [init, dates=\the\year-04-01 to \the\year-04-last];},
        face 5={ \calendar [init, dates=\the\year-05-01 to \the\year-05-last];},
        face 6={ \calendar [init, dates=\the\year-06-01 to \the\year-06-last];},
        face 7={ \calendar [init, dates=\the\year-07-01 to \the\year-07-last];},
        face 8={ \calendar [init, dates=\the\year-08-01 to \the\year-08-last];},
        face 9={ \calendar [init, dates=\the\year-09-01 to \the\year-09-last];},
        face 10={\calendar [init, dates=\the\year-10-01 to \the\year-10-last];},
        face 11={\calendar [init, dates=\the\year-11-01 to \the\year-11-last];},
        face 12={\calendar [init, dates=\the\year-12-01 to \the\year-12-last];}
    ];
    \end{tikzpicture}
\end{document}

缺点

最后一行有时没有颜色,因为一个月内没有星期日(大多数情况下)。

因此,一个改变是引入月份的背景颜色(因此也是第一周),并使用星期一节点从第二个节点开始为行着色。

最后,第二周(奇数周)应该是白色的,因为第五周没有颜色,因此交替时,第三周也不应该有颜色。

这是结果图

在此处输入图片描述

相关内容