summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorLuke Hsiao <lwhsiao@stanford.edu>2018-08-19 11:14:27 -0700
committerLuke Hsiao <lwhsiao@stanford.edu>2018-08-19 11:14:27 -0700
commita9cf7fc5b0d98678516ee5570d6a2ff251916e31 (patch)
treee322abdbbd800ee8e3459ca5b4ae002363d621ef
parent4c123b1714131b2b4465316660e1897b09a69a95 (diff)
downloadlatex-cal-a9cf7fc5b0d98678516ee5570d6a2ff251916e31.tar.gz
latex-cal-a9cf7fc5b0d98678516ee5570d6a2ff251916e31.tar.zst
latex-cal-a9cf7fc5b0d98678516ee5570d6a2ff251916e31.zip
Switch to Sunday-first
-rw-r--r--pa2cal.tex139
1 files changed, 111 insertions, 28 deletions
diff --git a/pa2cal.tex b/pa2cal.tex
index 60495a5..81a0720 100644
--- a/pa2cal.tex
+++ b/pa2cal.tex
@@ -1,41 +1,124 @@
\documentclass{article}
\usepackage{tikz}
+\usetikzlibrary{calendar}
\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\usepackage[letterpaper,margin=0.3in]{geometry}
-\usetikzlibrary{calendar}
-
-\renewcommand{\rmdefault}{cmss}
+\usepackage{verbatim}
\begin{document}
+ \title{\vspace{-1cm}Palo Alto 2nd Ward Year-at-a-Glance\vspace{-1cm}}
+ \date{}
+ \author{}
+
+ \maketitle
+ \thispagestyle{empty} % Remove page numbers and headers
+ \makeatletter
-\title{\vspace{-1cm}Palo Alto 2nd Ward Year-at-a-Glance\vspace{-1cm}}
-\date{}
-\author{}
-
-\maketitle
-\thispagestyle{empty} % Remove page numbers and headers
-
-\begin{minipage}{0.3\linewidth}
-\begin{tikzpicture}
- \small\sffamily
- \colorlet{darkgreen}{green!50!black}
- \calendar[
- dates=\year-01-01 to \year-12-last,
- week list,
- month label left,
- month yshift=0pt,
- month text={\textit{\%m. \%y0}}
+ % This way you can define your own conditions, for example, you
+ % could make something as `full moon', `even week', `odd week',
+ % et cetera. In principle. The math in TeX could be hard.
+ \pgfkeys{/pgf/calendar/start of year/.code={%
+ \ifnum\pgfcalendarifdateday=1\relax%
+ \ifnum\pgfcalendarifdatemonth=1\relax\pgfcalendarmatchestrue\fi%
+ \fi%
+ }}%
+
+ % Define our own style
+ \tikzstyle{week list sunday}=[
+ % Note that we cannot extend from week list,
+ % the execute before day scope is cumulative
+ execute before day scope={%
+ \ifdate{day of month=1}{\ifdate{equals=\pgfcalendarbeginiso}{}{
+ % On first of month, except when first date in calendar.
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@month@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }}{}%
+ },
+ execute at begin day scope={%
+ % Because for TikZ Monday is 0 and Sunday is 6,
+ % we can't directly use \pgfcalendercurrentweekday,
+ % but instead we define \c@pgf@counta (basically) as:
+ % (\pgfcalendercurrentweekday + 1) % 7
+ \pgfmathsetlength\pgf@x{\tikz@lib@cal@xshift}%
+ \ifnum\pgfcalendarcurrentweekday=6
+ \c@pgf@counta=0
+ \else
+ \c@pgf@counta=\pgfcalendarcurrentweekday
+ \advance\c@pgf@counta by 1
+ \fi
+ \pgf@x=\c@pgf@counta\pgf@x
+ % Shift to the right position for the day.
+ \pgftransformxshift{\pgf@x}
+ },
+ execute after day scope={
+ % Week is done, shift to the next line.
+ \ifdate{Saturday}{
+ \pgfmathsetlength{\pgf@y}{\tikz@lib@cal@yshift}%
+ \pgftransformyshift{-\pgf@y}
+ }{}%
+ },
+ % This should be defined, glancing from the source code.
+ tikz@lib@cal@width=7
]
- if (Sunday) [blue!80];
-\end{tikzpicture}
-\end{minipage}
-\begin{minipage}{0.6\linewidth}
-\end{minipage}
+ % New style for drawing the year, it is always drawn
+ % for January
+ \tikzstyle{year label left}=[
+ execute before day scope={
+ \ifdate{start of year}{
+ \drawyear
+ }{}
+ },
+ % Right align
+ every year/.append style={
+ anchor=east,
+ }
+ ]
+
+ % Style to force giving a month a year label.
+ \tikzset{draw year/.style={
+ execute before day scope={
+ \ifdate{day of month=1}{\drawyear}{}
+ }
+ }}
+
+ % This actually draws the year.
+ \newcommand{\drawyear}{
+ \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@xshift}%
+ \pgftransformxshift{-\pgf@x}
+ % \tikzyearcode is defined by default
+ \tikzyearcode
+ \pgfmathsetlength{\pgf@x}{\tikz@lib@cal@xshift}%
+ \pgftransformxshift{\pgf@x}
+ }
+
+ \makeatother
-\begin{center}
-Find the full calendar at \url{https://www.lds.org/church-calendar/}
-\end{center}
+\begin{minipage}{0.28\linewidth}
+ % The actual calendar is now rather easy:
+ \begin{tikzpicture}[every calendar/.style={
+ month label left,
+ month text={\textit{\%m. \%y0}},
+ month yshift=0pt,
+ % year label left,
+ % every year/.append style={font=\Large\sffamily\bfseries,
+ % green!50!black},
+ if={(Sunday) [blue!70]},
+ week list sunday,
+ }]\small
+ \matrix[column sep=0em, row sep=0em] {
+ \calendar[dates=2019-01-01 to 2019-12-last]; \\
+ };
+ \end{tikzpicture}
+
+\end{minipage}
+\begin{minipage}[t]{0.65\linewidth}
+\subsection*{Key Dates}
+what about stuff?
+\end{minipage}
+ \begin{center}
+ Find the full calendar at \url{https://www.lds.org/church-calendar/}
+ \end{center}
\end{document}