I'm using the dramatist package to typeset a drama script. Characters are created using the \GCharacter-command. I want to customize that command to have it execute \NewPerson for each new Character created.
To do so, I've looked up the installed dramatist.sty on my system and copied the definition of \GCharacter into my preamble like that:
\renewcommand\GCharacter[3]{
\stepcounter{g\Roman{character}}
\global\@namedef{#3}{{\namefont #2}\xspace}
\global\n@me@ppend@nddef{#3}{\@ppendname}{%
\if@drverse
{\speakstab\speaksfont #2\speaksdel\par\nobreak\addvspace{-\parskip}}
\else
\item[#2\speaksdel]
\fi}
\global\n@me@ppend@nddef{gpersona@\Roman{character}}{%
@\Roman{g\Roman{character}}}{\castfont #1}
}
This is the exact definition from the dramatist.sty-file. However, LaTeX complains: ! You can't use \spacefactor in vertical mode. on the first line I use \GCharacter in. How could this be, as I've changed nothing in comparison to the original definition?
In the following MWE, the error occurs in line 19:
\documentclass[a4paper]{scrartcl}
\usepackage{dramatist}
\usepackage{lipsum}
\renewcommand\GCharacter[3]{
\stepcounter{g\Roman{character}}
\global\@namedef{#3}{{\namefont #2}\xspace}
\global\n@me@ppend@nddef{#3}{\@ppendname}{%
\if@drverse
{\speakstab\speaksfont #2\speaksdel\par\nobreak\addvspace{-\parskip}}
\else
\item[#2\speaksdel]
\fi}
\global\n@me@ppend@nddef{gpersona@\Roman{character}}{%
@\Roman{g\Roman{character}}}{\castfont #1}
%\NewPerson
}
\begin{CharacterGroup}{TeX.SX}
\GCharacter{A Character}{A Character}{character}
\end{CharacterGroup}
\begin{document}
\DramPer
\lipsum[1] % Compilation fails with only \DramPer in document
\end{document}
Without the \renewcommand, everything works fine: 
Any clues on how to fix that error?
\makeatletterbefore the\renewcommandand\makeatotherafter the\renewcommand...such that it reads\makeatletter\renewcommand\GCharacter[3]{...}\makeatother– gernot Mar 09 '17 at 20:09\patchcmdinstead of\renewcommand(but that does not prevent the\makeatletter...\makeatotherpair) – Mar 09 '17 at 20:13@-thing. Sorry about that. @Christian Hupfer: What are the advantages of\patchcmd? – LukeLR Mar 09 '17 at 20:15