ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* [NTG-context] Using structureuservariables before the heading
@ 2023-09-12 15:47 denis.maier
  2023-09-12 15:57 ` [NTG-context] " denis.maier
  2023-09-12 18:41 ` Wolfgang Schuster
  0 siblings, 2 replies; 10+ messages in thread
From: denis.maier @ 2023-09-12 15:47 UTC (permalink / raw)
  To: ntg-context


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

Hi,

is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.

As an aside, I've tried to use the < command > key to provide my own command, but while \define works here (but ignores \blank), \def gives me an error.
Why is that?
How would you add blanks to a user-defined command?

Best,
Denis



\setuphead[chapter][
    before={Before: \structureuservariable{author}\blank},
    beforesection={Beforesection: \structureuservariable{author}\blank},
    insidesection={Insidesection: \structureuservariable{author}\blank},
    after={After: \structureuservariable{author}\blank},
    ]

\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work

\starttext
\macro{1}{2}

\startchapter[title=First][author=First Author]
\input knuth
\stopchapter

\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter

\setuphead[chapter]
    [
    before=,after=,beforesection=,insidesection=,
    command=\myChapterCommand,
    ]

\startchapter[title=Third][author=Third Author]
\input knuth
\stopchapter


\stoptext

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 15:47 [NTG-context] Using structureuservariables before the heading denis.maier
@ 2023-09-12 15:57 ` denis.maier
  2023-09-12 18:41 ` Wolfgang Schuster
  1 sibling, 0 replies; 10+ messages in thread
From: denis.maier @ 2023-09-12 15:57 UTC (permalink / raw)
  To: ntg-context


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

Ok, \starttexdefinition allows blanks, apparently just like setups.
But, it still fails exactly like the version with \def


\setuphead[chapter][
    before={Before: \structureuservariable{author}\blank},
    beforesection={Beforesection: \structureuservariable{author}\blank},
    insidesection={Insidesection: \structureuservariable{author}\blank},
    after={After: \structureuservariable{author}\blank},
    ]

\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work

% \starttexdefinition myChapterCommand #1 #2 % doesn't work either, but at least blanks should work
%   \structureuservariable{author}
%   Test
%   \blank
%   #1\space#2
% \stoptexdefinition


\starttext

\myChapterCommand{1}{asdf}

\startchapter[title=First][author=First Author]
\input knuth
\stopchapter

\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter

\setuphead[chapter]
    [
    before=,after=,beforesection=,insidesection=,
    command=\myChapterCommand,
    ]

\startchapter[title=Third][author={Third Author}]
\input knuth
\stopchapter


\stoptext

Von: denis.maier@unibe.ch <denis.maier@unibe.ch>
Gesendet: Dienstag, 12. September 2023 17:48
An: ntg-context@ntg.nl
Betreff: [NTG-context] Using structureuservariables before the heading

Hi,

is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.

As an aside, I've tried to use the < command > key to provide my own command, but while \define works here (but ignores \blank), \def gives me an error.
Why is that?
How would you add blanks to a user-defined command?

Best,
Denis



\setuphead[chapter][
    before={Before: \structureuservariable{author}\blank},
    beforesection={Beforesection: \structureuservariable{author}\blank},
    insidesection={Insidesection: \structureuservariable{author}\blank},
    after={After: \structureuservariable{author}\blank},
    ]

\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work

\starttext
\macro{1}{2}

\startchapter[title=First][author=First Author]
\input knuth
\stopchapter

\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter

\setuphead[chapter]
    [
    before=,after=,beforesection=,insidesection=,
    command=\myChapterCommand,
    ]

\startchapter[title=Third][author=Third Author]
\input knuth
\stopchapter


\stoptext

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 15:47 [NTG-context] Using structureuservariables before the heading denis.maier
  2023-09-12 15:57 ` [NTG-context] " denis.maier
@ 2023-09-12 18:41 ` Wolfgang Schuster
  2023-09-12 19:24   ` denis.maier
  1 sibling, 1 reply; 10+ messages in thread
From: Wolfgang Schuster @ 2023-09-12 18:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users, denis.maier


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

denis.maier@unibe.ch schrieb am 12.09.2023 um 17:47:
>
> Hi,
>
> is it possible to access a structureuservariable before the heading’s 
> title ?
>
> Using the «before» key does not seem to work.
>

There are ways but not in a general way because you try to access the values
before they are known to ConTeXt. To provide a proper solution you have
to tell what you're trying to achieve.

Wolfgang


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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 18:41 ` Wolfgang Schuster
@ 2023-09-12 19:24   ` denis.maier
  2023-09-12 19:30     ` Wolfgang Schuster
  0 siblings, 1 reply; 10+ messages in thread
From: denis.maier @ 2023-09-12 19:24 UTC (permalink / raw)
  To: wolfgang.schuster.lists, ntg-context


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


Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 20:41
An: mailing list for ConTeXt users <ntg-context@ntg.nl>; Maier, Denis Christian (UB) <denis.maier@unibe.ch>
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 17:47:

Hi,

is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.

There are ways but not in a general way because you try to access the values
before they are known to ConTeXt. To provide a proper solution you have
to tell what you're trying to achieve.

I'm just trying to output the author's name above a chapter heading. Do you need more information?

Denis

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 19:24   ` denis.maier
@ 2023-09-12 19:30     ` Wolfgang Schuster
  2023-09-12 19:38       ` denis.maier
  0 siblings, 1 reply; 10+ messages in thread
From: Wolfgang Schuster @ 2023-09-12 19:30 UTC (permalink / raw)
  To: denis.maier; +Cc: ntg-context


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

denis.maier@unibe.ch schrieb am 12.09.2023 um 21:24:
>
> *Von:*Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
> *Gesendet:* Dienstag, 12. September 2023 20:41
> *An:* mailing list for ConTeXt users <ntg-context@ntg.nl>; Maier, 
> Denis Christian (UB) <denis.maier@unibe.ch>
> *Betreff:* Re: [NTG-context] Using structureuservariables before the 
> heading
>
> denis.maier@unibe.ch <mailto:denis.maier@unibe.ch> schrieb am 
> 12.09.2023 um 17:47:
>
>     Hi,
>
>     is it possible to access a structureuservariable before the
>     heading’s title ?
>
>     Using the «before» key does not seem to work.
>
>
> There are ways but not in a general way because you try to access the 
> values
> before they are known to ConTeXt. To provide a proper solution you have
> to tell what you're trying to achieve.
>
> I’m just trying to output the author’s name above a chapter heading. 
> Do you need more information?
>

You can create a custom header for the chapter page and show the value 
of the author key
which works without problems because the header is added after to the 
finished page
after the value is available.

Another option when the name should appear in the same space as the 
chapter title
is a custom layout for the title.

Wolfgang


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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 19:30     ` Wolfgang Schuster
@ 2023-09-12 19:38       ` denis.maier
  2023-09-12 21:15         ` Wolfgang Schuster
  0 siblings, 1 reply; 10+ messages in thread
From: denis.maier @ 2023-09-12 19:38 UTC (permalink / raw)
  To: wolfgang.schuster.lists; +Cc: ntg-context


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

Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 21:30
An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
Cc: ntg-context@ntg.nl
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 21:24:


Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com><mailto:wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 20:41
An: mailing list for ConTeXt users <ntg-context@ntg.nl><mailto:ntg-context@ntg.nl>; Maier, Denis Christian (UB) <denis.maier@unibe.ch><mailto:denis.maier@unibe.ch>
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 17:47:


Hi,

is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.

There are ways but not in a general way because you try to access the values
before they are known to ConTeXt. To provide a proper solution you have
to tell what you're trying to achieve.

I'm just trying to output the author's name above a chapter heading. Do you need more information?

You can create a custom header for the chapter page and show the value of the author key
which works without problems because the header is added after to the finished page
after the value is available.

Another option when the name should appear in the same space as the chapter title
is a custom layout for the title.
Yes, I've tried that in the original MWE:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\setuphead[chapter][
    before={Before: \structureuservariable{author}\blank},
    beforesection={Beforesection: \structureuservariable{author}\blank},
    insidesection={Insidesection: \structureuservariable{author}\blank},
    after={After: \structureuservariable{author}\blank},
    ]

\def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
\define[2]\myChapterCommand{\structureuservariable{author}\blank #1\space#2}
%\def\myChapterCommand#1#2{\structureuservariable{author}\blank #1\space#2} % does not work

% \starttexdefinition myChapterCommand #1 #2 % doesn't work either, but at least blanks should work
%   \structureuservariable{author}
%   Test
%   \blank
%   #1\space#2
% \stoptexdefinition

\starttext

\myChapterCommand{1}{asdf}

\startchapter[title=First][author=First Author]
\input knuth
\stopchapter

\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter

\setuphead[chapter]
    [
    before=,after=,beforesection=,insidesection=,
    command=\myChapterCommand,
    ]

\startchapter[title=Third][author={Third Author}]
\input knuth
\stopchapter

\stoptext
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Here, I'm getting <Third author> just before <3 Third>. So I guess this goes in the right direction, but \define doesn't allow for blanks etc. \starttexdefinition and \def on the other hand gave me erros.

Denis


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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 19:38       ` denis.maier
@ 2023-09-12 21:15         ` Wolfgang Schuster
  2023-09-12 21:32           ` denis.maier
  0 siblings, 1 reply; 10+ messages in thread
From: Wolfgang Schuster @ 2023-09-12 21:15 UTC (permalink / raw)
  To: denis.maier; +Cc: ntg-context


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

denis.maier@unibe.ch schrieb am 12.09.2023 um 21:38:
>
> *Von:*Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
> *Gesendet:* Dienstag, 12. September 2023 21:30
> *An:* Maier, Denis Christian (UB) <denis.maier@unibe.ch>
> *Cc:* ntg-context@ntg.nl
> *Betreff:* Re: [NTG-context] Using structureuservariables before the 
> heading
>
> denis.maier@unibe.ch <mailto:denis.maier@unibe.ch> schrieb am 
> 12.09.2023 um 21:24:
>
>     *Von:*Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
>     <mailto:wolfgang.schuster.lists@gmail.com>
>     *Gesendet:* Dienstag, 12. September 2023 20:41
>     *An:* mailing list for ConTeXt users <ntg-context@ntg.nl>
>     <mailto:ntg-context@ntg.nl>; Maier, Denis Christian (UB)
>     <denis.maier@unibe.ch> <mailto:denis.maier@unibe.ch>
>     *Betreff:* Re: [NTG-context] Using structureuservariables before
>     the heading
>
>     denis.maier@unibe.ch <mailto:denis.maier@unibe.ch> schrieb am
>     12.09.2023 um 17:47:
>
>
>         Hi,
>
>         is it possible to access a structureuservariable before the
>         heading’s title ?
>
>         Using the «before» key does not seem to work.
>
>
>     There are ways but not in a general way because you try to access
>     the values
>     before they are known to ConTeXt. To provide a proper solution you
>     have
>     to tell what you're trying to achieve.
>
>     I’m just trying to output the author’s name above a chapter
>     heading. Do you need more information?
>
>
> You can create a custom header for the chapter page and show the value 
> of the author key
> which works without problems because the header is added after to the 
> finished page
> after the value is available.
>
> Another option when the name should appear in the same space as the 
> chapter title
> is a custom layout for the title.
>
> Yes, I’ve tried that in the original MWE:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> \setuphead[chapter][
>
>     before={Before: \structureuservariable{author}\blank},
>
>     beforesection={Beforesection: \structureuservariable{author}\blank},
>
>     insidesection={Insidesection: \structureuservariable{author}\blank},
>
>     after={After: \structureuservariable{author}\blank},
>
>     ]
>
> \def\myChapterCommand#1#2{\structureuservariable{author}\space\blank}
>
> \define[2]\myChapterCommand{\structureuservariable{author}\blank 
> #1\space#2}
>
> %\def\myChapterCommand#1#2{\structureuservariable{author}\blank 
> #1\space#2} % does not work
>
> % \starttexdefinition myChapterCommand #1 #2 % doesn't work either, 
> but at least blanks should work
>
> %   \structureuservariable{author}
>
> %   Test
>
> %   \blank
>
> %   #1\space#2
>
> % \stoptexdefinition
>
> \starttext
>
> \myChapterCommand{1}{asdf}
>
> \startchapter[title=First][author=First Author]
>
> \input knuth
>
> \stopchapter
>
> \startchapter[title=Second][author=Second Author]
>
> \input knuth
>
> \stopchapter
>
> \setuphead[chapter]
>
>     [
>
>     before=,after=,beforesection=,insidesection=,
>
>     command=\myChapterCommand,
>
> ]
>
> \startchapter[title=Third][author={Third Author}]
>
> \input knuth
>
> \stopchapter
>
> \stoptext
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> Here, I’m getting «Third author» just before «3 Third». So I guess 
> this goes in the right direction, but \define doesn’t allow for blanks 
> etc. \starttexdefinition and \def on the other hand gave me erros.
>

You need a box to get the author on a separate line.

% \define[2]\ChapterCommand
%   {\vbox
%      {\structureuservariable{author}
%      \blank
%      #1\space#2}}

\starttexdefinition protected ChapterCommand #1#2
   \vbox\bgroup
     \structureuservariable{author}
     \blank
     #1\space#2
   \egroup
\stoptexdefinition

\setuphead
   [chapter]
   [command=\ChapterCommand]

\starttext

\startchapter[title=First][author=First Author]
\input knuth
\stopchapter

\startchapter[title=Second][author=Second Author]
\input knuth
\stopchapter

\startchapter[title=Third][author={Third Author}]
\input knuth
\stopchapter

\stoptext

Wolfgang


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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 21:15         ` Wolfgang Schuster
@ 2023-09-12 21:32           ` denis.maier
  2023-09-14  7:55             ` Wolfgang Schuster
  0 siblings, 1 reply; 10+ messages in thread
From: denis.maier @ 2023-09-12 21:32 UTC (permalink / raw)
  To: wolfgang.schuster.lists; +Cc: ntg-context


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

Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 23:16
An: Maier, Denis Christian (UB) <denis.maier@unibe.ch>
Cc: ntg-context@ntg.nl
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 21:38:

Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com><mailto:wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 21:30
An: Maier, Denis Christian (UB) <denis.maier@unibe.ch><mailto:denis.maier@unibe.ch>
Cc: ntg-context@ntg.nl<mailto:ntg-context@ntg.nl>
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 21:24:



Von: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com><mailto:wolfgang.schuster.lists@gmail.com>
Gesendet: Dienstag, 12. September 2023 20:41
An: mailing list for ConTeXt users <ntg-context@ntg.nl><mailto:ntg-context@ntg.nl>; Maier, Denis Christian (UB) <denis.maier@unibe.ch><mailto:denis.maier@unibe.ch>
Betreff: Re: [NTG-context] Using structureuservariables before the heading

denis.maier@unibe.ch<mailto:denis.maier@unibe.ch> schrieb am 12.09.2023 um 17:47:



Hi,

is it possible to access a structureuservariable before the heading's title ?
Using the <before> key does not seem to work.

There are ways but not in a general way because you try to access the values
before they are known to ConTeXt. To provide a proper solution you have
to tell what you're trying to achieve.

I'm just trying to output the author's name above a chapter heading. Do you need more information?

You can create a custom header for the chapter page and show the value of the author key
which works without problems because the header is added after to the finished page
after the value is available.

Another option when the name should appear in the same space as the chapter title
is a custom layout for the title.
Yes, I've tried that in the original MWE:

...

Here, I'm getting <Third author> just before <3 Third>. So I guess this goes in the right direction, but \define doesn't allow for blanks etc. \starttexdefinition and \def on the other hand gave me erros.

You need a box to get the author on a separate line.

% \define[2]\ChapterCommand
%   {\vbox
%      {\structureuservariable{author}
%      \blank
%      #1\space#2}}

\starttexdefinition protected ChapterCommand #1#2
  \vbox\bgroup
    \structureuservariable{author}
    \blank
    #1\space#2
  \egroup
\stoptexdefinition


Thank you so much, Wolfgang!

Why do you need protected here? I've realized that \protected\def also helps a bit, but, of course, paragraph breaks are ignored there as well...
If just found the following in the lowlevel-macros manual:
<Traditional TEX has three prefixes that can be used with macros: \global, \outer and \long. The last two are no-op's in LuaMetaTEX and if you want to know what they do (did) you can look it up in the TEXbook.>
So, \long is gone, but why is that? Is there a new mechanism that serves the same purpose? Other than using a vbox, I mean...

Best,
Denis

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
  2023-09-12 21:32           ` denis.maier
@ 2023-09-14  7:55             ` Wolfgang Schuster
  0 siblings, 0 replies; 10+ messages in thread
From: Wolfgang Schuster @ 2023-09-14  7:55 UTC (permalink / raw)
  To: denis.maier; +Cc: ntg-context

denis.maier@unibe.ch schrieb am 12.09.2023 um 23:32:

> You need a box to get the author on a separate line.
> 
> % \define[2]\ChapterCommand
> %   {\vbox
> %      {\structureuservariable{author}
> %      \blank
> %      #1\space#2}}
> 
> \starttexdefinition protected ChapterCommand #1#2
>    \vbox\bgroup
>      \structureuservariable{author}
>      \blank
>      #1\space#2
>    \egroup
> \stoptexdefinition
> 
> Thank you so much, Wolfgang!
> 
> Why do you need protected here? I’ve realized that \protected\def also 
> helps a bit, but, of course, paragraph breaks are ignored there as well…

You probably haven't noticed it yet but unlike the other predefined 
layouts for sections you don't have to write "alternative=command" to 
use the layout which is passed to the command key.

To make this work ConTeXt has to check whether the argument of the 
command key is empty or not but this is problematic when you pass 
commands with arguments.

When you try to example below you can see that the first definition of 
\Mycommand fails because \edef\CheckMycommand tries to expand its 
argument which causes problems because \Mycommand tries to read the 
following argument. To solve this problem you can use the \protected 
modifier when you create \Mycommand.

\starttext

\def\Mycommand#1{#1}% fails
%\protected\def\Mycommand#1{#1}% works

\edef\CheckMycommand{\Mycommand}
\ifempty\CheckMycommand
    \tex{Mycommand} is empty
\else
    \tex{Mycommand} has content
\fi

\stoptext


> If just found the following in the lowlevel-macros manual:
> 
> «Traditional TEX has three prefixes that can be used with macros: 
> \global, \outer and \long. The last two are no-op's in LuaMetaTEX and if 
> you want to know what they do (did) you can look it up in the TEXbook.»
> 
> So, \long is gone, but why is that? Is there a new mechanism that serves 
> the same purpose? Other than using a vbox, I mean…

The purpose of the \long modifier is to specify whether the argument of 
a command can or cannot contain multiple paragraph (either by an empty 
line or with \par). This was needed by TeX in the early days where 
memory was limited but not on the current machines.

For a very long time ConTeXt made each command definition long by 
default (i.e. \def\...{...} behaved the same way as \long\def\...{...}) 
and as a result \long was dropped.

\def\CommandA#1{#1}

\long\def\CommandB#1{#1}

\starttext

\CommandA{xxx}% works

\CommandA{xxx

yyy}% fails because you have a empty line in the argument

\CommandA{xxx\par yyy}%fails because you have \par in the argument

\CommandB{xxx\par yyy}% works because \CommandB is \long

\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://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

* [NTG-context] Re: Using structureuservariables before the heading
       [not found] <169454748804.38484.3621451343993224756@cgl.ntg.nl>
@ 2023-09-12 23:09 ` Andres Conrado Montoya
  0 siblings, 0 replies; 10+ messages in thread
From: Andres Conrado Montoya @ 2023-09-12 23:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

You can find some examples in the wiki to do something similar:
https://wiki.contextgarden.net/Generate_Authorlist_from_Head_Content

Also you can use setups instead of macro definitions, and create spaces
with \space, \par, etc: https://wiki.contextgarden.net/Setups

-- 
Andrés Conrado Montoya
Andi Kú
andresconrado@gmail.com
http://sesentaycuatro.com
http://messier87.com
http://chiquitico.org
----------------------------------------
Los fines no justifican los medios, porque la medida verdadera de nuestro
carácter está dada por los medios que estamos dispuestos a utilizar, no por
los fines que proclamamos.
----------------------------------------

“You develop an instant global consciousness, a people orientation, an
intense dissatisfaction with the state of the world, and a compulsion to do
something about it. From out there on the moon, international politics look
so petty. You want to grab a politician by the scruff of the neck and drag
him a quarter of a million miles out and say, ‘Look at that, you son of a
bitch.’” — Apollo 14 astronaut Edgar Mitchell

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

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

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

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : https://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2023-09-14  7:57 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-12 15:47 [NTG-context] Using structureuservariables before the heading denis.maier
2023-09-12 15:57 ` [NTG-context] " denis.maier
2023-09-12 18:41 ` Wolfgang Schuster
2023-09-12 19:24   ` denis.maier
2023-09-12 19:30     ` Wolfgang Schuster
2023-09-12 19:38       ` denis.maier
2023-09-12 21:15         ` Wolfgang Schuster
2023-09-12 21:32           ` denis.maier
2023-09-14  7:55             ` Wolfgang Schuster
     [not found] <169454748804.38484.3621451343993224756@cgl.ntg.nl>
2023-09-12 23:09 ` Andres Conrado Montoya

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).