5

I'm using both datetime and termcal together in a document, but this seems to cause an error.

\documentclass[12pt,letterpaper]{article}
\usepackage{datetime,termcal}
\begin{document}
\begin{calendar}{6/1/15}{2}
\renewcommand{\calprintdate}{\monthname. \thedate}
\calday[Monday]{\classday}% Monday
\skipday% Tuesday
\calday[Wednesday]{\classday}%Wednesday
\skipday% Thursday
\skipday % Friday
\skipday\skipday% Weekend
\end{calendar}
\end{document}

Here's the error message from the console:

/usr/local/texlive/2014/texmf-dist/tex/latex/termcal/termcal.sty:135: LaTeX Error: Command \monthname already defined.
           Or name \end... illegal, see p.192 of the manual.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
...                                              

l.135         \or Nov\or Dec\fi}
  • Yes, they conflict because they each define a command called \monthname and I personally have not idea how to make these two packages load together. Perhaps one of the wizards will have a possible solution. – R. Schumacher May 26 '15 at 0:57
  • I checked the documentation for etoolbox and I think you could use this to patch either datetime or termcal to prevent the conflict. However, I have never used this package. I would recommend you draft a new question asking how to use etoolbox to patch one of those packages to eliminate the conflict. And then just delete this question. – R. Schumacher May 26 '15 at 2:03
  • You can \let\monthname\relax or use etoolbox's \undef. Not sure which package has the command you want to keep and which you want to \relax, though. (There may also be other unexpected consequences in a complex document.) – jon May 26 '15 at 2:30
3

The datetime package has now been replaced with datetime2. One of the reasons for replacing the package with a new one (rather than simply modifying the old one) was to avoid these types of conflicts by ensuring that most of the commands have a prefix. (If I'd simply updated datetime all the old commands, such as \monthname, would have had to be retained for backward compatibility and the problem would still remain.)

The base datetime2 package only has numerical date styles, so you can do:

\documentclass[12pt,letterpaper]{article}
\usepackage{datetime2,termcal}
\begin{document}
\begin{calendar}{6/1/15}{2}
\renewcommand{\calprintdate}{\monthname. \thedate}
\calday[Monday]{\classday}% Monday
\skipday% Tuesday
\calday[Wednesday]{\classday}%Wednesday
\skipday% Thursday
\skipday % Friday
\skipday\skipday% Weekend
\end{calendar}
\end{document}

This will just use termcal's definition of \monthname. Language dependent dates are in the datetime2 language modules. For example, for English, you'd need to additionally install datetime2-english. This will be loaded by datetime2 if the language is detected. Each language module comes with its own month name command. For the English language module the command is called \DTMenglishmonthname. This takes one compulsory argument, which is the month number. So if you prefer to use this instead of termcal's \monthname you can do:

\documentclass[12pt,letterpaper,english]{article}
\usepackage{datetime2,termcal}
\begin{document}
\begin{calendar}{6/1/15}{2}
\renewcommand{\calprintdate}{\DTMenglishmonthname{\value{month}}. \thedate}
\calday[Monday]{\classday}% Monday
\skipday% Tuesday
\calday[Wednesday]{\classday}%Wednesday
\skipday% Thursday
\skipday % Friday
\skipday\skipday% Weekend
\end{calendar}
\end{document}

If you get an undefined control sequence for \DTMenglishmonthname, then that probably means that the language module isn't installed. (There should be a warning about it in the log file.

3

Let me start by writing that datetime is obsolete and probably it's not a good idea to use it. The author says it is being replaced by datetime2. I'm not sure if the latter has the same conflicts.

The two packages (datetime and termcal) do indeed conflict, as mentioned in the comments. The solution that Jon suggests in his comment resolves the conflict but does not produce the correct result (you won't see June's calendar, unless it's actually June when you run LaTeX). The reason is that the two macros are semantically incompatible:

  1. The \monthname defined in datetime takes an optional argument, which is the number of the month (1-12). Its value defaults to the current month.

  2. The \monthname defined in termcal takes no argument. It expands to the name of the month whose number is contained in the \c@month variable.

I assume that the desired behaviour is to make termcal use \monthname as defined in datetime. Here's what I propose:

\documentclass[12pt,letterpaper]{article}

\usepackage{termcal}
%% forget about termcal's version
\let\monthname\relax

\usepackage{datetime}
%% rename datetime's version
\let\dtmonthname\monthname

%% and make a new version that behaves as termcal's but uses datetime's...
\makeatletter
\renewcommand\monthname{\dtmonthname[\c@month]}
\makeatother

\begin{document}
\begin{calendar}{6/1/15}{2}
\renewcommand{\calprintdate}{\monthname. \thedate}
\calday[Monday]{\classday}% Monday
\skipday% Tuesday
\calday[Wednesday]{\classday}%Wednesday
\skipday% Thursday
\skipday % Friday
\skipday\skipday% Weekend
\end{calendar}
\end{document}

Here's the result:

result

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.