
不久前,我發現了一個非常好的片段,用於創建 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 自備“實用工具”PGF日曆。在我的tikz-ext
包裹中我添加了支援週編號。為此,您實際上需要加載該pgfcalendar-ext
包。
現在,PGFCalendar 有一個主要命令:\pgfcalendar
它確實會循環遍歷該範圍內指定的所有日期,並設定一些巨集(和 TeX 計數)來保存有關當天的資訊。 (並pgfcalendar-ext
擴展它,以便週數也可用。)
現在,我們不想真正循環遍歷每個日期,而只想查看星期一(左側)和星期四(右側)。
所以最後,我們透過時間旅行到星期三(左邊)和星期日(右邊)來欺騙 PFCalendar:
\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}