如何将日历文件循环添加到我的 filofax 管理器中

如何将日历文件循环添加到我的 filofax 管理器中

不久前,我发现了一个非常棒的用于创建 Filofax (tm) 组织器 A5 日历页面的代码片段——遗憾的是,我再也找不到原始来源了。后来我修改了它,现在我期待着使用它。

但是,我无法创建超过两个一致的页面。如果我可以添加一个循环,以便可以一次创建超过一周的内容,那就太好了。也许是一个月、一年,甚至是任意的时间跨度。

\documentclass[%
a5paper,
BCOR=2cm,%  Space for hole puncher
DIV=25,%    Size of textbody
9pt%       Fontsize
]{scrbook}
%
%%%%%%%%%% PACKAGES %%%%%%%%%%
%
\usepackage{tabularx,booktabs,multirow}
%\renewcommand*\familydefault{\sfdefault}
%\usepackage{roboto}
\renewcommand{\familydefault}{\sfdefault}
%
%%%%%%%%%% COUNTER %%%%%%%%%%
%
\newcount\counter
\newcount\startdate
\newcount\starttime
\newcount\stoptime
\newcount\sundaybegin
\newcount\week
%
%%%%%%%%%% CUSTOMISATIONS %%%%%%%%%%
%
%% Month
\renewcommand{\month}{March}
%% Date to start the week with
\startdate=13
%% Morning starttime
\starttime=8
%% Evening time
\stoptime=20
%% Starttime sunday
% Min \starttime+1
% Max \stoptime-2
\sundaybegin=14
%% Weeknumber
\week=11
%% Rule width thick
\newcommand{\rulew}{.15em}
%% Extra space
%\setlength{\extrarowheight}{1pt}
%
%%%%%%%%%% DEFINITIONS %%%%%%%%%%
%
\newcommand{\lendt}{\cmidrule[\rulew](l){1-2}\cmidrule[\rulew](l){3-4}\cmidrule[\rulew](l){5-6}}
\newcommand{\lend}{\cmidrule(l){1-2}\cmidrule(l){3-4}\cmidrule(l){5-6}}
\newcommand{\lsun}{\cmidrule(l){1-2}\cmidrule(l){3-4}}
\newcommand{\lsunt}{\cmidrule(l){1-2}\cmidrule(l){3-4}\cmidrule[\rulew](l){5-6}}
\newcommand{\printday}[2]{{\LARGE \textbf{#1}}\,\, \large \textbf{#2}}
\newcommand{\neutralline}{& & & & &}
\newcommand{\footer}{\centering\rule{5.5cm}{\cmidrulewidth} \raisebox{-0.5ex}{\textbf{Dragosh Christian OTTO}} \rule{5.5cm}{\cmidrulewidth}}
\newcommand{\printmonth}{{\LARGE \textbf{\month}}}
%
%%%%%%%%%% TABLE CONTENT LEFT SIDE %%%%%%%%%%
%
% Correction due to \global\advance
\advance\startdate-6
%
\advance\stoptime1
\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
%
\def\tabledataleft{} \counter=\the\starttime
\loop
    \edef\tabline{\the\counter & & \the\counter & & \the\counter & }
    \expandafter\addto\expandafter\tabledataleft\expandafter{\tabline \\\lend}    
    \expandafter\addto\expandafter\tabledataleft\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledataleft\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledataleft\expandafter{\neutralline \\\lend}
    \advance \counter 2
    \ifnum \counter<\the\stoptime
\repeat 
%
%%%%%%%%%% TABLE CONTENT RIGHT SIDE %%%%%%%%%%
%
\def\tabledatarightupper{} \counter=\the\starttime
\loop
    \edef\tabline{\the\counter &  & \the\counter & & & }
    \expandafter\addto\expandafter\tabledatarightupper\expandafter{\tabline \\\lend}
    \expandafter\addto\expandafter\tabledatarightupper\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledatarightupper\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledatarightupper\expandafter{\neutralline \\\lend}
    \advance \counter 2
    \ifnum \counter<\the\sundaybegin
\repeat 
%
\advance\sundaybegin1
\def\tabledatarightinter{} \counter=\the\sundaybegin
\newcount\sundaystop
\sundaystop=\the\sundaybegin
\advance\sundaystop1
\loop
    \edef\tabline{\the\counter &  & \the\counter & & & }
    %\expandafter\addto\expandafter\tabledatarightinter\expandafter{\neutralline \\\lsun}
    \expandafter\addto\expandafter\tabledatarightinter\expandafter{\neutralline \\\lsun}
    \expandafter\addto\expandafter\tabledatarightinter\expandafter{\neutralline \\\lsun}
    \advance \counter 2
    \ifnum \counter<\the\sundaystop
\repeat
\advance\sundaybegin-1
\advance\sundaystop1
%
\def\tabledatarightlower{} \counter=\the\sundaystop
\loop
    \advance \counter 1
    \edef\tabline{\the\counter &  & \the\counter & & & }
    \expandafter\addto\expandafter\tabledatarightlower\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledatarightlower\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledatarightlower\expandafter{\neutralline \\\lend}
    \expandafter\addto\expandafter\tabledatarightlower\expandafter{\tabline \\\lend}
    \advance \counter 1
    \ifnum \counter<\the\stoptime
\repeat 
\advance\sundaystop-1
%
\begin{document}
%
%% Empty page to start left
\thispagestyle{empty}
\mbox{}
\clearpage
%
\pagestyle{empty}
\enlargethispage{1cm}
%
%%%%%%%%%% LEFT TABLE %%%%%%%%%%
%
\noindent
\begin{tabularx}{\linewidth}{lXlXlX}
    \multicolumn{6}{l}{\printmonth \hfill Week \the\week}\\[.2em]
    \midrule[\rulew]
    \addlinespace[.5em]
    \multicolumn{2}{l}{\printday{\the\startdate}{Monday}} \global\advance\startdate 1\relax &%
    \multicolumn{2}{l}{\printday{\the\startdate}{Tuesday}} \global\advance\startdate 1\relax &%
    \multicolumn{2}{l}{\printday{\the\startdate}{Wednesday}}\global\advance\startdate 1\relax \\[1cm]
     & & & & & \\\lendt
    \tabledataleft
     & & & & & \\[1cm]
     \midrule[\rulew]
\end{tabularx}
%
\vfill
%\footer
%
\clearpage
\enlargethispage{1cm}
% Correction due to \global\advance
\advance\startdate-6
%
%%%%%%%%%% RIGHT TABLE %%%%%%%%%%
%
\noindent
\begin{tabularx}{\linewidth}{lXlXlX}
    \multicolumn{6}{l}{Week \the\week \hfill \printmonth}\\[.2em]\midrule[\rulew]
    \addlinespace[.5em]
    \multicolumn{2}{l}{\printday{\the\startdate}{Thursday}} \global\advance\startdate 1\relax &%
    \multicolumn{2}{l}{\printday{\the\startdate}{Friday}}   \global\advance\startdate 1\relax &%
    \multicolumn{2}{l}{\printday{\the\startdate}{Saturday}} \global\advance\startdate 1\relax \\[1cm]
    & & & & & \\\lendt
    \tabledatarightupper
    %& & & & & \\\lsunt
    \addlinespace[-.15em]
    \the\sundaybegin & & \the\sundaybegin & & \multicolumn{2}{l}{\multirow{4}{*}[1.5em]{\printday{\the\startdate}{Sunday}}}\\\lsun
    \tabledatarightinter
    & & & & & \\\lsun
    \the\sundaystop & & \the\sundaystop & & & \\\lsunt
    \tabledatarightlower
    & & & & & \\\lend
    & & & & & \\\lend
    & & & & & \\\lend
    & & & & & \\[1cm]
    \midrule[\rulew]
\end{tabularx}
%
\vfill
%\footer
\end{document}

答案1

PGF/TikZ 自带“实用功能”PGFCalendar。 和我的tikz-ext我已添加我的包支持周数编号。为此,您实际上需要加载pgfcalendar-ext包。

现在,PGFCalendar 有一个主要命令:\pgfcalendar

它循环遍历范围内指定的所有日期,并设置一些宏(和一个 TeX 计数)来保存有关当前日期的信息。 (并pgfcalendar-ext对其进行扩展,以便周数也可用。)

现在,我们不想真正循环遍历每一个日期,而只想查看星期一(左侧)和星期四(右侧)。

所以最后,我们通过时间旅行到星期三(左侧)和星期日(右侧)来欺骗 PGFCalendar:

\ifdate{Monday}{\advance\pgfcalendarcurrentjulian by 2}
               {\advance\pgfcalendarcurrentjulian by 3}
\clearpage

我们实际上可以用它\ifodd\value{page}来确定我们在哪里,但在这里我使用 PGFCalendar,\ifdate其中星期一表示左侧。

由于每页的页眉和页脚大致相同,我们直接在循环中排版。我们使用相同的测试来确定是否必须排版左侧或右侧页眉设置。(我们可能已经为此使用了 Koma 类的左侧和右侧标记,但这不是我们这里的主要关注点。)

在我们将顶部的三天排版之后(稍后会详细介绍),我们必须再次考虑我们在哪一页(→ \ifdate{Monday})。

对于左侧,我们只需排版所有时间的所有行。对于右侧,我们必须将其拆分为星期日。

我没有使用预先构建的模板,而是使用 Latex3 的\int_step_function:nnnN简单 for(each) 循环。它可以安全地在 内使用tabularx。周日那边有点乱。我做了一些调整:

  • 看一下\lineEndSundayTop我添加了行距的地方,它将使表格忽略额外的厚度,\ruleThick以便右侧的行网格与左侧的行网格间距完全相同。

  • 在编辑时,星期日标题被降低(负升高),\smash以便它不会在没有垂直扩大线条的情况下偷偷溜到上线。


现在,我们不能简单地在当前日期上加一、二或(对于星期日)加三来获取页面上除星期一或星期四之外的其他日期,因为这些日期中的每一天都可能在下个月。

我们可以稍微检查一下是否超过 28/29/30/31,并进行相应的调整,但我只会让 PGFCalendar 通过 再次完成这项工作\PGFCalendarPlus

此宏将启动另一个\pgfcalendar一 (1) 天的循环,即当前日期(即星期一或星期四)后一天、两天或几天的循环。我们将打印日期编号和星期几,就这样。

代码

\documentclass[a5paper, BCOR=2cm, DIV=25, fontsize=9pt]{scrbook}
% https://tex.stackexchange.com/a/651888
\usepackage{pgfcalendar-ext} % loads pgfcalendar and has weeknumbering
\usepackage{tabularx, booktabs, multirow}
\usepackage{xfp}% for \inteval for older TeX distributions
\renewcommand*\familydefault{\sfdefault}

% horizontal lines in tabularx
\newcommand*\lineEndTop      {\cmidrule[\ruleThick](l){1-2}\cmidrule[\ruleThick](l){3-4}\cmidrule[\ruleThick](l){5-6}}
\newcommand*\lineEnd         {\cmidrule            (l){1-2}\cmidrule            (l){3-4}\cmidrule            (l){5-6}}
\newcommand*\lineEndSunday   {\cmidrule            (l){1-2}\cmidrule            (l){3-4}}
\newcommand*\lineEndSundayTop{\cmidrule            (l){1-2}\cmidrule            (l){3-4}\cmidrule[\ruleThick](l){5-6}%
                              \addlinespace[\dimexpr-\ruleThick+\lightrulewidth]}
\newcommand*\printDay        {{\LARGE \textbf{\%d-}}\,\, \large \textbf{\%wt}}
\newcommand*\printDays       {%
  \multicolumn{2}{l}                    {\printDay}  &
  \multicolumn{2}{l}{\PGFcalendarPlus{1}{\printDay}} &
  \multicolumn{2}{l}{\PGFcalendarPlus{2}{\printDay}}}
\newcommand*\printWeekLeft   {{\bfseries\LARGE\%mt} \hfill Week \%n-}
\newcommand*\printWeekRight  {Week \%n-\hfill {\bfseries\LARGE\%mt}}
\newcommand*\timeStart  {8}
\newcommand*\timeEnd   {20}
\newcommand*\timeStep   {2}
\newcommand*\timeSunday{14}
\newcommand*\timeBlockX[2]{%
  #1 & & #1 & & #2 \\ \lineEnd
  & & & & &        \\ \lineEnd \\ \lineEnd \\ \lineEnd}
\newcommand*\timeBlockLeft [1]{\timeBlockX{#1}{#1}}
\newcommand*\timeBlockRight[1]{\timeBlockX{#1}{}}
\newcommand*\blockSunday[3]{% Ugh!
  \inteval{\timeSunday-\timeStep} & &
  \inteval{\timeSunday-\timeStep} & & \\ \lineEnd
  \\ \lineEnd       \\ \lineEnd       \\ \lineEndSundayTop
  \timeSunday & & \timeSunday & & #1  \\ \lineEndSunday
  \\ \lineEndSunday \\ \lineEndSunday}

\newcommand*\PGFcalendarPlus[2]{%
  \pgfcalendar{temp}{\pgfcalendarcurrentyear-\pgfcalendarcurrentmonth-\pgfcalendarcurrentday+#1}
                    {\pgfcalendarcurrentyear-\pgfcalendarcurrentmonth-\pgfcalendarcurrentday+#1}{#2}}

\newcommand*\ruleThick{.15em}

\pagestyle{empty}
\setlength\parindent{0pt}% instead of \noindent
\ExplSyntaxOn \let\FOREACH\int_step_function:nnnN \ExplSyntaxOff
\let\%\pgfcalendarshorthand
%\usepackage[showframe, pass]{geometry}
\begin{document}
\null\clearpage
\pgfcalendar{cal}{2023-03-13}{2023-06-30}{%
  \enlargethispage{1cm}
  \begin{tabularx}{\linewidth}{lXlXlX}
    \multicolumn{6}{l}{\ifdate{Monday}{\printWeekLeft}{\printWeekRight}}\\[.2em]
    \midrule[\ruleThick] \addlinespace[.5em]
    \printDays \\[4em]\lineEndTop
  \ifdate{Monday}{% left page
    \FOREACH{\timeStart}{\timeStep}{\timeEnd}\timeBlockLeft
  }{%
    \FOREACH{\timeStart}{\timeStep}{\inteval{\timeSunday-2*\timeStep}}\timeBlockRight
    \blockSunday{\multicolumn{2}{l}{\PGFcalendarPlus{3}{\smash{\raisebox{-.3em}{\printDay}}}}}{}{}
    \\\lineEndSundayTop
    \FOREACH{\inteval{\timeSunday+\timeStep}}{\timeStep}{\timeEnd}\timeBlockRight
  }%
    \\[1cm]
    \midrule[\ruleThick]
  \end{tabularx}
  \ifdate{Monday}{\advance\pgfcalendarcurrentjulian by 2}
                 {\advance\pgfcalendarcurrentjulian by 3}
  \clearpage
}
\end{document}

输出

在此处输入图片描述

这是一个视频。

相关内容