TikZ 日历中的垂直周列表

TikZ 日历中的垂直周列表

我读过week listPGF/TikZ 手册,但找不到垂直排列一周中各天的示例:

June 1997

M   2  9 16 23 30
T   3 10 17 24
W   4 11 18 25
T   5 12 19 26
F   6 13 20 27
S   7 14 21 28
S 1 8 15 22 29

您能帮我举一个如何创建这样的周列表安排的例子吗?

答案1

这是新的样式vertical week list,它改编自week listTikZ 源代码中的样式。日期标签改编自以下答案:使用 TikZ 库“日历”添加工作日标题

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{calendar}

 \makeatletter
\tikzstyle{week list}=[%
  execute before day scope={%
    \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}
      {%
        % On first of month, except when first date in calendar.
        \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@month@xshift}%
        \pgftransformxshift{\pgf@x}
      }%
    }{}%
  }, 
  execute at begin day scope={%
    \pgfmathsetlength\pgf@y{\tikz@lib@cal@yshift}%
    \pgf@y=\pgfcalendarcurrentweekday\pgf@y%
    \pgftransformyshift{-\pgf@y}%
  },
  execute after day scope={%
    \ifdate{Sunday}{%
      \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@xshift}%
      \pgftransformxshift{\pgf@x}
    }{}%
  }
]

\tikzoption{day headings}{\tikzstyle{day heading}=[#1]}
\tikzstyle{day heading}=[]
\tikzstyle{day letter headings}=[
    execute before day scope={ \ifdate{day of month=1}{%
      \pgfmathsetlength\pgf@ya{\tikz@lib@cal@yshift}%
      \pgfmathsetlength\pgf@xa{\tikz@lib@cal@xshift}%
      \pgftransformxshift{\pgf@xa}
      \foreach \d/\l in {0/M,1/T,2/W,3/T,4/F,5/S,6/S} {
        \pgf@ya=\d\pgf@ya%
        \pgftransformxshift{-\pgf@xa}%
        \pgftransformyshift{-\pgf@ya}%
        \node[every day,day heading, anchor=base]{\l};%
      } 
    }{}%
  }%
]
\makeatother


\begin{document}
\begin{tikzpicture}
\calendar[
    dates=1997-06-01 to 1997-06-last,
    week list,
    day letter headings,
    day heading/.style={gray, xshift=-1em},
    month label above left,
    month text=\%mt \%y0
];
\end{tikzpicture}
\end{document}

答案2

您可以使用\pgftransformyshift将日期向下移动。以下是垂直排列日期的示例样式:

\documentclass[12pt]{article}
\usepackage{tikz}
\usetikzlibrary{calendar}
\tikzstyle{week list downward}=[%
  execute before day scope={%
    \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{%
      \pgftransformxshift{1.5em}}%
    }{}}, 
  execute after day scope={%
    \ifdate{Sunday}{%
      \pgftransformyshift{6em}
      \pgftransformxshift{1.5em}
    }{\pgftransformyshift{-1em}}},
]
\begin{document}
  \tikz\calendar [dates=2012-01-01 to 2012-03-last,week list downward];
\end{document}

weekly calender with vertically arranged days

相关内容