Hi, LuaTeX team,
I'm writing this email to append the complete steps about how I found the
problem mentioned in the forwarded email.
I want to take a number after a macro and use the content after number.
For example, scale the baseline skip and then output the later content:
\begingroup\endlinechar=-1
\newcount\scalecount
\long\gdef\scaleBase{
\afterassignment\scaleBaseWithFactor
\scalecount=
}
\long\gdef\scaleBaseWithFactor#1{{
\divide\baselineskip by 1000
\multiply\baselineskip by \scalecount
#1
}}
\endgroup
\scaleBase1200
{line1\par line2\par line3}
\bye
This will show a much baseline skip between line1 and line2.
I want to take \magstep values as parameter. But \scaleBase\magstep1{line1\par
line2\par line3} did not work as expected.
I found this is because \magstep add a \relax at the end to split itself from
possible next number:
$ luatex
This is LuaTeX, Version 1.22.0 (TeX Live 2026/dev/Arch Linux)
restricted system commands enabled.
**\relax
*\show\magstep
> \magstep=macro:
#1->\ifcase #1 \@m \or 1200\or 1440\or 1728\or 2074\or 2488\fi \relax .
<*> \show\magstep
?
So I add more 1 macro to strip \relax:
\begingroup\endlinechar=-1
\newcount\scalecount
\long\gdef\scaleBase#1{
%>>>>>>>>>
\ifx#1\magstep
\afterassignment\scaleBaseWithmagstep
\else
%<<<<<<<<<
\afterassignment\scaleBaseWithFactor
\fi%<<<<<<<<<
\scalecount=#1
}
%>>>>>>>>>
\long\gdef\scaleBaseWithmagstep#1\relax#2{
\scaleBaseWithFactor{#2}
}
%<<<<<<<<<
\long\gdef\scaleBaseWithFactor#1{{
\divide\baselineskip by 1000
\multiply\baselineskip by \scalecount
#1
}}
\endgroup
\scaleBase\magstep1%<<<<<<<<<
{line1\par line2\par line3}
\bye
This works fine for \magstep except \magstep0.
\scaleBase\magstep0 make a warning:
(\end occurred inside a group at level 1)
in the log.
In other more complecated cases, it report (\end occurred when \ifcase but not
inside a group. So I checked the place sending \magstep.
I checked this by \show#1 in \scaleBaseWithmagstep:
\begingroup\endlinechar=-1
\newcount\scalecount
\long\gdef\scaleBase#1{
\ifx#1\magstep
\afterassignment\scaleBaseWithmagstep
\else
\afterassignment\scaleBaseWithFactor
\fi
\scalecount=#1
}
\long\gdef\scaleBaseWithmagstep#1\relax#2{
\show#1%<<<<<<<<<
\scaleBaseWithFactor{#2}
}
\long\gdef\scaleBaseWithFactor#1{{
\divide\baselineskip by 1000
\multiply\baselineskip by \scalecount
#1
}}
\endgroup
\scaleBase\magstep1
{line1\par line2\par line3}
\bye
And then \scaleBase\magstep1 will \show the definition of \scaleBaseWithFactor,
which may mean there is nothing before \relax, just strip \relax as expected.
While \scaleBase\magstep0 report:
:!f=tmp sh -c 'luatex $f.tex'
This is LuaTeX, Version 1.22.0 (TeX Live 2026/dev/Arch Linux)
restricted system commands enabled.
(./tmp.tex
> \or=\or.
<argument> \or
1200\or 1440\or 1728\or 2074\or 2488\fi
\scaleBaseWithmagstep #1\relax #2->\show #1
\scaleBaseWithFactor {#2}
l.27 \scaleBase\magstep0{}
apply \or before 1200 to \show.
It seems that:
* For \magstep1
* \afterassignment insert \scaleBaseWithmagstep after the full \ifcase
* For \magstep0
* \afterassignment insert \scaleBaseWithmagstep before the 1st \or.
________________________________
From: li lu
Sent: Sunday, June 8, 2025 3:27 PM
To: [email protected] <[email protected]>
Subject: A strange behavior of `\magstep0`
Hi LuaTeX Team,
I am writing to report strange behavior of the \magstep0 command , or the
original magnification \csname @m\endcsname.
The problem is happened in a macro with \afterassignment and then assign
\magstep0 to a count register.
For the LuaTeX version: luatex --version
This is LuaTeX, Version 1.22.0 (TeX Live 2026/dev/Arch Linux)
Development id: 7674
Execute 'luatex --credits' for credits and version details.
There is NO warranty. Redistribution of this software is covered by
the terms of the GNU General Public License, version 2 or (at your option)
any later version. For more information about these matters, see the file
named COPYING and the LuaTeX source.
LuaTeX is Copyright 2025 Taco Hoekwater and the LuaTeX Team.
The problem is happened in a macro with \afterassignment and then assign
\magstep0 to a count register.
A shortest description:
```
\newcount\count
\def\problemhere#1\relax#2{\string#1#2}
\def\todo{
\afterassignment\problemhere
\count=
}
```
For the above macro, \todo\magstep1{HERE} just print HERE while
\todo\magstep0{HERE} print \or1200HERE.
It seems that \magstep0 break the \ifcase structure in the \magstep definition,
It seems that this is not a expected behavior.
Complete use case steps and more details are on the stackoverflow page
* https://tex.stackexchange.com/q/745864/248249
Sincerely,
Yours
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]