Cómo reproducir archivos de calendario en mi organizador filofax

Cómo reproducir archivos de calendario en mi organizador filofax

Hace algún tiempo encontré un fragmento realmente agradable para crear páginas de calendario A5 del organizador Filofax (tm); lamentablemente ya no pude encontrar la fuente original. Posteriormente lo modifiqué y ahora tengo muchas ganas de usarlo.

Sin embargo, no pude crear más de dos páginas consistentes. Sería realmente bueno si pudiera agregar un bucle para poder crear más de una semana a la vez. Quizás un mes, un año o incluso un lapso de tiempo arbitrario.

\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}

Respuesta1

PGF/TikZ viene con la “utilidad”PGFCalendario. Con mi tikz-extpaquete he añadidosoporte para numeración de semanas. Para ello, necesitarás cargar el pgfcalendar-extpaquete.

Ahora, PGFCalendar tiene un comando principal:\pgfcalendar

Recorre todas las fechas especificadas en el rango y configura algunas macros (y un recuento de TeX) que contiene información sobre el día actual. (Y pgfcalendar-extlo amplía para que el número de semana también esté disponible).

Ahora, no queremos recorrer cada fecha, sino solo mirar los lunes (lado izquierdo) y los jueves (lado derecho).

Entonces, al final, engañamos a PGFCalendar viajando en el tiempo al miércoles (lado izquierdo) y al domingo (lado derecho):

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

De hecho, podríamos usar \ifodd\value{page}para averiguar dónde estamos, pero aquí estoy usando PGFCalendar \ifdatedonde el lunes indica el lado izquierdo.

Dado que el encabezado y el pie de cada página son aproximadamente iguales, escribimos esto directamente en el bucle. Usamos la misma prueba para determinar si tenemos que componer la configuración del encabezado izquierdo o derecho. (Probablemente podríamos haber usado las marcas izquierda y derecha de las clases Koma para esto, pero esa no es nuestra principal preocupación aquí).

Después de escribir los tres días en la parte superior (más sobre esto más adelante), nuevamente tenemos que pensar en qué página estamos (→ \ifdate{Monday}).

Para el lado izquierdo simplemente componemos todas las filas para todos los tiempos. Por el lado derecho tenemos que dividirlo para el domingo.

En lugar de sus plantillas prediseñadas, estoy usando el \int_step_function:nnnNbucle for(each) tan simple de Latex3. Se puede utilizar de forma segura dentro de un archivo tabularx. El lado del domingo está un poco desordenado. He hecho algunos ajustes:

  • Observe \lineEndSundayTopdónde agregué un espacio de línea que hará que la tabla ignore el grosor adicional de \ruleThickmodo que la cuadrícula de líneas en el lado derecho tenga el mismo espacio que en el lado izquierdo.

  • El encabezado del domingo se baja (se eleva negativamente) mientras se \smashmodifica para que no se cuele hasta la línea superior sin agrandar la línea verticalmente.


Ahora, no podemos simplemente agregar uno, dos o – para el domingo – tres al día actual para obtener los otros días en la página que no son lunes o jueves porque cada uno de estos días podría estar en el próximo mes.

Podríamos comprobar un poco si estaríamos por encima de 28/29/30/31 y ajustar las cosas en consecuencia, pero dejaré que PGFCalendar haga ese trabajo nuevamente a través de \PGFCalendarPlus.

Esta macro iniciará otro \pgfcalendarciclo de un (1) día, el que es uno, dos o días después del actual (que es un lunes o un jueves). Imprimimos el número del día y el día de la semana y listo.

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}

Producción

ingrese la descripción de la imagen aquí

Es un vídeo.

información relacionada