Different macro behavior when used in another macro Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What's the best/right way to test an argument to a macro?How do I put a paragraph in a box that is some percentage of the width of the page I'm putting it in?How to control whether and when a macro gets expanded during another definition?one character macrosDifferent macro behavior when supplied an argumentHow to read a stream of tokens up to one of two different delimitersDraw a box around a title on the title pageTesting parameter as “empty” when it has nested bracesProtecting blocks of text and commands, not just one command, from expansionWeird hfill behavior with custom length calculations?
In predicate logic, does existential quantification (∃) include universal quantification (∀), i.e. can 'some' imply 'all'?
porting install scripts : can rpm replace apt?
What does this icon in iOS Stardew Valley mean?
Denied boarding although I have proper visa and documentation. To whom should I make a complaint?
When were vectors invented?
Should I use a zero-interest credit card for a large one-time purchase?
Identify plant with long narrow paired leaves and reddish stems
What does an IRS interview request entail when called in to verify expenses for a sole proprietor small business?
How widely used is the term Treppenwitz? Is it something that most Germans know?
Why am I getting the error "non-boolean type specified in a context where a condition is expected" for this request?
What does the "x" in "x86" represent?
What is a non-alternating simple group with big order, but relatively few conjugacy classes?
What is Arya's weapon design?
Why did the Falcon Heavy center core fall off the ASDS OCISLY barge?
How do I stop a creek from eroding my steep embankment?
Why do people hide their license plates in the EU?
How to align text above triangle figure
If a contract sometimes uses the wrong name, is it still valid?
Why is my conclusion inconsistent with the van't Hoff equation?
The logistics of corpse disposal
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
Echoing a tail command produces unexpected output?
Is it true that "carbohydrates are of no use for the basal metabolic need"?
ListPlot join points by nearest neighbor rather than order
Different macro behavior when used in another macro
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)What's the best/right way to test an argument to a macro?How do I put a paragraph in a box that is some percentage of the width of the page I'm putting it in?How to control whether and when a macro gets expanded during another definition?one character macrosDifferent macro behavior when supplied an argumentHow to read a stream of tokens up to one of two different delimitersDraw a box around a title on the title pageTesting parameter as “empty” when it has nested bracesProtecting blocks of text and commands, not just one command, from expansionWeird hfill behavior with custom length calculations?
Please consider the following MWE :
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
(actually, the definitions of boxes are more complex but I think that doesn't change anything to the logic)
I'd like the use of innerbox
inside outerbox
not to induce spaces at the beginning and at the end of the box.
I suppose i should expand argument #1
(once got rid of the unnecessary spaces) from outerbox
and detect if the first and last token are equal mymargin
and then make the necessary changes but I really don't know how to do it. Any ideas?
macros boxes expansion
New contributor
add a comment |
Please consider the following MWE :
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
(actually, the definitions of boxes are more complex but I think that doesn't change anything to the logic)
I'd like the use of innerbox
inside outerbox
not to induce spaces at the beginning and at the end of the box.
I suppose i should expand argument #1
(once got rid of the unnecessary spaces) from outerbox
and detect if the first and last token are equal mymargin
and then make the necessary changes but I really don't know how to do it. Any ideas?
macros boxes expansion
New contributor
Welcome to TeX.SE!
– Kurt
14 hours ago
add a comment |
Please consider the following MWE :
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
(actually, the definitions of boxes are more complex but I think that doesn't change anything to the logic)
I'd like the use of innerbox
inside outerbox
not to induce spaces at the beginning and at the end of the box.
I suppose i should expand argument #1
(once got rid of the unnecessary spaces) from outerbox
and detect if the first and last token are equal mymargin
and then make the necessary changes but I really don't know how to do it. Any ideas?
macros boxes expansion
New contributor
Please consider the following MWE :
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
(actually, the definitions of boxes are more complex but I think that doesn't change anything to the logic)
I'd like the use of innerbox
inside outerbox
not to induce spaces at the beginning and at the end of the box.
I suppose i should expand argument #1
(once got rid of the unnecessary spaces) from outerbox
and detect if the first and last token are equal mymargin
and then make the necessary changes but I really don't know how to do it. Any ideas?
macros boxes expansion
macros boxes expansion
New contributor
New contributor
edited 11 hours ago
David Carlisle
499k4111451896
499k4111451896
New contributor
asked 14 hours ago
user30654user30654
16111
16111
New contributor
New contributor
Welcome to TeX.SE!
– Kurt
14 hours ago
add a comment |
Welcome to TeX.SE!
– Kurt
14 hours ago
Welcome to TeX.SE!
– Kurt
14 hours ago
Welcome to TeX.SE!
– Kurt
14 hours ago
add a comment |
2 Answers
2
active
oldest
votes
You can check (ignoring spaces) whether the first token in the argument of outerbox
is innerbox
and, in this case, expand it and gobble mymargin
.
At the end you can recursively remove all glue nodes.
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
makeatletter
newcommandouterbox[1]%
fbox%
@ifnextcharinnerboxexpandafter@gobble#1%
forever@unskip
%
newcommandforever@unskip%
ifnumlastnodetype=11
expandafterunskipexpandafterforever@unskip
fi
makeatother
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
test outerboxtest innerboxHello test innerboxHello
test outerboxinnerboxHello test innerboxHello test
test outerbox test innerboxHello test innerboxHello
test outerbox innerboxHello test innerboxHello test
enddocument
add a comment |
This version omits the space if innerbox
is in any hbox, not just outerbox
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifinnerelsemymarginfififbox#1ifhmodeifinnerelsemymarginfifi
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
egreg notes that you may not be what you wanted, so..
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifnumlastpenalty=-1elsemymarginfififbox#1mymargin
newcommandouterbox[1]fboxpenalty-1#1unskipunskip
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 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
);
);
user30654 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f485147%2fdifferent-macro-behavior-when-used-in-another-macro%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can check (ignoring spaces) whether the first token in the argument of outerbox
is innerbox
and, in this case, expand it and gobble mymargin
.
At the end you can recursively remove all glue nodes.
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
makeatletter
newcommandouterbox[1]%
fbox%
@ifnextcharinnerboxexpandafter@gobble#1%
forever@unskip
%
newcommandforever@unskip%
ifnumlastnodetype=11
expandafterunskipexpandafterforever@unskip
fi
makeatother
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
test outerboxtest innerboxHello test innerboxHello
test outerboxinnerboxHello test innerboxHello test
test outerbox test innerboxHello test innerboxHello
test outerbox innerboxHello test innerboxHello test
enddocument
add a comment |
You can check (ignoring spaces) whether the first token in the argument of outerbox
is innerbox
and, in this case, expand it and gobble mymargin
.
At the end you can recursively remove all glue nodes.
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
makeatletter
newcommandouterbox[1]%
fbox%
@ifnextcharinnerboxexpandafter@gobble#1%
forever@unskip
%
newcommandforever@unskip%
ifnumlastnodetype=11
expandafterunskipexpandafterforever@unskip
fi
makeatother
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
test outerboxtest innerboxHello test innerboxHello
test outerboxinnerboxHello test innerboxHello test
test outerbox test innerboxHello test innerboxHello
test outerbox innerboxHello test innerboxHello test
enddocument
add a comment |
You can check (ignoring spaces) whether the first token in the argument of outerbox
is innerbox
and, in this case, expand it and gobble mymargin
.
At the end you can recursively remove all glue nodes.
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
makeatletter
newcommandouterbox[1]%
fbox%
@ifnextcharinnerboxexpandafter@gobble#1%
forever@unskip
%
newcommandforever@unskip%
ifnumlastnodetype=11
expandafterunskipexpandafterforever@unskip
fi
makeatother
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
test outerboxtest innerboxHello test innerboxHello
test outerboxinnerboxHello test innerboxHello test
test outerbox test innerboxHello test innerboxHello
test outerbox innerboxHello test innerboxHello test
enddocument
You can check (ignoring spaces) whether the first token in the argument of outerbox
is innerbox
and, in this case, expand it and gobble mymargin
.
At the end you can recursively remove all glue nodes.
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]mymarginfbox#1mymargin
makeatletter
newcommandouterbox[1]%
fbox%
@ifnextcharinnerboxexpandafter@gobble#1%
forever@unskip
%
newcommandforever@unskip%
ifnumlastnodetype=11
expandafterunskipexpandafterforever@unskip
fi
makeatother
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
test outerboxtest innerboxHello test innerboxHello
test outerboxinnerboxHello test innerboxHello test
test outerbox test innerboxHello test innerboxHello
test outerbox innerboxHello test innerboxHello test
enddocument
answered 13 hours ago
egregegreg
734k8919333257
734k8919333257
add a comment |
add a comment |
This version omits the space if innerbox
is in any hbox, not just outerbox
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifinnerelsemymarginfififbox#1ifhmodeifinnerelsemymarginfifi
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
egreg notes that you may not be what you wanted, so..
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifnumlastpenalty=-1elsemymarginfififbox#1mymargin
newcommandouterbox[1]fboxpenalty-1#1unskipunskip
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
add a comment |
This version omits the space if innerbox
is in any hbox, not just outerbox
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifinnerelsemymarginfififbox#1ifhmodeifinnerelsemymarginfifi
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
egreg notes that you may not be what you wanted, so..
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifnumlastpenalty=-1elsemymarginfififbox#1mymargin
newcommandouterbox[1]fboxpenalty-1#1unskipunskip
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
add a comment |
This version omits the space if innerbox
is in any hbox, not just outerbox
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifinnerelsemymarginfififbox#1ifhmodeifinnerelsemymarginfifi
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
egreg notes that you may not be what you wanted, so..
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifnumlastpenalty=-1elsemymarginfififbox#1mymargin
newcommandouterbox[1]fboxpenalty-1#1unskipunskip
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
This version omits the space if innerbox
is in any hbox, not just outerbox
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifinnerelsemymarginfififbox#1ifhmodeifinnerelsemymarginfifi
newcommandouterbox[1]fbox#1
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
egreg notes that you may not be what you wanted, so..
documentclassarticle
newcommandmymarginhspace*3em
newcommandinnerbox[1]ifhmodeifnumlastpenalty=-1elsemymarginfififbox#1mymargin
newcommandouterbox[1]fboxpenalty-1#1unskipunskip
begindocument
test innerboxHello test% OK
test outerboxinnerboxHello test innerboxHello test innerboxHello% I don't want space at beginning and end of box
test outerboxfboxHellomymargin test innerboxHello test mymarginfboxHello% what i'd like
enddocument
edited 10 hours ago
answered 11 hours ago
David CarlisleDavid Carlisle
499k4111451896
499k4111451896
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
add a comment |
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
Which is rather different from the output the OP seems to want. Look at the “what I'd like” line.
– egreg
11 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
@egreg 2nd version added (shame, first version was more fun)
– David Carlisle
10 hours ago
add a comment |
user30654 is a new contributor. Be nice, and check out our Code of Conduct.
user30654 is a new contributor. Be nice, and check out our Code of Conduct.
user30654 is a new contributor. Be nice, and check out our Code of Conduct.
user30654 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f485147%2fdifferent-macro-behavior-when-used-in-another-macro%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
-boxes, expansion, macros
Welcome to TeX.SE!
– Kurt
14 hours ago