From b7a371f60990e50fc6ed89125af120179d84e0e3 Mon Sep 17 00:00:00 2001
From: "Douglas B. Rumbaugh" <doug@douglasrumbaugh.com>
Date: Sun, 11 Jan 2026 12:41:19 -0500
Subject: Fixed centering issues

---
 weekschedule.cls | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

(limited to 'weekschedule.cls')

diff --git a/weekschedule.cls b/weekschedule.cls
index d411537..db9be2e 100644
--- a/weekschedule.cls
+++ b/weekschedule.cls
@@ -158,7 +158,8 @@
     \ifx\@scheduleauthor\empty\else\\[0.2cm]\Large\@scheduleauthor\fi%
     \end{center}
     \vspace{0.05cm}
-
+    
+    \centering
     \begin{tikzpicture}[x=1cm, y=1cm]
         % Calculate dynamic day width based on number of days
         % Reserve 1.5cm for time labels, divide remaining width by day count
@@ -170,6 +171,21 @@
         \pgfmathsetmacro{\padding}{\@padding}
         \pgfmathtruncatemacro{\starthour}{\@starthour}
         \pgfmathtruncatemacro{\endhour}{\@endhour}
+        
+        % Calculate grid width (used later for drawing)
+        \pgfmathsetmacro{\gridwidth}{\@daycount*\daywidth}
+        
+        % Calculate shift to center the grid properly
+        % \centering centers the bounding box, which includes time labels extending left.
+        % The bounding box center is approximately at (-1.5 + gridwidth)/2.
+        % The grid center is at gridwidth/2.
+        % To align grid center with bounding box center (which is at page center), 
+        % shift right by: gridwidth/2 - (-1.5 + gridwidth)/2 = 1.5/2 = 0.75cm
+        \pgfmathsetmacro{\timelabelreserved}{1.5}
+        \pgfmathsetmacro{\xshift}{\timelabelreserved/2}
+        
+        % Shift everything to align grid center with page center
+        \begin{scope}[xshift=\xshift cm]
 
         % Draw column headers (days) - iterate through configured day list
         \setcounter{@daypos}{0}
@@ -226,8 +242,9 @@
         \foreach \evnum in {1,...,\the@numevents} {
             \@drawevent{\evnum}
         }
-
+        \end{scope}
     \end{tikzpicture}
+    \par
 
     \vspace{0.2cm}
 
-- 
cgit v1.2.3

