Calendars and MiscellaneousRemove Saturday and Sunday

Calendars, invoices, tables, memos, contracts, dictionaries, code snippets
Post Reply
templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm

Remove Saturday and Sunday

Post by templateuser »

I’d like to remove from my timetable saturday and sunday because they are blank days. How can I do that?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
mathemagician
Posts: 1
Joined: Thu Jan 23, 2020 8:38 pm

Remove Saturday and Sunday

Post by mathemagician »

There are two steps. First, change the calendar.sty file as follows:

%%%%%%%%%%%%%%%%%%%%%
\NeedsTeXFormat{LaTeX2e}

\def\CalendarVersion{3.2}
\def\CalendarVersionDate{2018/09/19}

\ProvidesClass{calendar}[\CalendarVersionDate
LaTeX2e class file `calendar' v\CalendarVersion]

\typeout{'calendar' style \CalendarVersion \CalendarVersionDate.}
\typeout{Created by Evan Sultanik}
\typeout{****** Bugs/comments/suggestions/technicalities to Evan Sultanik -- evan@sultanik.com ******}

\RequirePackage{tabularx}

\def\@CALtrue{1}
\newcount\@currentdaynum
\newcounter{calendardate}
\newcount\StartingDayNumber

\def\dayheader#1#2{
\noindent
\begin{minipage}[t]{0.87\hsize}
\noindent
\raggedright
\textit{#1}
\end{minipage}
\begin{minipage}[t]{0.1\hsize}
\noindent
\raggedleft
\textit{#2}
\end{minipage}
}
\def\activities#1{
\parbox{\hsize}{\vspace*{5pt}\raggedright\scriptsize #1}\smallskip
}

\let\@colbreak=&

\def\printdayname#1{\hfil\textsc{#1}\hfil}

\newcommand{\dayname}[1]{
\ifnum#1=1 Monday\else
\ifnum#1=2 Tuesday\else
\ifnum#1=3 Wednesday\else
\ifnum#1=4 Thursday\else
\ifnum#1=5 Friday\else
%\ifnum#1=6 Friday\else
% \ifnum#1=7 Saturday\else
\PackageError{calendar}{Unrecognized day number: #1!}
\fi\fi\fi\fi\fi%\fi\fi
}

\StartingDayNumber=1
\newenvironment{calendar}[1]{
\newdimen\@calendarwidth
\@calendarwidth=#1
\begingroup
\def\@calendarmode{\@CALtrue}
\def\day##1##2{
\if\@calendarmode\@CALtrue\else\PackageWarning{calendar}{The '\day' macro is expected to be used in the 'calendar' environment!}\fi
\ifnum\@currentdaynum>5\global\@currentdaynum=1\fi
\global\advance\@currentdaynum by 1
%\dayheader{##1}{\thecalendardate}
\def\daysep{\vskip2pt\hrule\vskip4pt}
\def\timesep{\vskip6pt}
\activities{##2}
\addtocounter{calendardate}{1}
\ifnum\@currentdaynum>5\@arraycr\hline\else&\fi
}
\def\finishCalendar{
\ifnum\@currentdaynum=5 \\\hline\else
\ifnum\@currentdaynum=4 &\\\hline\else
\ifnum\@currentdaynum=3 &&\\\hline\else
\ifnum\@currentdaynum=2 &&&\\\hline\else
\ifnum\@currentdaynum=1 &&&&\\\hline
%\ifnum\@currentdaynum=2 &&&&&\\\hline\else
%\ifnum\@currentdaynum=1 &&&&&&\\\hline
\fi\fi\fi\fi\fi%\fi\fi
}
\def\BlankDay{
\if\@calendarmode\@CALtrue\else\PackageWarning{calendar}{The '\calendarday' macro is expected to be used in the 'calendar' environment!}\fi
\ifnum\@currentdaynum>7\global\@currentdaynum=1\fi
\global\advance\@currentdaynum by 1
\addtocounter{calendardate}{1}
\ifnum\@currentdaynum>7\@arraycr\hline\else&\fi
}

\setcounter{calendardate}{1}
\newcount\@currday
\@currday=\StartingDayNumber
\newcount\@numdays
\@numdays=5
\let\@cbreak=&
\tabularx{\@calendarwidth}{|X|X|X|X|X|} \hline
\ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
\ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
\ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
\ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 &
\ifnum\@currday>\@numdays\@currday=1\fi\printdayname{\dayname{\@currday}} \global\advance\@currday by 1 \\ \hline \hline
\@currentdaynum=1
\let\@firstline=\@CALtrue
}{
\endtabularx
\endgroup
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Then, change the .tex file as follows:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Weekly Timetable Calendar
% LaTeX Template
% Version 1.2 (19/9/18)
%
% This template has been downloaded from:
% http://www.LaTeXTemplates.com
%
% Original author:
% Evan Sultanik with modifications by
% Vel (vel@LaTeXTemplates.com)
%
% License:
% CC BY-NC-SA 3.0 (http://creativecommons.org/licenses/by-nc-sa/3.0/)
%
% Important note:
% This template requires the calendar.sty file to be in the same directory as the
% .tex file. The calendar.sty file provides the necessary structure to create the
% calendar.
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------
% PACKAGES AND OTHER DOCUMENT CONFIGURATIONS
%----------------------------------------------------------------------------------------

\documentclass[10pt]{article} % Can also use 11pt for a larger overall font size

\usepackage{calendar} % Use the calendar.sty style

\usepackage[landscape, a4paper, margin=1cm]{geometry} % Page dimensions and margins

\usepackage{palatino} % Use the Palatino font

\begin{document}

\pagestyle{empty} % Disable default headers and footers

\setlength{\parindent}{0pt} % Stop paragraph indentation

\StartingDayNumber=1 % Calendar starting day, default of 1 means Sunday, 2 for Monday, etc

%----------------------------------------------------------------------------------------
% TITLE SECTION
%----------------------------------------------------------------------------------------

\begin{center}
\textsc{\LARGE University Timetable}\\ % Title text
\textsc{\large Semester 1} % Subtitle text
\end{center}

%----------------------------------------------------------------------------------------

\begin{calendar}{\textwidth} % Calendar to be the entire width of the page

%----------------------------------------------------------------------------------------
% FIRST DAY
%----------------------------------------------------------------------------------------

\day{}{
\textbf{9am-5pm} \daysep Work at McDonald's
}

%----------------------------------------------------------------------------------------
% SECOND DAY
%----------------------------------------------------------------------------------------

\day{}{
\textbf{9am-10am} \daysep BIOSCI101 - BLT100 \timesep
\textbf{10am-11am} \daysep BIOSCI 104 - LLT \timesep
%\textbf{11am-12pm} \daysep No Lecture \timesep
\textbf{12pm-1pm} \daysep BIOSCI105 - BLT204 \timesep
%\textbf{1pm-2pm} \daysep No Lecture \timesep
\textbf{2pm-5pm} \daysep BIOSCI101 Laboratory \timesep
%\textbf{3pm-4pm} \daysep BIOSCI101 Laboratory \timesep
%\textbf{4pm-5pm} \daysep BIOSCI101 Laboratory
}

%----------------------------------------------------------------------------------------
% THIRD DAY
%----------------------------------------------------------------------------------------

\day{}{ % Tuesday
\textbf{9am-10am} \daysep BIOSCI101 - BLT100 \timesep
\textbf{10am-11am} \daysep BIOSCI 104 - LLT \timesep
%\textbf{11am-12pm} \daysep No Lecture \timesep
%\textbf{12pm-1pm} \daysep No Lecture \timesep
%\textbf{1pm-2pm} \daysep No Lecture \timesep
\textbf{2pm-3pm} \daysep GEO101 - HSB1 \timesep
%\textbf{3pm-4pm} \daysep No Lecture \timesep
%\textbf{4pm-5pm} \daysep No Lecture
}

%----------------------------------------------------------------------------------------
% FOURTH DAY
%----------------------------------------------------------------------------------------

\day{}{ % Wednesday
%\textbf{9am-10am} \daysep No Lecture \timesep
\textbf{10am-11am} \daysep BIOSCI 104 - LLT \timesep
%\textbf{11am-12pm} \daysep No Lecture \timesep
\textbf{12pm-1pm} \daysep BIOSCI105 - BLT204 \timesep
%\textbf{1pm-2pm} \daysep No Lecture \timesep
\textbf{2pm-3pm} \daysep GEO101 - HSB1 \timesep
%\textbf{3pm-4pm} \daysep No Lecture \timesep
%\textbf{4pm-5pm} \daysep No Lecture
}

%----------------------------------------------------------------------------------------
% FIFTH DAY
%----------------------------------------------------------------------------------------

\day{}{ % Thursday
%\textbf{9am-10am} \daysep No Lecture \timesep
\textbf{10am-11am} \daysep BIOSCI 104 - LLT \timesep
%\textbf{11am-12pm} \daysep No Lecture \timesep
%\textbf{12pm-1pm} \daysep No Lecture \timesep
%\textbf{1pm-2pm} \daysep No Lecture \timesep
\textbf{2pm-3pm} \daysep GEO101 - HSB1 \timesep
%\textbf{3pm-4pm} \daysep No Lecture \timesep
%\textbf{4pm-5pm} \daysep No Lecture
}





\finishCalendar
\end{calendar}
\end{document}
Post Reply