Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
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? –  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

1 Answer 1

up vote 3 down vote accepted

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.