
Am 12.05.2025 um 05:26 schrieb jbf:
I have the following command which I am using as part of \setuphead[chapter]:
\define[2]\MyChapterCommand%
{\framed[frame=on,bottomframe=on,leftframe=off,rightframe=off,topframe=off,align=middle]
{\vbox{\headtext{chapter} #1 \blank #2}}}
Together with the rest of the \setuphead[chapter] elements, it functions correctly, as indeed it should
But as soon as I place the full description of the chapter head between a \startsetups.... \stopsetups (since I wanted to create a few different chapter possibilities as setups to choose from), the hashes in the above command cause an error.
The error reads: You meant to type ## instead of # right?..... fatal error...
Why is this?
The setups environment is a fancy version of \def with additional features, e.g. ignoring line endings. When you create an environment with \startsetups A ... \stopsetups the internal structure is \def\xxxA{...} with xxx as internal prefix for the macro name. When you create a command within the argument of another command the # of the argument of the inner command have to be doubled, as indicated in the error message, i.e. \define[1]\Command{... #1 ...} becomes \def\OuterCommand{\define[1]\InnerCommand{... ##1 ...}} Below are two example once with nested definitions and once with a setups environment. %% begin example - nested definitions \def\RedefineStrong{\define[1]\Strong{{\it ##1}}} \define[1]\Strong{{\bf #1}} \starttext word \Strong{word} word \RedefineStrong word \Strong{word} word \stoptext %% end example %% begin example - setups environment \startsetups italic \define[1]\Strong{{\it ##1}} \stopsetups \define[1]\Strong{{\bf #1}} \starttext word \Strong{word} word \setups[italic] word \Strong{word} word \stoptext %% end example Wolfgang