Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In languages like dutch, the first letter of the names of days and months are not capitalized unless they occur as the first character of a sentence. So I added the following code in the preamble of my latex file to cope with the general rule:

\newcommand*{\dayofweeknameiddutch}[1]{%
\ifcase#1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

Now you can use:

\selectlanguage{dutch}
\dutchformat\formatdate{DAY}{MONTH}{YEAR}

in the document, but you cannot capitalize the first character that comes out of this call, for the cases in which this call comes as the beginning of the sentence. I tried using the mfirstuc and stringstrings package but nothing seems to work since both packages expect an expanded string as their argument.

See the following minimal working example:

\documentclass{minimal}
\usepackage{inputenc}

\usepackage[T1]{fontenc}

\usepackage[dutch]{babel}
\usepackage{datetime}

\newcommand*{\dayofweeknameiddutch}[1]{%
\ifcase#1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

\begin{document}
\noindent In this sentence the format of the date
``\dutchformat\formatdate{1}{1}{2013}'' is displayed correctly
since it occurs in the middle of the sentence. But when I start
a sentence with \verb+\dutchformat\formatdate{1}{1}{2013}+\verb
I want the first character of the expanded string i.e.\
``dinsdag'' to be capitalized like ``Dinsdag''. The commands
\verb+\newdateformat+\verb and \verb+\formatdate+\verb come
from the \texttt{datetime} package.

\end{document}

So this problem boils down to expansion of the of the formatdate call. Any ideas?

share|improve this question
    
Where do the commands \newdateformat and \formatdate come from? –  Harald Hanche-Olsen Oct 18 '13 at 9:46
1  
Could you please post a full example, starting with \documentclass? –  Steven B. Segletes Oct 18 '13 at 10:06

1 Answer 1

up vote 5 down vote accepted

I create two commands \dutchformat and \Dutchformat for the capitalized version.

\documentclass{minimal}
\usepackage{inputenc}

\usepackage[T1]{fontenc}

\usepackage[dutch]{babel}
\usepackage{datetime}

\newdateformat{dutchformat}{%
\dayofweekname{\THEDAY}{\THEMONTH}{\THEYEAR}~\THEDAY~\monthname[\THEMONTH]~\THEYEAR}

\let\SAVEdutchformat\dutchformat

\newcommand*{\dayofweeknameiddutch}[1]{}%

\renewcommand\dutchformat{%
\renewcommand*{\dayofweeknameiddutch}[1]{%
\ifcase##1\relax
\or zondag%
\or maandag%
\or dinsdag%
\or woensdag%
\or donderdag%
\or vrijdag%
\or zaterdag%
\fi}%
\SAVEdutchformat}

\newcommand\Dutchformat{%
\renewcommand*{\dayofweeknameiddutch}[1]{%
\ifcase##1\relax
\or Zondag%
\or Maandag%
\or Dinsdag%
\or Woensdag%
\or Donderdag%
\or Vrijdag%
\or Zaterdag%
\fi}%
\SAVEdutchformat}
\begin{document}
\dutchformat\formatdate{1}{1}{2013}

\Dutchformat\formatdate{1}{1}{2013}
\end{document}

enter image description here

share|improve this answer
    
Tnx, indeed an elegant solution to my problem! –  Pieter Stroobants Oct 18 '13 at 15:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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