I'm looking for a way to get the following done
I want to have a command
\setcitation[2]
with the following definition
\def\setcitation#1#2{\lowercase{\expandafter\gdef\csname mycommoncitation#1\endcsname}{#2}}
Essentially, what it does is each time it is called with arguments xXx and yyy, it creates a new command
\mycommoncitationxxx
defined as
\yyy
Now, given an input, xxX, I would like to get yyy out. So what has to happen: convert xxX to lowercase xxx, call \mycommoncitationxxx
I tried doing this as follows:
\newcommand\getcitation[1]{%
\lowercase{\csuse{mycommoncitation#1}}
}
And as follows:
\newcommand\getcitation[1]{\lowercase{\expandafter\gdef\csname mycommoncitation#1\endcsname}}
However niether work.
For the first part (the definition of my setcitation command) I based my solution on build a capitalized CS from a lowercase string and to give it a definition
For the second part, I don't find any help yet.
Complete example, that also shows how I want to use these commands:
\documentclass{article}
\usepackage{etoolbox}
\newcommand{\setcitation}[2]{\lowercase{\csdef{mycommoncitation#1}}{#2}}
\newcommand{\getcitation}[1]{\lowercase{\csuse{mycommoncitation#1}}}
\newcommand{\getcitationifexistsotherwiseinput}[1]{\lowercase{\ifcsdef{mycommoncitation#1}{\getcitation{#1}}{#1}}}
\begin{document}
\setcitation{Foo}{Bar}
\getcitation{Foo}
\mycommoncitationfoo
\getcitationifexistsotherwiseinput{Foo} %My expectation: Bar
\getcitationifexistsotherwiseinput{foo} %my expectation: Bar
\getcitationifexistsotherwiseinput{boo} %my expectation: boo
%Now I want a command that returns
% \getcitation{FOO}
\cite{\getcitation{foo}} %my expectaiton: "undefined citation Bar"
\end{document}
here, in the line \cite{...} things start to go wrong.
lowercase
is not expandable so does not work inside\cite
if you don't mind enumerating all the letters (eg if you only allow a-z, not accented letters) then it is possible to write an expandable version. Or simpler use a modified command say\lccite
that applies lowercase then \cite`\cite{something,\getcitation{somethingelse}}
, SO I'ld basically ahve to patch the entire cite command...