
얼마 전에 저는 Filofax(tm) Organizer 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
주 번호도 사용할 수 있도록 확장합니다.)
이제 우리는 실제로 모든 날짜를 반복하는 것이 아니라 월요일(왼쪽)과 목요일(오른쪽)만 확인하려고 합니다.
그래서 마지막으로 수요일(왼쪽)과 일요일(오른쪽)로 시간 이동하여 PGFCalendar를 속입니다.
\ifdate{Monday}{\advance\pgfcalendarcurrentjulian by 2}
{\advance\pgfcalendarcurrentjulian by 3}
\clearpage
우리는 실제로 \ifodd\value{page}
우리가 어디에 있는지 알아내는 데 사용할 수 있지만 여기서는 \ifdate
월요일이 왼쪽을 나타내는 PGFCalendar를 사용하고 있습니다.
각 페이지의 머리 부분과 끝 부분이 대략 동일하므로 루프에서 직접 조판합니다. 우리는 동일한 테스트를 사용하여 왼쪽 또는 오른쪽 헤더 설정을 조판해야 하는지 알아냅니다. (이를 위해 Koma 클래스의 왼쪽 및 오른쪽 표시를 사용할 수도 있었지만 여기서는 이것이 주요 관심사가 아닙니다.)
상단에 3일을 조판한 후(나중에 자세히 설명) 우리는 현재 어느 페이지에 있는지 다시 생각해야 합니다(→ \ifdate{Monday}
).
왼쪽에는 항상 모든 행을 조판합니다. 오른쪽의 경우 일요일을 위해 나누어야 합니다.
미리 만들어진 템플릿 대신 Latex3를 \int_step_function:nnnN
간단한 for(each) 루프로 사용하고 있습니다. 내부에서 안전하게 사용할 수 있습니다 tabularx
. 일요일 쪽은 좀 지저분해요. 몇 가지 조정을 했습니다:
오른쪽에 있는 선 그리드의 간격이 왼쪽과 정확히 동일하도록
\lineEndSundayTop
테이블에서 추가 두께를 무시하도록 하는 라인 공간을 추가한 위치를 살펴보십시오 .\ruleThick
선데이 헤더는
\smash
수직으로 라인을 확대하지 않고 상위 라인까지 슬그머니 올라가지 않도록 에드되면서 낮아집니다(음수 상승).
이제 페이지에서 월요일이나 목요일이 아닌 다른 요일을 가져오기 위해 현재 날짜에 하나, 둘 또는 일요일의 경우 3개를 단순히 추가할 수 없습니다. 왜냐하면 이러한 요일이 다음 달에 포함될 수 있기 때문입니다.
28/29/30/31 이상이면 조금 확인하고 그에 따라 조정할 수 있지만 PGFCalendar가 \PGFCalendarPlus
.
\pgfcalendar
이 매크로는 현재 하루(월요일 또는 목요일)로부터 1일, 2일 또는 1일 후인 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}