I'm trying to define a custom section command that will also define a corresponding label after a bit of preparsing. Specifically, I want the command to define a section with the given name, and then define a label with the name lower-cased and having spaces replaced with dashes.
So far I've come up with the following:
\NewDocumentCommand\startSection{m}
{
\section{#1}\label{\lowercase{\StrSubstitute{#1}{ }{-}}}
}
Which uses the xstring
and xparse
packages, but this yields an error:
! Argument of \@sect has an extra }.
After a bit of playing around I would get:
! Missing \endcsname inserted
around the \lowercase
command.
I seem to be missing some essential knowledge about how labels work, so does anyone have a good suggestion?