# Macro defining another macro with spaces in its name

I am trying to use the KOMA-Script command \newcaptionname which takes a macro name as its second argument, but I need spaces in it:

\documentclass{scrartcl}

\newcaptionname{english}{\namewithoutspaces}{With spaces.}
\newcaptionname{english}{\csname name with spaces\endcsname}{Without Spaces} % fails

\usepackage[english]{babel}

\begin{document}
\namewithoutspaces

\csname name with spaces\endcsname
\end{document}


\namewith is properly defined, but obviously, the definition of \csname name with spaces\endcsname fails. I know that this has something to do with expansion, but I think I still do not fully understand this concept (together with all related commands like \expandafter, \noexpand, \edef, ...).

How do I have to modify

\newcaptionname{english}{\csname name with spaces\endcsname}{Without Spaces}


to make it work?

-
why do you need to define a macro with spaces in its name ? (The \csname usage you show does that, but it is hard to see why you need that here? –  David Carlisle May 5 at 14:34
The names I have to use in \newcaptionname come from a list of predefined keywords which in my case contain spaces. –  porst17 May 5 at 14:47
I'd normalise your keywords first:-) –  David Carlisle May 5 at 14:59

It is hard to see why you would need this, but

\documentclass{scrartcl}

\newcaptionname{english}{\namewithoutspaces}{With spaces.}
\def\tmp{\newcaptionname{english}}
\expandafter\tmp\csname name with spaces\endcsname{Without Spaces} % works

\usepackage[english]{babel}

\begin{document}
\namewithoutspaces

\csname name with spaces\endcsname
\end{document}

-