Who ate my space? (How to stop exp_args:Nf from consuming a space?)
I have a macro that uses prg_replicate:nn
to produce a number of spaces, then pass those spaces, after f-expanding prg_replicate:nn
, to another macro. The problem is that when I use exp_args:Nf
, it will use the romannumeral 0
thingy which can consume a space. Guess what, this space is removed from my replicated spaces, so after the whole thing is completed I have one space less.
The issue is reproduced with this MWE:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Nf __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
which produces:
I couldn't find a way to stop romannumeral
from eating one of my spaces besides the obvious "do the whole thing with an extra space to begin with".
For the time being I'm doing the replication with an extra space to feed to romannumeral
, but it seems a hackish way to do that. Is there another possibility?
macros expansion expl3
add a comment |
I have a macro that uses prg_replicate:nn
to produce a number of spaces, then pass those spaces, after f-expanding prg_replicate:nn
, to another macro. The problem is that when I use exp_args:Nf
, it will use the romannumeral 0
thingy which can consume a space. Guess what, this space is removed from my replicated spaces, so after the whole thing is completed I have one space less.
The issue is reproduced with this MWE:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Nf __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
which produces:
I couldn't find a way to stop romannumeral
from eating one of my spaces besides the obvious "do the whole thing with an extra space to begin with".
For the time being I'm doing the replication with an extra space to feed to romannumeral
, but it seems a hackish way to do that. Is there another possibility?
macros expansion expl3
Is 'use another expansion method' a valid answer? Withexpanded
coming (already in MiKTeX), I'd just usee
-type in new code.
– Joseph Wright♦
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible withf
-type, then I'd be happy withe
:)
– Phelype Oleinik
17 hours ago
how many steps requiresprg_replicate:nn
to fully expand ? if only two then you only need to expand twice.
– jfbu
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago
add a comment |
I have a macro that uses prg_replicate:nn
to produce a number of spaces, then pass those spaces, after f-expanding prg_replicate:nn
, to another macro. The problem is that when I use exp_args:Nf
, it will use the romannumeral 0
thingy which can consume a space. Guess what, this space is removed from my replicated spaces, so after the whole thing is completed I have one space less.
The issue is reproduced with this MWE:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Nf __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
which produces:
I couldn't find a way to stop romannumeral
from eating one of my spaces besides the obvious "do the whole thing with an extra space to begin with".
For the time being I'm doing the replication with an extra space to feed to romannumeral
, but it seems a hackish way to do that. Is there another possibility?
macros expansion expl3
I have a macro that uses prg_replicate:nn
to produce a number of spaces, then pass those spaces, after f-expanding prg_replicate:nn
, to another macro. The problem is that when I use exp_args:Nf
, it will use the romannumeral 0
thingy which can consume a space. Guess what, this space is removed from my replicated spaces, so after the whole thing is completed I have one space less.
The issue is reproduced with this MWE:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Nf __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
which produces:
I couldn't find a way to stop romannumeral
from eating one of my spaces besides the obvious "do the whole thing with an extra space to begin with".
For the time being I'm doing the replication with an extra space to feed to romannumeral
, but it seems a hackish way to do that. Is there another possibility?
macros expansion expl3
macros expansion expl3
edited 17 hours ago
Joseph Wright♦
202k21555883
202k21555883
asked 17 hours ago
Phelype OleinikPhelype Oleinik
21.5k54381
21.5k54381
Is 'use another expansion method' a valid answer? Withexpanded
coming (already in MiKTeX), I'd just usee
-type in new code.
– Joseph Wright♦
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible withf
-type, then I'd be happy withe
:)
– Phelype Oleinik
17 hours ago
how many steps requiresprg_replicate:nn
to fully expand ? if only two then you only need to expand twice.
– jfbu
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago
add a comment |
Is 'use another expansion method' a valid answer? Withexpanded
coming (already in MiKTeX), I'd just usee
-type in new code.
– Joseph Wright♦
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible withf
-type, then I'd be happy withe
:)
– Phelype Oleinik
17 hours ago
how many steps requiresprg_replicate:nn
to fully expand ? if only two then you only need to expand twice.
– jfbu
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago
Is 'use another expansion method' a valid answer? With
expanded
coming (already in MiKTeX), I'd just use e
-type in new code.– Joseph Wright♦
17 hours ago
Is 'use another expansion method' a valid answer? With
expanded
coming (already in MiKTeX), I'd just use e
-type in new code.– Joseph Wright♦
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible with
f
-type, then I'd be happy with e
:)– Phelype Oleinik
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible with
f
-type, then I'd be happy with e
:)– Phelype Oleinik
17 hours ago
how many steps requires
prg_replicate:nn
to fully expand ? if only two then you only need to expand twice.– jfbu
17 hours ago
how many steps requires
prg_replicate:nn
to fully expand ? if only two then you only need to expand twice.– jfbu
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago
add a comment |
3 Answers
3
active
oldest
votes
I would simply use the new e
-type approach here (i.e. using the expanded
primitive or equivalent):
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Ne __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
This will likely become the standard approach for such cases: f
-type expansion is much less important now that we have e
-type either directly using the expanded
primitive or (where necessary) emulated. Note that MiKTeX already has expanded
in pdfTeX and XeTeX, and that this will appear in TeX Live 2019. Also note that LuaTeX has had expanded
from day one. (Emulation is reliable but does have a performance impact: at present, it probably is best avoided for any code which needs to work in tight loops or similar.)
add a comment |
Like @jfbu mentioned, expanding twice is enough for prg_replicate:nn
. So using exp_args:No
twice on it suffices:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:NNo exp_args:No __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
add a comment |
I can only second @JosephWright and @Skillmon answers but speaking of what I know, with xint
you only need to expand once romannumeralxintreplicate{100}{ }
to get 100 spaces. So if inside a macro
defx{romannumeralxintreplicate{100}{ }}
you only need to expand x
twice.
Or
defx{xintreplicate{100}{ }}
then you can do romannumeralx
.
Oh wait, I completely forgot: romannumeralxintreplicate
basically IS (up to different user interface) prg_replicate:nn
, I COPIED its underlying implementation ;-)
.
You naughty boy ;) But they are not exactly the same. If I useexpandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I useexpandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get aMissing number
error... Either way, I'm sticking toexpl3
in this code, so I'll leavexint
for another time :)
– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface withromannumeral
. I will fix my confusing wording. (of coursexint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)
– jfbu
16 hours ago
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post doesabs(#1)
replications when input#1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)
– jfbu
16 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469521%2fwho-ate-my-space-how-to-stop-exp-argsnf-from-consuming-a-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I would simply use the new e
-type approach here (i.e. using the expanded
primitive or equivalent):
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Ne __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
This will likely become the standard approach for such cases: f
-type expansion is much less important now that we have e
-type either directly using the expanded
primitive or (where necessary) emulated. Note that MiKTeX already has expanded
in pdfTeX and XeTeX, and that this will appear in TeX Live 2019. Also note that LuaTeX has had expanded
from day one. (Emulation is reliable but does have a performance impact: at present, it probably is best avoided for any code which needs to work in tight loops or similar.)
add a comment |
I would simply use the new e
-type approach here (i.e. using the expanded
primitive or equivalent):
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Ne __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
This will likely become the standard approach for such cases: f
-type expansion is much less important now that we have e
-type either directly using the expanded
primitive or (where necessary) emulated. Note that MiKTeX already has expanded
in pdfTeX and XeTeX, and that this will appear in TeX Live 2019. Also note that LuaTeX has had expanded
from day one. (Emulation is reliable but does have a performance impact: at present, it probably is best avoided for any code which needs to work in tight loops or similar.)
add a comment |
I would simply use the new e
-type approach here (i.e. using the expanded
primitive or equivalent):
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Ne __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
This will likely become the standard approach for such cases: f
-type expansion is much less important now that we have e
-type either directly using the expanded
primitive or (where necessary) emulated. Note that MiKTeX already has expanded
in pdfTeX and XeTeX, and that this will appear in TeX Live 2019. Also note that LuaTeX has had expanded
from day one. (Emulation is reliable but does have a performance impact: at present, it probably is best avoided for any code which needs to work in tight loops or similar.)
I would simply use the new e
-type approach here (i.e. using the expanded
primitive or equivalent):
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:Ne __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
This will likely become the standard approach for such cases: f
-type expansion is much less important now that we have e
-type either directly using the expanded
primitive or (where necessary) emulated. Note that MiKTeX already has expanded
in pdfTeX and XeTeX, and that this will appear in TeX Live 2019. Also note that LuaTeX has had expanded
from day one. (Emulation is reliable but does have a performance impact: at present, it probably is best avoided for any code which needs to work in tight loops or similar.)
edited 17 hours ago
answered 17 hours ago
Joseph Wright♦Joseph Wright
202k21555883
202k21555883
add a comment |
add a comment |
Like @jfbu mentioned, expanding twice is enough for prg_replicate:nn
. So using exp_args:No
twice on it suffices:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:NNo exp_args:No __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
add a comment |
Like @jfbu mentioned, expanding twice is enough for prg_replicate:nn
. So using exp_args:No
twice on it suffices:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:NNo exp_args:No __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
add a comment |
Like @jfbu mentioned, expanding twice is enough for prg_replicate:nn
. So using exp_args:No
twice on it suffices:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:NNo exp_args:No __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
Like @jfbu mentioned, expanding twice is enough for prg_replicate:nn
. So using exp_args:No
twice on it suffices:
documentclass{article}
usepackage{expl3}
begin{document}
ExplSyntaxOn
cs_new:Npn __printf_pre_output:n #1 { [ tl_to_str:n {#1} ] }
cs_set:Npn __printf_tmp:w #1
{
cs_new:Npn __printf_format_final_print:n ##1
{
exp_args:NNo exp_args:No __printf_pre_output:n
{ prg_replicate:nn {##1} {#1} }
}
}
__printf_tmp:w { ~ }
ttfamily
Wrong,~4~spaces:~__printf_format_final_print:n {5}par
Right,~5~spaces:~[ ]par
ExplSyntaxOff
end{document}
answered 17 hours ago
SkillmonSkillmon
21.3k11941
21.3k11941
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
add a comment |
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
Ooh, I got so deep in counting spaces that I forgot counting expansions :)
– Phelype Oleinik
17 hours ago
add a comment |
I can only second @JosephWright and @Skillmon answers but speaking of what I know, with xint
you only need to expand once romannumeralxintreplicate{100}{ }
to get 100 spaces. So if inside a macro
defx{romannumeralxintreplicate{100}{ }}
you only need to expand x
twice.
Or
defx{xintreplicate{100}{ }}
then you can do romannumeralx
.
Oh wait, I completely forgot: romannumeralxintreplicate
basically IS (up to different user interface) prg_replicate:nn
, I COPIED its underlying implementation ;-)
.
You naughty boy ;) But they are not exactly the same. If I useexpandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I useexpandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get aMissing number
error... Either way, I'm sticking toexpl3
in this code, so I'll leavexint
for another time :)
– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface withromannumeral
. I will fix my confusing wording. (of coursexint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)
– jfbu
16 hours ago
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post doesabs(#1)
replications when input#1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)
– jfbu
16 hours ago
add a comment |
I can only second @JosephWright and @Skillmon answers but speaking of what I know, with xint
you only need to expand once romannumeralxintreplicate{100}{ }
to get 100 spaces. So if inside a macro
defx{romannumeralxintreplicate{100}{ }}
you only need to expand x
twice.
Or
defx{xintreplicate{100}{ }}
then you can do romannumeralx
.
Oh wait, I completely forgot: romannumeralxintreplicate
basically IS (up to different user interface) prg_replicate:nn
, I COPIED its underlying implementation ;-)
.
You naughty boy ;) But they are not exactly the same. If I useexpandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I useexpandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get aMissing number
error... Either way, I'm sticking toexpl3
in this code, so I'll leavexint
for another time :)
– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface withromannumeral
. I will fix my confusing wording. (of coursexint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)
– jfbu
16 hours ago
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post doesabs(#1)
replications when input#1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)
– jfbu
16 hours ago
add a comment |
I can only second @JosephWright and @Skillmon answers but speaking of what I know, with xint
you only need to expand once romannumeralxintreplicate{100}{ }
to get 100 spaces. So if inside a macro
defx{romannumeralxintreplicate{100}{ }}
you only need to expand x
twice.
Or
defx{xintreplicate{100}{ }}
then you can do romannumeralx
.
Oh wait, I completely forgot: romannumeralxintreplicate
basically IS (up to different user interface) prg_replicate:nn
, I COPIED its underlying implementation ;-)
.
I can only second @JosephWright and @Skillmon answers but speaking of what I know, with xint
you only need to expand once romannumeralxintreplicate{100}{ }
to get 100 spaces. So if inside a macro
defx{romannumeralxintreplicate{100}{ }}
you only need to expand x
twice.
Or
defx{xintreplicate{100}{ }}
then you can do romannumeralx
.
Oh wait, I completely forgot: romannumeralxintreplicate
basically IS (up to different user interface) prg_replicate:nn
, I COPIED its underlying implementation ;-)
.
edited 16 hours ago
answered 17 hours ago
jfbujfbu
46.3k66148
46.3k66148
You naughty boy ;) But they are not exactly the same. If I useexpandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I useexpandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get aMissing number
error... Either way, I'm sticking toexpl3
in this code, so I'll leavexint
for another time :)
– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface withromannumeral
. I will fix my confusing wording. (of coursexint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)
– jfbu
16 hours ago
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post doesabs(#1)
replications when input#1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)
– jfbu
16 hours ago
add a comment |
You naughty boy ;) But they are not exactly the same. If I useexpandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I useexpandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get aMissing number
error... Either way, I'm sticking toexpl3
in this code, so I'll leavexint
for another time :)
– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface withromannumeral
. I will fix my confusing wording. (of coursexint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)
– jfbu
16 hours ago
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post doesabs(#1)
replications when input#1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)
– jfbu
16 hours ago
You naughty boy ;) But they are not exactly the same. If I use
expandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I use expandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get a Missing number
error... Either way, I'm sticking to expl3
in this code, so I'll leave xint
for another time :)– Phelype Oleinik
16 hours ago
You naughty boy ;) But they are not exactly the same. If I use
expandafter__printf_pre_output:nexpandafter{romannumeralxintreplicate{##1}{#1}}
it works correctly, but if I use expandafter__printf_pre_output:nexpandafter{romannumeralprg_replicate:nn{##1}{#1}}
I get a Missing number
error... Either way, I'm sticking to expl3
in this code, so I'll leave xint
for another time :)– Phelype Oleinik
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface with
romannumeral
. I will fix my confusing wording. (of course xint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)– jfbu
16 hours ago
@PhelypeOleinik yes only the underlying implementation is the same, not the user interface with
romannumeral
. I will fix my confusing wording. (of course xint
never had ambition to provide programming environment like expl3 does; if I had known about expl3 when I started coding xint in 2013 I might have used it... but obviously I was not good at that time finding TeX documentation...)– jfbu
16 hours ago
1
1
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post does
abs(#1)
replications when input #1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)– jfbu
16 hours ago
not exactly the same (from the docs: Using it with a negative x raises no error and does nothing. and from code comment in sourcexint.pdf The code in Joseph's post does
abs(#1)
replications when input #1
is negative and then activates an error triggering macro; This refers to tex.stackexchange.com/questions/16189/repeat-command-n-times and I don't know if posted code there is still faithfully the one from expl3)– jfbu
16 hours ago
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469521%2fwho-ate-my-space-how-to-stop-exp-argsnf-from-consuming-a-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Is 'use another expansion method' a valid answer? With
expanded
coming (already in MiKTeX), I'd just usee
-type in new code.– Joseph Wright♦
17 hours ago
@JosephWright Ooh, there's that. If it isn't possible with
f
-type, then I'd be happy withe
:)– Phelype Oleinik
17 hours ago
how many steps requires
prg_replicate:nn
to fully expand ? if only two then you only need to expand twice.– jfbu
17 hours ago
@jfbu two steps.
– Skillmon
17 hours ago