I am working with cleveref in a German document and i need in some cases the genitive of the word given by \cref{}. The problem is, that the German genitive is not equally build for all words, so i need some kind of switch-case. Therefore i want a command \crefgen{}, which works similar to \cref{}, but returns the genitive. I think my code shows pretty well what I am trying to achieve. I am sorry that this example is manly in German, but i did not find a useful English example in reasonable time. Nevertheless, I emphasised the important parts I want to add, so it will be clear, even without understanding German.
\documentclass[ngerman,11pt,a4paper]{scrreprt}
\usepackage{cleveref}
\usepackage{ulem}
\newtheorem{problem}{Problem}
\newtheorem{satz}[problem]{Satz}
\newtheorem{proposition}[problem]{Proposition}
\crefname{problem}{Problem}{Probleme}
\crefname{satz}{Satz}{S{\"a}tze}
\crefname{proposition}{Proposition}{Propositionen}
\newcommand{\crefgen}[1]{
\def\tempStyle{\namecref{#1}}
\def\tempProblem{Problem}
\def\tempSatz{Satz}
\ifx\tempStyle\tempProblem{
\namecref{#1}s \labelcref{#1} % genitive for Problem
}\else{
\ifx\tempStyle\tempSatz{
\namecref{#1}es \labelcref{#1} % genitive for Satz
}\else{
No genitiv defined % error if no genitive defined
}\fi
}\fi
}
\begin{document}
\begin{problem}\label{prob}
Some Text
\end{problem}
\begin{satz}\label{sat}
Some Text
\end{satz}
\begin{proposition}\label{propo}
Some Text
\end{proposition}
\paragraph{What i want:}
Die L{\"o}sung des Problem\uline{s} \ref{prob}.\\
Die Aussage des Satz\uline{es} \ref{sat}.\\
\uline{No genitiv defined} f{\"u}r Propositionen.
\paragraph{How i want to achieve that:}
Die L{\"o}sung des \verb!\crefgen{prob}!.\\
Die Aussage des \verb!\crefgen{sat}!.\\
\verb!\crefgen{propo}! f{\"u}r Propositionen.
\paragraph{How my command looks like:}
Die L{\"o}sung des \crefgen{prob}.\\
Die Aussage des \crefgen{sat}.\\
\crefgen{propo} f{\"u}r Propositionen.
\end{document}


xcrefof thecleverefpackage on github. It can be found here. – moro11 Sep 20 '19 at 14:00