Expand command in an argument before the main commandExercises imported don't print when i call a collectionHyperref to expand macro in argumentexpandafter to expand macro before macro callExpand argument for detokenize while creating indexExpand nameref before creating indexExpand a command inside another commandextra solution for blank in xsim necessary?Protecting blocks of text and commands, not just one command, from expansionA way to “execute” only latex procedural code (def, let) in a sequence ignoring the rest?Fully expand macro argumentExercises imported don't print when i call a collection
Why is Madam Hooch not a professor?
What would earth look like at night in medieval times?
Can the US president have someone sent to jail?
Animation advice please
What do you call a weak person's act of taking on bigger opponents?
Do flight schools typically have dress codes or expectations?
Plotting with different color for a single curve
C-152 carb heat on before landing in hot weather?
Cascading Repair Costs following Blown Head Gasket on a 2004 Subaru Outback
Does anycast addressing add additional latency in any way?
What is the fibered coproduct of abelian groups?
Fetch and print all properties of an object graph as string
Unusual mail headers, evidence of an attempted attack. Have I been pwned?
Does ultrasonic bath cleaning damage laboratory volumetric glassware calibration?
Is adding a new player (or players) a DM decision, or a group decision?
What are the benefits of using the X Card safety tool in comparison to plain communication?
When is the original BFGS algorithm still better than the Limited-Memory version?
MH370 blackbox - is it still possible to retrieve data from it?
What happens when your group is victim of a surprise attack but you can't be surprised?
Could Sauron have read Tom Bombadil's mind if Tom had held the Palantir?
Does squid ink pasta bleed?
How to split an equation over two lines?
Story-based adventure with functions and relationships
A player is constantly pestering me about rules, what do I do as a DM?
Expand command in an argument before the main command
Exercises imported don't print when i call a collectionHyperref to expand macro in argumentexpandafter to expand macro before macro callExpand argument for detokenize while creating indexExpand nameref before creating indexExpand a command inside another commandextra solution for blank in xsim necessary?Protecting blocks of text and commands, not just one command, from expansionA way to “execute” only latex procedural code (def, let) in a sequence ignoring the rest?Fully expand macro argumentExercises imported don't print when i call a collection
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
Related to my problem for xsim
here.
I want to use commands ExOption
and ExPart
to implement more easily my collection in xsim
package. But i'm facing the problem that my commands do not expand in DeclareExerciseCollectionExOption_ExPart
. In the aux
file i can find this line : XSIM collection:ExOption _ExPart
who point to me that there is no expansion.
How can i make my commands expanded before the macros DeclareExerciseCollection
and avoid spaces implement by TeX after a macro ? I've read some information about expandafter
and edef
and i think it can be helpfull but it's the first time i've to deal with those commands.
Here is a MWE :
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
DeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
collectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
collectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
expansion xsim
add a comment |
Related to my problem for xsim
here.
I want to use commands ExOption
and ExPart
to implement more easily my collection in xsim
package. But i'm facing the problem that my commands do not expand in DeclareExerciseCollectionExOption_ExPart
. In the aux
file i can find this line : XSIM collection:ExOption _ExPart
who point to me that there is no expansion.
How can i make my commands expanded before the macros DeclareExerciseCollection
and avoid spaces implement by TeX after a macro ? I've read some information about expandafter
and edef
and i think it can be helpfull but it's the first time i've to deal with those commands.
Here is a MWE :
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
DeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
collectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
collectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
expansion xsim
add a comment |
Related to my problem for xsim
here.
I want to use commands ExOption
and ExPart
to implement more easily my collection in xsim
package. But i'm facing the problem that my commands do not expand in DeclareExerciseCollectionExOption_ExPart
. In the aux
file i can find this line : XSIM collection:ExOption _ExPart
who point to me that there is no expansion.
How can i make my commands expanded before the macros DeclareExerciseCollection
and avoid spaces implement by TeX after a macro ? I've read some information about expandafter
and edef
and i think it can be helpfull but it's the first time i've to deal with those commands.
Here is a MWE :
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
DeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
collectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
collectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
expansion xsim
Related to my problem for xsim
here.
I want to use commands ExOption
and ExPart
to implement more easily my collection in xsim
package. But i'm facing the problem that my commands do not expand in DeclareExerciseCollectionExOption_ExPart
. In the aux
file i can find this line : XSIM collection:ExOption _ExPart
who point to me that there is no expansion.
How can i make my commands expanded before the macros DeclareExerciseCollection
and avoid spaces implement by TeX after a macro ? I've read some information about expandafter
and edef
and i think it can be helpfull but it's the first time i've to deal with those commands.
Here is a MWE :
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
DeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
collectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
collectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
expansion xsim
expansion xsim
edited Jun 15 at 12:54
David Carlisle
511k43 gold badges1162 silver badges1923 bronze badges
511k43 gold badges1162 silver badges1923 bronze badges
asked Jun 15 at 12:38
PirooohPiroooh
36010 bronze badges
36010 bronze badges
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
With a current version of pdftex (that defines expanded
) you can define expanding versions of the commands as shown below.
With older implementations without expanded
you can use edef
:
newcommandxDeclareExerciseCollection[1]%
edeftmpnoexpandDeclareExerciseCollection#1tmp
and similarly for the other two commands.
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
newcommandxDeclareExerciseCollection[1]%
expandafterDeclareExerciseCollectionexpandafterexpanded#1
newcommandxcollectexercises[1]%
expandaftercollectexercisesexpandafterexpanded#1
newcommandxcollectexercisesstop[1]%
expandaftercollectexercisesstopexpandafterexpanded#1
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
xDeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
xcollectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
xcollectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
Your solution doesn't work, the console says that the commandsx...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark aboutexpanded
? I'll update my version of pdftex and retry it.
– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not sayx...
is undefined it will sayexpanded
is undefined. (if you use texlive you need texlive 2019) but I give the version withoutexpanded
as well.
– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not overexpanded
for which you warned me. I continue to test if i can update version to testexpanded
answer. The solution withoutexpanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?
– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all threex..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should showexpanded
as the undefined command.
– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
|
show 2 more comments
I present two solutions here.
First solution
This is in the same spirit as David Carlisle's solution, except that only one command needs to be defined for everything. You don't need a specific command for DeclareExerciseCollection
, for collectexercises
, for collectexercisesstop
, etc. Also, the command is implemented with LaTeX3—and thus not a fake of David Carlisle's solution. :-)
documentclassbook
usepackage[verbose,clear-aux]xsim
usepackagexparse
ExplSyntaxOn
cs_new_protected:Npn pirooh_call_with_one_arg:Nn #1#2
#1 #2
cs_generate_variant:Nn pirooh_call_with_one_arg:Nn Nx
NewDocumentCommand callWithExpandedArg m m
% Perform full expansion on what #2 stands for, then call #1
% with the result.
pirooh_call_with_one_arg:Nx #1 #2
ExplSyntaxOff
newcommand*ExOption5M4
newcommand*ExPartAlgebreFinanciere
callWithExpandedArgDeclareExerciseCollectionExOption_ExPart
begindocument
chapterWhere i want exercises
callWithExpandedArgcollectexercisesExOption_ExPart
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithExpandedArgcollectexercisesstopExOption_ExPart
callWithExpandedArgprintcollectionExOption_ExPart
enddocument
Second solution
Here, the approach is different. There is one command to define per argument value, not per xsim
command such as DeclareExerciseCollection
, collectexercises
, collectexercisesstop
and printcollection
as in David Carlisle's solution. Here, the command callWithPredefinedArg
is defined for the argument value 5M4_AlgebreFinanciere
(you may want to adapt its name).
This solution isn't better than others, it's just different in spirit. The code does full expansion of ExOption
and ExPart
when callWithPredefinedArg
is defined (this could be changed if needed).
documentclassbook
usepackage[verbose,clear-aux]xsim
newcommand*ExOptiondefault
newcommand*ExPartdefault
renewcommand*ExOption5M4
renewcommand*ExPartAlgebreFinanciere
% This recursively expands ExOption and ExPart and “freezes”
% the result in the definition of callWithPredefinedArg.
edefcallWithPredefinedArg#1#1ExOption_ExPart
% Of course, you could achieve the same with:
%defcallWithPredefinedArg#1#15M4_AlgebreFinanciere
callWithPredefinedArgDeclareExerciseCollection
begindocument
chapterWhere i want exercises
callWithPredefinedArgcollectexercises
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithPredefinedArgcollectexercisesstop
callWithPredefinedArgprintcollection
% If you have another chapter/module to start here, you could do
% defcallWithPredefinedArg#1#16N5_GeometrieFinanciere
% callWithPredefinedArgcollectexercises
% etc.
enddocument
If i understand,callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here :ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefinecallWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !
– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass toxsim
commands (or whatever you use aftercallWithPredefinedArg
) is frozen at the timecallWithPredefinedArg
is defined (I added comments that should clarify this, I hope).
– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near whatxsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to readexpl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !
– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understandingexpl3
code, but well...
– frougon
Jun 15 at 14:38
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%2f495894%2fexpand-command-in-an-argument-before-the-main-command%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
With a current version of pdftex (that defines expanded
) you can define expanding versions of the commands as shown below.
With older implementations without expanded
you can use edef
:
newcommandxDeclareExerciseCollection[1]%
edeftmpnoexpandDeclareExerciseCollection#1tmp
and similarly for the other two commands.
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
newcommandxDeclareExerciseCollection[1]%
expandafterDeclareExerciseCollectionexpandafterexpanded#1
newcommandxcollectexercises[1]%
expandaftercollectexercisesexpandafterexpanded#1
newcommandxcollectexercisesstop[1]%
expandaftercollectexercisesstopexpandafterexpanded#1
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
xDeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
xcollectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
xcollectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
Your solution doesn't work, the console says that the commandsx...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark aboutexpanded
? I'll update my version of pdftex and retry it.
– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not sayx...
is undefined it will sayexpanded
is undefined. (if you use texlive you need texlive 2019) but I give the version withoutexpanded
as well.
– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not overexpanded
for which you warned me. I continue to test if i can update version to testexpanded
answer. The solution withoutexpanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?
– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all threex..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should showexpanded
as the undefined command.
– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
|
show 2 more comments
With a current version of pdftex (that defines expanded
) you can define expanding versions of the commands as shown below.
With older implementations without expanded
you can use edef
:
newcommandxDeclareExerciseCollection[1]%
edeftmpnoexpandDeclareExerciseCollection#1tmp
and similarly for the other two commands.
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
newcommandxDeclareExerciseCollection[1]%
expandafterDeclareExerciseCollectionexpandafterexpanded#1
newcommandxcollectexercises[1]%
expandaftercollectexercisesexpandafterexpanded#1
newcommandxcollectexercisesstop[1]%
expandaftercollectexercisesstopexpandafterexpanded#1
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
xDeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
xcollectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
xcollectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
Your solution doesn't work, the console says that the commandsx...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark aboutexpanded
? I'll update my version of pdftex and retry it.
– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not sayx...
is undefined it will sayexpanded
is undefined. (if you use texlive you need texlive 2019) but I give the version withoutexpanded
as well.
– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not overexpanded
for which you warned me. I continue to test if i can update version to testexpanded
answer. The solution withoutexpanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?
– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all threex..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should showexpanded
as the undefined command.
– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
|
show 2 more comments
With a current version of pdftex (that defines expanded
) you can define expanding versions of the commands as shown below.
With older implementations without expanded
you can use edef
:
newcommandxDeclareExerciseCollection[1]%
edeftmpnoexpandDeclareExerciseCollection#1tmp
and similarly for the other two commands.
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
newcommandxDeclareExerciseCollection[1]%
expandafterDeclareExerciseCollectionexpandafterexpanded#1
newcommandxcollectexercises[1]%
expandaftercollectexercisesexpandafterexpanded#1
newcommandxcollectexercisesstop[1]%
expandaftercollectexercisesstopexpandafterexpanded#1
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
xDeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
xcollectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
xcollectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
With a current version of pdftex (that defines expanded
) you can define expanding versions of the commands as shown below.
With older implementations without expanded
you can use edef
:
newcommandxDeclareExerciseCollection[1]%
edeftmpnoexpandDeclareExerciseCollection#1tmp
and similarly for the other two commands.
documentclass[10pt,a4paper]book
usepackage[verbose,clear-aux]xsim
newcommandxDeclareExerciseCollection[1]%
expandafterDeclareExerciseCollectionexpandafterexpanded#1
newcommandxcollectexercises[1]%
expandaftercollectexercisesexpandafterexpanded#1
newcommandxcollectexercisesstop[1]%
expandaftercollectexercisesstopexpandafterexpanded#1
%%Declaration exercices
edefExOptiondefault
edefExPartdefault
%%Declaration Collection
renewcommandExOption5M4
renewcommandExPartAlgebreFinanciere
xDeclareExerciseCollectionExOption_ExPart %%With custom commands produce wrong output
% DeclareExerciseCollection5M4_AlgebreFinanciere %%With applicable name produce good output
begindocument
chapterWhere i want exercises
%%Collecting exercises
xcollectexercisesExOption_ExPart %%With custom commands produce wrong output
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
xcollectexercisesstopExOption_ExPart
% collectexercises5M4_AlgebreFinanciere %%With applicable name produce good output
% beginexercise
% Can you print me ?
% endexercise
% beginsolution
% Yes, you can !
% endsolution
% collectexercisesstop5M4_AlgebreFinanciere
%%Print
Output of the command in LaTeX verb|ExOption_ExPart| : ExOption_ExPart
printcollection5M4_AlgebreFinanciere
enddocument
answered Jun 15 at 12:54
David CarlisleDavid Carlisle
511k43 gold badges1162 silver badges1923 bronze badges
511k43 gold badges1162 silver badges1923 bronze badges
Your solution doesn't work, the console says that the commandsx...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark aboutexpanded
? I'll update my version of pdftex and retry it.
– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not sayx...
is undefined it will sayexpanded
is undefined. (if you use texlive you need texlive 2019) but I give the version withoutexpanded
as well.
– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not overexpanded
for which you warned me. I continue to test if i can update version to testexpanded
answer. The solution withoutexpanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?
– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all threex..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should showexpanded
as the undefined command.
– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
|
show 2 more comments
Your solution doesn't work, the console says that the commandsx...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark aboutexpanded
? I'll update my version of pdftex and retry it.
– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not sayx...
is undefined it will sayexpanded
is undefined. (if you use texlive you need texlive 2019) but I give the version withoutexpanded
as well.
– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not overexpanded
for which you warned me. I continue to test if i can update version to testexpanded
answer. The solution withoutexpanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?
– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all threex..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should showexpanded
as the undefined command.
– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
Your solution doesn't work, the console says that the commands
x...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark about expanded
? I'll update my version of pdftex and retry it.– Piroooh
Jun 15 at 13:21
Your solution doesn't work, the console says that the commands
x...
are not defined. It does not produce an error for the definition but when they are called. Related to your remark about expanded
? I'll update my version of pdftex and retry it.– Piroooh
Jun 15 at 13:21
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not say
x...
is undefined it will say expanded
is undefined. (if you use texlive you need texlive 2019) but I give the version without expanded
as well.– David Carlisle
Jun 15 at 13:23
@Piroooh I always run the code before posting, it does not give errors on a current system. The error (in the log) on older systems would not say
x...
is undefined it will say expanded
is undefined. (if you use texlive you need texlive 2019) but I give the version without expanded
as well.– David Carlisle
Jun 15 at 13:23
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not over
expanded
for which you warned me. I continue to test if i can update version to test expanded
answer. The solution without expanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?– Piroooh
Jun 15 at 13:45
sorry, i didn't say it correctly. I wanted to say it doesn't work on my side and was curious to see the error that commands are not defined and not over
expanded
for which you warned me. I continue to test if i can update version to test expanded
answer. The solution without expanded
seems to compile but it takes a while to (~5min and do not make an output). Is it normal ?– Piroooh
Jun 15 at 13:45
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all three
x..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should show expanded
as the undefined command.– David Carlisle
Jun 15 at 13:48
@Piroooh I ran it in a second or two, you must be looping somewhere. Did you change all three
x..
commands? But for the expanded version check your log for the actual error message (not any misleading summary from your editor) it should show expanded
as the undefined command.– David Carlisle
Jun 15 at 13:48
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
Yes, i've changed the three definition commands. Seems i compile my documents with TeXLive 2017... I'll install the 2019 version first to tackle the problem !
– Piroooh
Jun 15 at 13:58
|
show 2 more comments
I present two solutions here.
First solution
This is in the same spirit as David Carlisle's solution, except that only one command needs to be defined for everything. You don't need a specific command for DeclareExerciseCollection
, for collectexercises
, for collectexercisesstop
, etc. Also, the command is implemented with LaTeX3—and thus not a fake of David Carlisle's solution. :-)
documentclassbook
usepackage[verbose,clear-aux]xsim
usepackagexparse
ExplSyntaxOn
cs_new_protected:Npn pirooh_call_with_one_arg:Nn #1#2
#1 #2
cs_generate_variant:Nn pirooh_call_with_one_arg:Nn Nx
NewDocumentCommand callWithExpandedArg m m
% Perform full expansion on what #2 stands for, then call #1
% with the result.
pirooh_call_with_one_arg:Nx #1 #2
ExplSyntaxOff
newcommand*ExOption5M4
newcommand*ExPartAlgebreFinanciere
callWithExpandedArgDeclareExerciseCollectionExOption_ExPart
begindocument
chapterWhere i want exercises
callWithExpandedArgcollectexercisesExOption_ExPart
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithExpandedArgcollectexercisesstopExOption_ExPart
callWithExpandedArgprintcollectionExOption_ExPart
enddocument
Second solution
Here, the approach is different. There is one command to define per argument value, not per xsim
command such as DeclareExerciseCollection
, collectexercises
, collectexercisesstop
and printcollection
as in David Carlisle's solution. Here, the command callWithPredefinedArg
is defined for the argument value 5M4_AlgebreFinanciere
(you may want to adapt its name).
This solution isn't better than others, it's just different in spirit. The code does full expansion of ExOption
and ExPart
when callWithPredefinedArg
is defined (this could be changed if needed).
documentclassbook
usepackage[verbose,clear-aux]xsim
newcommand*ExOptiondefault
newcommand*ExPartdefault
renewcommand*ExOption5M4
renewcommand*ExPartAlgebreFinanciere
% This recursively expands ExOption and ExPart and “freezes”
% the result in the definition of callWithPredefinedArg.
edefcallWithPredefinedArg#1#1ExOption_ExPart
% Of course, you could achieve the same with:
%defcallWithPredefinedArg#1#15M4_AlgebreFinanciere
callWithPredefinedArgDeclareExerciseCollection
begindocument
chapterWhere i want exercises
callWithPredefinedArgcollectexercises
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithPredefinedArgcollectexercisesstop
callWithPredefinedArgprintcollection
% If you have another chapter/module to start here, you could do
% defcallWithPredefinedArg#1#16N5_GeometrieFinanciere
% callWithPredefinedArgcollectexercises
% etc.
enddocument
If i understand,callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here :ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefinecallWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !
– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass toxsim
commands (or whatever you use aftercallWithPredefinedArg
) is frozen at the timecallWithPredefinedArg
is defined (I added comments that should clarify this, I hope).
– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near whatxsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to readexpl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !
– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understandingexpl3
code, but well...
– frougon
Jun 15 at 14:38
add a comment |
I present two solutions here.
First solution
This is in the same spirit as David Carlisle's solution, except that only one command needs to be defined for everything. You don't need a specific command for DeclareExerciseCollection
, for collectexercises
, for collectexercisesstop
, etc. Also, the command is implemented with LaTeX3—and thus not a fake of David Carlisle's solution. :-)
documentclassbook
usepackage[verbose,clear-aux]xsim
usepackagexparse
ExplSyntaxOn
cs_new_protected:Npn pirooh_call_with_one_arg:Nn #1#2
#1 #2
cs_generate_variant:Nn pirooh_call_with_one_arg:Nn Nx
NewDocumentCommand callWithExpandedArg m m
% Perform full expansion on what #2 stands for, then call #1
% with the result.
pirooh_call_with_one_arg:Nx #1 #2
ExplSyntaxOff
newcommand*ExOption5M4
newcommand*ExPartAlgebreFinanciere
callWithExpandedArgDeclareExerciseCollectionExOption_ExPart
begindocument
chapterWhere i want exercises
callWithExpandedArgcollectexercisesExOption_ExPart
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithExpandedArgcollectexercisesstopExOption_ExPart
callWithExpandedArgprintcollectionExOption_ExPart
enddocument
Second solution
Here, the approach is different. There is one command to define per argument value, not per xsim
command such as DeclareExerciseCollection
, collectexercises
, collectexercisesstop
and printcollection
as in David Carlisle's solution. Here, the command callWithPredefinedArg
is defined for the argument value 5M4_AlgebreFinanciere
(you may want to adapt its name).
This solution isn't better than others, it's just different in spirit. The code does full expansion of ExOption
and ExPart
when callWithPredefinedArg
is defined (this could be changed if needed).
documentclassbook
usepackage[verbose,clear-aux]xsim
newcommand*ExOptiondefault
newcommand*ExPartdefault
renewcommand*ExOption5M4
renewcommand*ExPartAlgebreFinanciere
% This recursively expands ExOption and ExPart and “freezes”
% the result in the definition of callWithPredefinedArg.
edefcallWithPredefinedArg#1#1ExOption_ExPart
% Of course, you could achieve the same with:
%defcallWithPredefinedArg#1#15M4_AlgebreFinanciere
callWithPredefinedArgDeclareExerciseCollection
begindocument
chapterWhere i want exercises
callWithPredefinedArgcollectexercises
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithPredefinedArgcollectexercisesstop
callWithPredefinedArgprintcollection
% If you have another chapter/module to start here, you could do
% defcallWithPredefinedArg#1#16N5_GeometrieFinanciere
% callWithPredefinedArgcollectexercises
% etc.
enddocument
If i understand,callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here :ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefinecallWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !
– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass toxsim
commands (or whatever you use aftercallWithPredefinedArg
) is frozen at the timecallWithPredefinedArg
is defined (I added comments that should clarify this, I hope).
– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near whatxsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to readexpl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !
– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understandingexpl3
code, but well...
– frougon
Jun 15 at 14:38
add a comment |
I present two solutions here.
First solution
This is in the same spirit as David Carlisle's solution, except that only one command needs to be defined for everything. You don't need a specific command for DeclareExerciseCollection
, for collectexercises
, for collectexercisesstop
, etc. Also, the command is implemented with LaTeX3—and thus not a fake of David Carlisle's solution. :-)
documentclassbook
usepackage[verbose,clear-aux]xsim
usepackagexparse
ExplSyntaxOn
cs_new_protected:Npn pirooh_call_with_one_arg:Nn #1#2
#1 #2
cs_generate_variant:Nn pirooh_call_with_one_arg:Nn Nx
NewDocumentCommand callWithExpandedArg m m
% Perform full expansion on what #2 stands for, then call #1
% with the result.
pirooh_call_with_one_arg:Nx #1 #2
ExplSyntaxOff
newcommand*ExOption5M4
newcommand*ExPartAlgebreFinanciere
callWithExpandedArgDeclareExerciseCollectionExOption_ExPart
begindocument
chapterWhere i want exercises
callWithExpandedArgcollectexercisesExOption_ExPart
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithExpandedArgcollectexercisesstopExOption_ExPart
callWithExpandedArgprintcollectionExOption_ExPart
enddocument
Second solution
Here, the approach is different. There is one command to define per argument value, not per xsim
command such as DeclareExerciseCollection
, collectexercises
, collectexercisesstop
and printcollection
as in David Carlisle's solution. Here, the command callWithPredefinedArg
is defined for the argument value 5M4_AlgebreFinanciere
(you may want to adapt its name).
This solution isn't better than others, it's just different in spirit. The code does full expansion of ExOption
and ExPart
when callWithPredefinedArg
is defined (this could be changed if needed).
documentclassbook
usepackage[verbose,clear-aux]xsim
newcommand*ExOptiondefault
newcommand*ExPartdefault
renewcommand*ExOption5M4
renewcommand*ExPartAlgebreFinanciere
% This recursively expands ExOption and ExPart and “freezes”
% the result in the definition of callWithPredefinedArg.
edefcallWithPredefinedArg#1#1ExOption_ExPart
% Of course, you could achieve the same with:
%defcallWithPredefinedArg#1#15M4_AlgebreFinanciere
callWithPredefinedArgDeclareExerciseCollection
begindocument
chapterWhere i want exercises
callWithPredefinedArgcollectexercises
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithPredefinedArgcollectexercisesstop
callWithPredefinedArgprintcollection
% If you have another chapter/module to start here, you could do
% defcallWithPredefinedArg#1#16N5_GeometrieFinanciere
% callWithPredefinedArgcollectexercises
% etc.
enddocument
I present two solutions here.
First solution
This is in the same spirit as David Carlisle's solution, except that only one command needs to be defined for everything. You don't need a specific command for DeclareExerciseCollection
, for collectexercises
, for collectexercisesstop
, etc. Also, the command is implemented with LaTeX3—and thus not a fake of David Carlisle's solution. :-)
documentclassbook
usepackage[verbose,clear-aux]xsim
usepackagexparse
ExplSyntaxOn
cs_new_protected:Npn pirooh_call_with_one_arg:Nn #1#2
#1 #2
cs_generate_variant:Nn pirooh_call_with_one_arg:Nn Nx
NewDocumentCommand callWithExpandedArg m m
% Perform full expansion on what #2 stands for, then call #1
% with the result.
pirooh_call_with_one_arg:Nx #1 #2
ExplSyntaxOff
newcommand*ExOption5M4
newcommand*ExPartAlgebreFinanciere
callWithExpandedArgDeclareExerciseCollectionExOption_ExPart
begindocument
chapterWhere i want exercises
callWithExpandedArgcollectexercisesExOption_ExPart
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithExpandedArgcollectexercisesstopExOption_ExPart
callWithExpandedArgprintcollectionExOption_ExPart
enddocument
Second solution
Here, the approach is different. There is one command to define per argument value, not per xsim
command such as DeclareExerciseCollection
, collectexercises
, collectexercisesstop
and printcollection
as in David Carlisle's solution. Here, the command callWithPredefinedArg
is defined for the argument value 5M4_AlgebreFinanciere
(you may want to adapt its name).
This solution isn't better than others, it's just different in spirit. The code does full expansion of ExOption
and ExPart
when callWithPredefinedArg
is defined (this could be changed if needed).
documentclassbook
usepackage[verbose,clear-aux]xsim
newcommand*ExOptiondefault
newcommand*ExPartdefault
renewcommand*ExOption5M4
renewcommand*ExPartAlgebreFinanciere
% This recursively expands ExOption and ExPart and “freezes”
% the result in the definition of callWithPredefinedArg.
edefcallWithPredefinedArg#1#1ExOption_ExPart
% Of course, you could achieve the same with:
%defcallWithPredefinedArg#1#15M4_AlgebreFinanciere
callWithPredefinedArgDeclareExerciseCollection
begindocument
chapterWhere i want exercises
callWithPredefinedArgcollectexercises
beginexercise
Can you print me ?
endexercise
beginsolution
Yes, you can !
endsolution
callWithPredefinedArgcollectexercisesstop
callWithPredefinedArgprintcollection
% If you have another chapter/module to start here, you could do
% defcallWithPredefinedArg#1#16N5_GeometrieFinanciere
% callWithPredefinedArgcollectexercises
% etc.
enddocument
edited Jun 15 at 14:05
answered Jun 15 at 13:05
frougonfrougon
3,6851 gold badge9 silver badges18 bronze badges
3,6851 gold badge9 silver badges18 bronze badges
If i understand,callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here :ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefinecallWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !
– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass toxsim
commands (or whatever you use aftercallWithPredefinedArg
) is frozen at the timecallWithPredefinedArg
is defined (I added comments that should clarify this, I hope).
– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near whatxsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to readexpl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !
– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understandingexpl3
code, but well...
– frougon
Jun 15 at 14:38
add a comment |
If i understand,callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here :ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefinecallWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !
– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass toxsim
commands (or whatever you use aftercallWithPredefinedArg
) is frozen at the timecallWithPredefinedArg
is defined (I added comments that should clarify this, I hope).
– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near whatxsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to readexpl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !
– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understandingexpl3
code, but well...
– frougon
Jun 15 at 14:38
If i understand,
callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here : ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefine callWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !– Piroooh
Jun 15 at 13:32
If i understand,
callWithPredefinedArg
act as a "meta" command who allows me to expand the set up argument (here : ExOption_ExPart
). So if i want to add another subdivisions (ExOption_ExPart_ExSubpart
), i have to redefine callWithPredefinedArg
. I think for my purpose it is simpler to work with DavidCarlisle answer. But it's nice to see alternative answer. Thank you !– Piroooh
Jun 15 at 13:32
Yes, that's correct. The argument value to pass to
xsim
commands (or whatever you use after callWithPredefinedArg
) is frozen at the time callWithPredefinedArg
is defined (I added comments that should clarify this, I hope).– frougon
Jun 15 at 13:34
Yes, that's correct. The argument value to pass to
xsim
commands (or whatever you use after callWithPredefinedArg
) is frozen at the time callWithPredefinedArg
is defined (I added comments that should clarify this, I hope).– frougon
Jun 15 at 13:34
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
I added another solution (“First solution”) in the spirit of David Carlisle's one, but “meta”-style as you put it, and based on LaTeX3.
– frougon
Jun 15 at 14:06
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near what
xsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to read expl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !– Piroooh
Jun 15 at 14:32
Nice improve to add the second option. At the moment, the two solutions allows me to attempt what i was looking for and it solves my problem. For the consistency of syntax (near what
xsim
package defines) and because if i had to build other add-on, the David Carlisle's solution is more familiar to me (i'm unable right now to read expl3
syntax), i'll use David Carlisle's solution. Unfortunately i can't accept the two solutions as an answer but thank you for your help !– Piroooh
Jun 15 at 14:32
It's actually a simple enough example to start understanding
expl3
code, but well...– frougon
Jun 15 at 14:38
It's actually a simple enough example to start understanding
expl3
code, but well...– frougon
Jun 15 at 14:38
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%2f495894%2fexpand-command-in-an-argument-before-the-main-command%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