1

I'm trying to automate report generation in czech. In english, there is no problem using solution from this thread. Same behaviour is for \monthname command from datetime package.

The problem is, that in czech the \DTMmonthname returns the month name in genitive case which is usually different from the nominative case.

Is datetime2 package capable of returning different cases (in czech there are 7 different cases, in german there are 4 cases) or it holds only one case for each month? Or there is only one way: hardcode \foo[<case>]{<month#>} by myself?

  • Have you tried \DTMMonthname{1}, with a capital M? – Runar Sep 6 '16 at 17:12
  • See the solutions to this question (especially Nicola Talbot's answer): Change month names in \today command – Alenanno Sep 6 '16 at 17:27
  • @RunarTrollet Yes, both capitalised and uncapitalised commands return genitive case. – Crowley Sep 6 '16 at 17:34
  • @Alenanno So the "hardcoding" then? The reason is that the sencences "[written on] January 7, 2016" and "Report for January, 2016" use different cases. – Crowley Sep 6 '16 at 17:40
  • Yeah, I didn't find anything in the manual about cases (in the grammatical sense), so I guess the only solution would be hardcoding. For the various "cases", no pun intended, you could use an optional argument to switch. But you still must add all the variants in the command definition manually. Unless someone thinks of a different solution. – Alenanno Sep 6 '16 at 17:44
2

I don't know any Czech, so this is pure guesswork.

The datetime2-serbian module provides Latin month names and Cyrillic month names with an option to switch between them. The datetime2-usorbian module provides new style month names and old style month names with an option to switch between them. It sounds as though you're looking for a similar function, so I'll use a similar method here to that employed by those language modules. If this isn't correct, please add some examples of usage to your question.

In datetime2-czech-utf8.ldf, replace

\newcommand*{\DTMczechmonthname}[1]{%
  \ifcase#1
  \or
  ledna%
  \or
  února%
  \or
  března%
  \or
  dubna%
  \or
  května%
  \or
  června%
  \or
  července%
  \or
  srpna%
  \or
  září%
  \or
  října%
  \or
  listopadu%
  \or
  prosince%
  \fi
}

with

\newcommand*{\DTMczechgenitivemonthname}[1]{%
  \ifcase#1
  \or
  ledna%
  \or
  února%
  \or
  března%
  \or
  dubna%
  \or
  května%
  \or
  června%
  \or
  července%
  \or
  srpna%
  \or
  září%
  \or
  října%
  \or
  listopadu%
  \or
  prosince%
  \fi
}
\newcommand*{\DTMczechmonthname}{\DTMczechgenitivemonthname}% default

\newcommand*{\DTMczechnominativemonthname}[1]{%
  \ifcase#1
  \or
  nominative version of ledna%
  \or
  nominative version of února%
  \or
  nominative version of března%
  \or
  nominative version of dubna%
  \or
  nominative version of května%
  \or
  nominative version of června%
  \or
  nominative version of července%
  \or
  nominative version of srpna%
  \or
  nominative version of září%
  \or
  nominative version of října%
  \or
  nominative version of listopadu%
  \or
  nominative version of prosince%
  \fi
}

Add similar code for the other cases that are required. Similarly for the first letter upper case \DTMczechMonthname.

Do the same thing in datetime2-czech-ascii.ldf but replace the UTF-8 characters with LaTeX commands. (The -utf8.ldf file is used by XeLaTeX and LuaLaTeX. The -ascii.ldf file is used by LaTeX.)

Then in datetime2-czech.ldf in the block that defines the module options (commands like \DTMdefbool and \DTMdefkey) add the following:

\DTMdefchoicekey{czech}{month}[\val\nr]{genitive,nominative}{%
 \ifcase\nr\relax
  \renewcommand*\DTMczechmonthname{\DTMczechgenitivemonthname}%
  \renewcommand*\DTMczechMonthname{\DTMczechgenitiveMonthname}%
 \or
  \renewcommand*\DTMczechmonthname{\DTMczechnominativemonthname}%
  \renewcommand*\DTMczechMonthname{\DTMczechnominativeMonthname}%
 \fi
}

Similarly add the extra cases that you require.

With these changes, in your document you should be able to switch between the different cases using \DTMlangsetup. For example:

\DTMlangsetup[czech]{month=genitive}

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.