5

I'd like to remove the ordinal numbering and month names in termcal but have been unsuccessful so far. The original code, according to the package documentation is:

\newcommand{\calprintdate}{%
\ifnewmonth\framebox{\monthname\ \ordinaldate}%
\else \ordinaldate\fi
}

Which yields dates like "Oct 1st" or "Aug 26th." My goal is to change these to "10/1" and "8/26," respectively. Since I am new to LaTeX, my attempt is a bit embarrassing:

\renewcommand{\calprintdate}{%
    \ifnewmonth\framebox{\c@month\ \c@date}%
    \else \ordinaldate\fi
}

This outputs gibberish like "@month @date," which confuses me, because the documentation does state that \c@month is the month counter (Jan = 1). I also haven't changed \ordinaldate in the \else line, and I don't know what \fi means.

Here's a minimal working example without \renewcommand:

\documentclass[12pt]{article}
\usepackage{termcal}

\begin{document}

\begin{calendar}{8/31/2014}{5}
\setlength{\calboxdepth}{.3in}

% Description of the Week.
\calday[Sun]{\noclassday} % Sunday
\skipday\skipday % Monday, Tuesday
\calday[Wed]{\noclassday} % Wednesday
\skipday\skipday % Thursday, Friday
\calday[Sat]{\noclassday}

\caltext{8/31/2014}{Exam 1}
\caltext{9/7/2014}{Exam 2}

\end{calendar}

\end{document}

Output of MWE

I also don't understand why "Sep 3rd" is printed, if, as according to \calprintdate, only dates for new months should be printed.

  • Can you please add a full minimal working example so that people can see what packages etc you need to get your code to work (but don't add code that is not needed). This makes it much easier for people to help you. In this case it would be useful to have code for producing a (very) short calendar. – Andrew Aug 11 '14 at 12:51
  • @Andrew I added a MWE. Sorry for leaving this out earlier. – SEL Aug 11 '14 at 12:53
5

It turns out that this is very easy: internally termcal uses counters month, date (for day of the month) and year. So to do what you want you only need the following:

\renewcommand{\calprintdate}{%
     \ifnewmonth\framebox{\arabic{month}/\arabic{date}}%
     \else\arabic{date}%
     \fi}

Now your calendar becomes:

enter image description here

I think that this is what you wanted. If you want to always print the month number then instead use:

\renewcommand{\calprintdate}{%
     \ifnewmonth\framebox{\arabic{month}/\arabic{date}}%
     \else\arabic{month}/\arabic{date}%
     \fi}

Finally, if you don't want boxes around the first date in each month you can simplify this to

\renewcommand{\calprintdate}{\arabic{month}/\arabic{date}}

[Edit Aside: Explanation of the "@month @date gibberish":

In LaTeX you create counters using

\newcounter{countername}

Internally this is stored as the TeX counter called \c@countername (here countername can be arbitrary). In code behind the scenes it is sometimes useful to use the \c@countername form but this is rarely necessary for normal mortals. If you do to use \c@countername then you should surround your code with \makeatletter...\makeatother because the @ character is "protected" so that it can't be used in normal commands -- this is why @month etc was printed when you tried this. (For more information about @ search for "category codes" in TeX.) Finally, as above, to print the counter you can use \arabic{countername} to print as a normal number (1, 2, 3, ...), \alph{countername} to print in the sequence a, b, c, `..., and so on. ]

  • Any idea why "9/3" is printed? Or is that possibly controlled by somewhere else in the package (other than \calprintdate)? Thanks! – SEL Aug 11 '14 at 13:03
  • I've copied the termcal syntax so that when you hit a new month the date is printed inside a \framebox, and the number of the month is printed, to highlight this. Is this what you wanted? If you want to always use the format <month>/<day> let me know and I'll edit the solution. – Andrew Aug 11 '14 at 13:07
  • I'd like to always use the format <month>/<day>, thank you. And I think the 9/3 date is in a framebox, because it's the first day of September that is displayed. – SEL Aug 11 '14 at 13:09
  • @Sel I've edited answer to describe more options. – Andrew Aug 11 '14 at 13:18
  • Perfect! Thank you for your comprehensive answer and for explaining category codes. – SEL Aug 11 '14 at 13:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.