From: Wolfgang Schuster <wolfgang.schuster.lists@gmail.com>
To: denis.maier@unibe.ch
Cc: ntg-context@ntg.nl
Subject: [NTG-context] Re: Using structureuservariables before the heading
Date: Thu, 14 Sep 2023 09:55:49 +0200 [thread overview]
Message-ID: <79492d15-0b98-ce1b-a032-b1b0fc54c664@gmail.com> (raw)
In-Reply-To: <ZRAP278MB0495BE64BEBEAD0F65C2FDBF83F1A@ZRAP278MB0495.CHEP278.PROD.OUTLOOK.COM>
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
___________________________________________________________________________________
next prev parent reply other threads:[~2023-09-14 7:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-12 15:47 [NTG-context] " 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 [this message]
[not found] <169454748804.38484.3621451343993224756@cgl.ntg.nl>
2023-09-12 23:09 ` Andres Conrado Montoya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79492d15-0b98-ce1b-a032-b1b0fc54c664@gmail.com \
--to=wolfgang.schuster.lists@gmail.com \
--cc=denis.maier@unibe.ch \
--cc=ntg-context@ntg.nl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).