1

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?

3
  • 1
    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? Commented May 5, 2014 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
    Commented May 5, 2014 at 14:47
  • I'd normalise your keywords first:-) Commented May 5, 2014 at 14:59

1 Answer 1

3

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .