## LaTeX forum ⇒ Calendars and Miscellaneous ⇒ bottom line sometimes not drawn

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

### bottom line sometimes not drawn

Hello,

I'm seeing a little bug in the weekly timetable template. The bottom line of the calendar is not always drawn. For example, this works as expected:

    \begin{calendar}{\hsize}     \day{}{}     \day{}{hello, world}     \day{}{}     \day{}{}     \day{}{}     \finishCalendar     \end{calendar}

But this omits the bottom line:

    \begin{calendar}{\hsize}     \day{}{}     \day{}{hello, world}     \day{}{}     \day{}{}     \day{}{}     \day{}{}     \finishCalendar

\end{calendar}

jjfoersch
Last edited by templateuser on Thu Mar 19, 2015 1:59 pm, edited 1 time in total.

Tags:

Vel
Site Moderator
Posts: 455
Joined: Fri Jun 29, 2012 1:20 am
Hi,

It looks like you're right. Odd that the bug only appears with 6 \day{}{} commands and not if there are more or less. I've had a quick look at the calendar.sty file and I don't immediately see what is causing the bug, the line \ifnum\@currentdaynum=6 &\\\hline\else should be printing the bottom line when there are 6 \day{}{} commands.

Ultimately I don't think it matters much since this template has 7 separate sections for each day of the week with a \day{}{} command in each one. Days that are not filled with anything should be left empty, as the Saturday has been in the template.

If you figure out what's causing the bug do let me know and I'll update the template!

Cheers,
Vel
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com

templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm
At the point when \finishCalendar gets called, the value of \@currentdaynum will 1 if \day was not called at all, and 2 through 8 if it was. If the last \day was in the 7th column, the value of the counter is 8, and \day has drawn the \hline. If the last \day was in the 6th column or lower, the value of the counter is (column+1), and \finishCalendar needs to draw that line. \finishCalendar just needs an ifnum branch to handle \@currentdaynum=7. Here is a patch:

http://retroj.net/scratch/handle-day-6-last-day.patch

ftr, I'm using calendar.sty for multi-row calendars, so it's nice not to have to make sure I have an evenly-divisible-by-7 number of \day entries.

jjfoersch

Vel
Site Moderator
Posts: 455
Joined: Fri Jun 29, 2012 1:20 am
Excellent, thanks for the fix! I've updated the template on the site to get rid of this bug.
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com

templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm
Ah, this is not the "official" copy of calendar.sty, is it? Just realised that. It looks like there is at least one newer version of calendar.sty out since 2010, and I would not be surprised if this bug was already fixed in it. I think that if latextemplates is going to distribute a modified old version of calendar.sty, it would be best to make that clear in the file's version information. Either that, or just use the newest version on latextemplates, and check that the bug has been fixed.

I wrote to the author of calendar.sty to report this bug and find out if it has already been fixed in the newer version. Will report back here if I learn the answer.

jjfoersch

Vel
Site Moderator
Posts: 455
Joined: Fri Jun 29, 2012 1:20 am
Indeed, it appears to be an older version. The newer version doesn't work with this template at all and seems to be very different. I tend not to touch the style files since the site is more about the templates rather than the backend of what's making them work (plus it would mean a lot more work for me to process the style files . I could put in a short comment saying that this has been modified to fix a bug from the original version 3.1.
Founder and administrator of LaTeXTemplates.com and LaTeXTypesetting.com

templateuser
Posts: 679
Joined: Tue Mar 03, 2015 4:01 pm
That sounds good.

jjfoersch