I'm trying to define a command which, upon being called with a certain parameter, 'renews' a different command. In particular, I tried the following (it doesn't work!).
\newcommand{\gap} %initialise \gap to exist
\newcommand{\GAP}{1}{
\renewcommand{\gap}{\hspace{#1 em}} }
My idea was that \GAP{3}
redefines \gap
to \hspace{3em}
, for example.
I've looked at a few TeX.SE questions, in particular this one, but I can't see how to correct this...
Incidentally, removing the space between #1
and em
doesn't work, and putting two #
-s outputs 13 (for \GAP{3}
).
Here's a full MWE.
\documentclass[]{article}
\usepackage{amsmath,amssymb}
\newcommand{\gap}{} %initialise \gap to exist
\newcommand{\GAP}{1}{
\renewcommand{\gap}{\hspace{##1em}} }
\begin{document}
\GAP{3}
\end{document}