ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] setups issue
@ 2025-05-12  3:26 jbf
  2025-05-12 16:12 ` [NTG-context] " Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: jbf @ 2025-05-12  3:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 697 bytes --]

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?

Julian


[-- Attachment #1.2: Type: text/html, Size: 2096 bytes --]

[-- Attachment #2: Type: text/plain, Size: 511 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [NTG-context] Re: setups issue
  2025-05-12  3:26 [NTG-context] setups issue jbf
@ 2025-05-12 16:12 ` Wolfgang Schuster
  2025-05-12 21:22   ` jbf
  0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Schuster @ 2025-05-12 16:12 UTC (permalink / raw)
  To: ntg-context

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

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [NTG-context] Re: setups issue
  2025-05-12 16:12 ` [NTG-context] " Wolfgang Schuster
@ 2025-05-12 21:22   ` jbf
  2025-05-13 18:11     ` Wolfgang Schuster
  0 siblings, 1 reply; 4+ messages in thread
From: jbf @ 2025-05-12 21:22 UTC (permalink / raw)
  To: Wolfgang Schuster, mailing list for ConTeXt users

Thank you for that very clear explanation.

Julian

On 13/5/25 02:12, Wolfgang Schuster wrote:
> The setups environment is a fancy version of \def 
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [NTG-context] Re: setups issue
  2025-05-12 21:22   ` jbf
@ 2025-05-13 18:11     ` Wolfgang Schuster
  0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Schuster @ 2025-05-13 18:11 UTC (permalink / raw)
  To: jbf, mailing list for ConTeXt users

Am 12.05.2025 um 23:22 schrieb jbf:
> Thank you for that very clear explanation.

Below is another \setups feature.

\startsetups strong
   \ifempty{#1}
     \bgroup \tttf
       [empty]
     \egroup
   \else
     \bgroup \bf
       #1
     \egroup
   \fi
\stopsetups

\starttext

word \setup{strong} word

word \setupwithargument{strong}{word} word

\stoptext

Wolfgang

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-05-13 18:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-12  3:26 [NTG-context] setups issue jbf
2025-05-12 16:12 ` [NTG-context] " Wolfgang Schuster
2025-05-12 21:22   ` jbf
2025-05-13 18:11     ` Wolfgang Schuster

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).