5

I'm trying to use the calendar package but I've a problem. The \DaysInWeek command doesn't work. I can't delete the Saturday and Sunday columns.

Does anyone have a solution?

Here is my code (I use the template found on latextemplate.com):

\documentclass[]{article}
\usepackage{calendar}

\begin{document}
\pagestyle{empty}
\noindent
\StartingDayNumber=2

\begin{calendar}{\hsize}

\day{}{My appointment}

\day{}{}

\day{}{}

\day{}{}

\day{}{} 

\finishCalendar
\end{calendar}
\end{document}

I also use a calendar.sty found on the same address.

Werner
  • 603,163
Theo_H
  • 110

1 Answers1

3

The calendar package you list is very rigid, and does not provide an easy way to achieve a \DaysInWeek output. By rigid I mean that it assumes a fixed 7-day calendar view. One way of getting around this is to set a regular 7-day calendar, but gobble the last two (weekend) columns using a technique from Easiest way to delete a column?:

enter image description here

\documentclass{article}
% For this example, adjust the margins
\usepackage[margin=1in]{geometry}% http://ctan.org/pkg/geometry
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{calendar}% http://www.latextemplates.com/template/weekly-timetable

\newsavebox{\columngobble}
\newcolumntype{d}{>{\lrbox{\columngobble}}l<{\endlrbox}}
% \patchcmd{<cmd>}{<search>}{<replace>}{<succes>}{<failure>}
\patchcmd{\calendar}{|X|X|X|X|X|X|X|}{|X|X|X|X|Xd@{}d@{}|}{}{}

\begin{document}
\pagestyle{empty}
\noindent
\StartingDayNumber=2

\setlength{\parindent}{0pt}
\begin{calendar}{\linewidth}
  \day{}{My appointment}% Monday
  \day{}{}% Tuesday
  \day{}{}% Wednesday
  \day{}{}% Thursday
  \day{}{}% Friday 
  \day{}{}% Saturday (will be gobbled)
  \day{}{}% Sunday (will be gobbled)
  \day{}{Something}% Monday
  \finishCalendar
\end{calendar}
\end{document}

The above solution creates a new column d (using array's \newcolumntype - loaded by tabularx) and inserts it as the last two columns of the tabularx used inside the calendar environment. Well, technically it replaces the rigid |X|X|X|X|X|X|X| column specification to |X|X|X|X|X|@{}dd@{}|, which gobbles the last two (weekend) columns. You still have to set them in your usage though...

Werner
  • 603,163