
Há algum tempo, encontrei um trecho muito bom para criar páginas de calendário A5 do organizador Filofax (tm) - infelizmente não consegui mais encontrar a fonte original. Posteriormente, modifiquei-o e agora estou ansioso para usá-lo.
No entanto, não consegui criar mais de duas páginas consistentes. Seria muito bom se eu pudesse adicionar um loop para poder criar mais de uma semana de cada vez. Talvez um mês, um ano ou até mesmo um período de tempo arbitrário.
\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}
Responder1
PGF/TikZ vem com o “utilitário”PGFCalendário. Com meu tikz-ext
pacote eu adicioneisuporte para numeração de semana. Para isso, você realmente precisará carregar o pgfcalendar-ext
pacote.
Agora, o PGFCalendar tem um comando principal:\pgfcalendar
Ele percorre todas as datas especificadas no intervalo e configura algumas macros (e uma contagem TeX) que contém informações sobre o dia atual. (E pgfcalendar-ext
estende isso para que o número da semana também esteja disponível.)
Agora, não queremos realmente percorrer todas as datas, mas apenas olhar para as segundas-feiras (lado esquerdo) e quinta-feira (lado direito).
Por fim, enganamos o PGFCalendar viajando no tempo para quarta-feira (lado esquerdo) e domingo (lado direito):
\ifdate{Monday}{\advance\pgfcalendarcurrentjulian by 2}
{\advance\pgfcalendarcurrentjulian by 3}
\clearpage
Na verdade, poderíamos apenas \ifodd\value{page}
descobrir onde estamos, mas aqui estou usando o PGFCalendar, \ifdate
onde segunda-feira indica o lado esquerdo.
Como o cabeçalho e o rodapé de cada página são praticamente os mesmos, digitamos isso diretamente no loop. Usamos o mesmo teste para descobrir se precisamos digitar a configuração do cabeçalho esquerdo ou direito. (Provavelmente poderíamos ter usado as marcas esquerda e direita das classes Koma para isso, mas essa não é nossa principal preocupação aqui.)
Depois de digitarmos os três dias no topo (falaremos mais sobre isso depois), novamente temos que pensar em qual página estamos (→ \ifdate{Monday}
).
Para o lado esquerdo, apenas digitamos todas as linhas para todos os tempos. Para o lado direito temos que separar para o domingo.
Em vez de seus modelos pré-construídos, estou usando o \int_step_function:nnnN
loop for(each) simples do Latex3. Ele pode ser usado com segurança dentro de um arquivo tabularx
. O lado de domingo é um pouco confuso. Fiz alguns ajustes:
Dê uma olhada
\lineEndSundayTop
onde adicionei um espaço de linha que fará com que a tabela ignore a espessura extra de\ruleThick
modo que a grade de linhas no lado direito tenha o mesmo espaçamento que no lado esquerdo.O cabeçalho de domingo é abaixado (levantado negativamente) enquanto é
\smash
editado para que não chegue à linha superior sem alargar a linha verticalmente.
Agora, não podemos simplesmente adicionar um, dois ou – para o domingo – três ao dia atual para obter os outros dias na página que não são segunda ou quinta-feira, porque cada um desses dias pode ser no próximo mês.
Poderíamos verificar um pouco se estaríamos acima de 28/29/30/31 e ajustar as coisas de acordo, mas deixarei o PGFCalendar fazer esse trabalho novamente via \PGFCalendarPlus
.
Esta macro iniciará outro \pgfcalendar
loop de um (1) dia, aquele que for um, dois ou dias após o atual (que é segunda ou quinta-feira). Imprimiremos o número do dia e o dia da semana e pronto.
Código
\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}