fully expand toks and save for later (appendix with exact copies of tables from the main text)Using nameref within pathHow can I use a variable from xstring with the text along path decoration from tikz?Define macro for sequence/list/tuple macrosHow to store to-be-credited contributors for acknowledgment later in the appendixHow do I expand pgfkeys properly?How can expand a counter of auxiliary file and save in list with xparse?

What are the original Russian words for a prostitute?

What are some further readings in Econometrics you recommend?

Misrepresented my work history

Is there a minimum field size for peah to apply?

Swapping "Good" and "Bad"

What do three diagonal dots above a letter mean in the "Misal rico de Cisneros" (Spain, 1518)?

How to tell someone I'd like to become friends without letting them think I'm romantically interested in them?

Why did Old English lose both thorn and eth?

How to know if blackberries are safe to eat

What's the point of having a RAID 1 configuration over incremental backups to a secondary drive?

Party going through airport security at separate times?

Why different specifications for telescopes and binoculars?

Matrix with arrows and comments

What is the right approach to quit a job during probation period for a competing offer?

Backspace functionality in normal mode

What is this little owl-like bird?

The rigidity of the countable product of free groups

Is it possible to split a vertex?

When an electron changes its spin, or any other intrinsic property, is it still the same electron?

How quality assurance engineers test calculations?

Why did Harry Potter get a bedroom?

Misspelling my name on my mathematical publications

What is the correct parsing of お高くとまる?

What happens when adult Billy Batson says "Shazam"?



fully expand toks and save for later (appendix with exact copies of tables from the main text)


Using nameref within pathHow can I use a variable from xstring with the text along path decoration from tikz?Define macro for sequence/list/tuple macrosHow to store to-be-credited contributors for acknowledgment later in the appendixHow do I expand pgfkeys properly?How can expand a counter of auxiliary file and save in list with xparse?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








4















I have a document with some complex tables, defined by a command called Rule with named parameters (using the keyval package).
The individual rows of the table are first stored into a token list defined via newtoks because some of the named parameters correspond to multiple cells of the table and simultaneously must be enveloped inside an ifcsname condition.
I'd like to force Rule to store a fully expanded copy of the resulting table (with the particular values for each named parameter) so that I can list all rules that appeared anywhere in the document in the appendix.
But I was not able to force the token list to fully expand.



I compile with xetex and cannot change that.




EDIT:
Each table corresponds to a single call of Rule; the named parameters contain the information, and the definition of Rule provides the formatting for each kind of named parameter (most are optional).
I want exactly the same tables in main text and in the appendix: the output should be the same as if I manually copy-pasted all Rule commands from the document into the appendix.




documentclassbook
usepackagexparse,keyval

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter
newtoks@tabtoks
newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
newcommand*resettabtoks@tabtoks
newcommand*printtabtoksthe@tabtoks

edefallrules
edefoldallrulesallrules
newcommand*addtoallrules[1]g@addto@macroallrules#1


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

%% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
%% so instead of spitting out the rows of the table immediately,
%% the content is added to @tabtoks via the command addtabtoks
%% and printed when all parameters are read


DeclareDocumentCommandRulem
begingroup%
setkeysmyKeys#1%reads the key=value pairs
medskipnoindent
begintable
addtabtoksbegintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
addtabtoksmulticolumn2bfmm@header\
else refstepcounterrule
addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
fi
addtabtokshline
ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \fi
ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \fi
addtabtokshline
endtabular
printtabtoks

% %%%%%%%% BEFORE RESETTING @tabtoks, I'D LIKE TO STORE ITS FULLY EXPANDED VALUE
% expandafterlongexpandafteredefexpandaftertmpexpandafterwriteexpandafterthe@tabtoks
% showtmp
% expandafteraddtoallrulesexpandaftertmp
% showallrules

resettabtoks

ifcsname mm@labelendcsname labelmm@labelfi
endtable
smallskip
endgroup%

makeatother

begindocument
Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1,


appendix
allrules
enddocument









share|improve this question
























  • it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

    – David Carlisle
    Jul 1 at 7:06











  • I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

    – frougon
    Jul 1 at 8:47


















4















I have a document with some complex tables, defined by a command called Rule with named parameters (using the keyval package).
The individual rows of the table are first stored into a token list defined via newtoks because some of the named parameters correspond to multiple cells of the table and simultaneously must be enveloped inside an ifcsname condition.
I'd like to force Rule to store a fully expanded copy of the resulting table (with the particular values for each named parameter) so that I can list all rules that appeared anywhere in the document in the appendix.
But I was not able to force the token list to fully expand.



I compile with xetex and cannot change that.




EDIT:
Each table corresponds to a single call of Rule; the named parameters contain the information, and the definition of Rule provides the formatting for each kind of named parameter (most are optional).
I want exactly the same tables in main text and in the appendix: the output should be the same as if I manually copy-pasted all Rule commands from the document into the appendix.




documentclassbook
usepackagexparse,keyval

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter
newtoks@tabtoks
newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
newcommand*resettabtoks@tabtoks
newcommand*printtabtoksthe@tabtoks

edefallrules
edefoldallrulesallrules
newcommand*addtoallrules[1]g@addto@macroallrules#1


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

%% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
%% so instead of spitting out the rows of the table immediately,
%% the content is added to @tabtoks via the command addtabtoks
%% and printed when all parameters are read


DeclareDocumentCommandRulem
begingroup%
setkeysmyKeys#1%reads the key=value pairs
medskipnoindent
begintable
addtabtoksbegintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
addtabtoksmulticolumn2bfmm@header\
else refstepcounterrule
addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
fi
addtabtokshline
ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \fi
ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \fi
addtabtokshline
endtabular
printtabtoks

% %%%%%%%% BEFORE RESETTING @tabtoks, I'D LIKE TO STORE ITS FULLY EXPANDED VALUE
% expandafterlongexpandafteredefexpandaftertmpexpandafterwriteexpandafterthe@tabtoks
% showtmp
% expandafteraddtoallrulesexpandaftertmp
% showallrules

resettabtoks

ifcsname mm@labelendcsname labelmm@labelfi
endtable
smallskip
endgroup%

makeatother

begindocument
Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1,


appendix
allrules
enddocument









share|improve this question
























  • it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

    – David Carlisle
    Jul 1 at 7:06











  • I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

    – frougon
    Jul 1 at 8:47














4












4








4








I have a document with some complex tables, defined by a command called Rule with named parameters (using the keyval package).
The individual rows of the table are first stored into a token list defined via newtoks because some of the named parameters correspond to multiple cells of the table and simultaneously must be enveloped inside an ifcsname condition.
I'd like to force Rule to store a fully expanded copy of the resulting table (with the particular values for each named parameter) so that I can list all rules that appeared anywhere in the document in the appendix.
But I was not able to force the token list to fully expand.



I compile with xetex and cannot change that.




EDIT:
Each table corresponds to a single call of Rule; the named parameters contain the information, and the definition of Rule provides the formatting for each kind of named parameter (most are optional).
I want exactly the same tables in main text and in the appendix: the output should be the same as if I manually copy-pasted all Rule commands from the document into the appendix.




documentclassbook
usepackagexparse,keyval

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter
newtoks@tabtoks
newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
newcommand*resettabtoks@tabtoks
newcommand*printtabtoksthe@tabtoks

edefallrules
edefoldallrulesallrules
newcommand*addtoallrules[1]g@addto@macroallrules#1


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

%% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
%% so instead of spitting out the rows of the table immediately,
%% the content is added to @tabtoks via the command addtabtoks
%% and printed when all parameters are read


DeclareDocumentCommandRulem
begingroup%
setkeysmyKeys#1%reads the key=value pairs
medskipnoindent
begintable
addtabtoksbegintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
addtabtoksmulticolumn2bfmm@header\
else refstepcounterrule
addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
fi
addtabtokshline
ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \fi
ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \fi
addtabtokshline
endtabular
printtabtoks

% %%%%%%%% BEFORE RESETTING @tabtoks, I'D LIKE TO STORE ITS FULLY EXPANDED VALUE
% expandafterlongexpandafteredefexpandaftertmpexpandafterwriteexpandafterthe@tabtoks
% showtmp
% expandafteraddtoallrulesexpandaftertmp
% showallrules

resettabtoks

ifcsname mm@labelendcsname labelmm@labelfi
endtable
smallskip
endgroup%

makeatother

begindocument
Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1,


appendix
allrules
enddocument









share|improve this question
















I have a document with some complex tables, defined by a command called Rule with named parameters (using the keyval package).
The individual rows of the table are first stored into a token list defined via newtoks because some of the named parameters correspond to multiple cells of the table and simultaneously must be enveloped inside an ifcsname condition.
I'd like to force Rule to store a fully expanded copy of the resulting table (with the particular values for each named parameter) so that I can list all rules that appeared anywhere in the document in the appendix.
But I was not able to force the token list to fully expand.



I compile with xetex and cannot change that.




EDIT:
Each table corresponds to a single call of Rule; the named parameters contain the information, and the definition of Rule provides the formatting for each kind of named parameter (most are optional).
I want exactly the same tables in main text and in the appendix: the output should be the same as if I manually copy-pasted all Rule commands from the document into the appendix.




documentclassbook
usepackagexparse,keyval

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter
newtoks@tabtoks
newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
newcommand*resettabtoks@tabtoks
newcommand*printtabtoksthe@tabtoks

edefallrules
edefoldallrulesallrules
newcommand*addtoallrules[1]g@addto@macroallrules#1


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

%% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
%% so instead of spitting out the rows of the table immediately,
%% the content is added to @tabtoks via the command addtabtoks
%% and printed when all parameters are read


DeclareDocumentCommandRulem
begingroup%
setkeysmyKeys#1%reads the key=value pairs
medskipnoindent
begintable
addtabtoksbegintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
addtabtoksmulticolumn2bfmm@header\
else refstepcounterrule
addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
fi
addtabtokshline
ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \fi
ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \fi
addtabtokshline
endtabular
printtabtoks

% %%%%%%%% BEFORE RESETTING @tabtoks, I'D LIKE TO STORE ITS FULLY EXPANDED VALUE
% expandafterlongexpandafteredefexpandaftertmpexpandafterwriteexpandafterthe@tabtoks
% showtmp
% expandafteraddtoallrulesexpandaftertmp
% showallrules

resettabtoks

ifcsname mm@labelendcsname labelmm@labelfi
endtable
smallskip
endgroup%

makeatother

begindocument
Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1,


appendix
allrules
enddocument






expansion token-lists






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 1 at 7:51







Ansa211

















asked Jul 1 at 6:26









Ansa211Ansa211

2661 silver badge7 bronze badges




2661 silver badge7 bronze badges












  • it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

    – David Carlisle
    Jul 1 at 7:06











  • I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

    – frougon
    Jul 1 at 8:47


















  • it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

    – David Carlisle
    Jul 1 at 7:06











  • I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

    – frougon
    Jul 1 at 8:47

















it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

– David Carlisle
Jul 1 at 7:06





it isn't clear what you want to do, most tex commands including begintabular or bf (which should never be used in latex) do not work by expansion so can not be completely expanded in an edef in any meaningful way. What is the actual top level requirement that you want to implement?

– David Carlisle
Jul 1 at 7:06













I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

– frougon
Jul 1 at 8:47






I think many things can be simplified, and expansion doesn't need to happen so early. table creates a float, why do you put medskipnoindent before begintable and smallskip after endtable? Are you sure you want table environments? Without any caption? Do you want the labels to point to the rules in the main text or in the appendix?

– frougon
Jul 1 at 8:47











3 Answers
3






active

oldest

votes


















3














It's not exactly clear what you want the final summary to look like, but this might get you started. As you see, the rules are all collected at the end.



What I do here is create a 2nd token register globaltabtoks in parallel to the one employed by the OP, @tabtoks. Then, I can add pieces-parts of the rules into the globaltabtoks in the manner to construct a summary table. And I don't clear/reset the register between rules! So, for example, rather than setting a row between the title and the content, I merely employ a column separator.



The key is to expand the keys into their text before placing them into the token registers. Here I create addglobaltabtoks to place literal text at the end of the globaltabtoks register, and xaddglobaltabtoks to expand-once the first token of the argument and then append it and the rest of the argument to globaltabtoks.



In the case of therule, I need more than a single expansion to get the desired number, so I used the new TeX primitive expanded in the fashion of



xaddglobaltabtoksexpandedtherule&


However, if your installation does not yet support expanded, one could as an alternative use



edeftmptherule
xaddglobaltabtokstmp&


Here is the MWE:



documentclassbook
usepackage[T1]fontenc
usepackagexparse,keyval

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter
newtoks@tabtoks
newtoksglobaltabtoks
newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
newcommandaddglobaltabtoks[1]%
globalglobaltabtoksexpandaftertheglobaltabtoks#1%

newcommandxaddglobaltabtoks[1]%
expandafteraddglobaltabtoksexpandafter#1%

newcommand*resettabtoks@tabtoks
newcommand*resetglobaltabtoksglobaltabtoks
newcommand*printtabtoksthe@tabtoks

edefallrules
edefoldallrulesallrules
newcommand*addtoallrules[1]g@addto@macroallrules#1


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

%% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
%% so instead of spitting out the rows of the table immediately,
%% the content is added to @tabtoks via the command addtabtoks
%% and printed when all parameters are read


DeclareDocumentCommandRulem
begingroup%
setkeysmyKeys#1%reads the key=value pairs
medskipnoindent
begintable[ht]
addtabtoksbegintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
addtabtoksmulticolumn2bfmm@header\
addglobaltabtoks&
else refstepcounterrule
addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
addglobaltabtoksRule xaddglobaltabtoksexpandedtherule&
fi
addtabtokshline
ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \
xaddglobaltabtoksmm@FUNKTORY \fi
ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \
addglobaltabtoksObligatory &
xaddglobaltabtoksmm@OBLIG \fi
addtabtokshline
endtabular
addglobaltabtokshline
printtabtoks

resettabtoks

ifcsname mm@labelendcsname labelmm@labelfi
endtable
smallskip
endgroup%

makeatother

begindocument
Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1


Rule
header = Rule 2,
FUNKTORY = P & Q,
label = rule:2,


appendix SUMMARY

noindent
begintabularp5cm
hline
theglobaltabtoks
endtabular

enddocument


enter image description here






share|improve this answer

























  • Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

    – Ansa211
    Jul 1 at 12:04











  • If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

    – Ansa211
    Jul 1 at 12:07






  • 1





    @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

    – Steven B. Segletes
    Jul 1 at 12:32












  • @Ansa211 I have added commentary to describe what I did.

    – Steven B. Segletes
    Jul 1 at 12:41











  • @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

    – Steven B. Segletes
    Jul 1 at 12:45


















3














I think what you want is something like what follows. Macros can record many things. Most things. Verbatim material is tricky, but you don't have any here, so you can just record the high-level commands with their arguments in a LaTeX3 sequence and use it in the appendix to replay everything (precisely, in recapallrules). I only had to introduce an indirection level in two places:



  • For the label command: there must be only one label with a given name, so I use mm@set@rule@label in typesetRule. mm@set@rule@label sets a label when used in the main text, but does nothing when used from recapallrules, i.e., in the appendix (the behavior is trivial to change).


  • For the counter incrementation: for the same reason, mm@increment@rule@ctr does refstepcounterrule when used in the main text and stepcounterrule when used from recapallrules (we don't want two different references—places recorded with a label command—for the same value of the rule counter).


I also simplified your code by removing all the addtabtoks-like things, which appear not to be necessary at all (unless proven otherwise!).



documentclassbook
usepackagekeyval
usepackagexparse

newcounterrule
renewcommandtherule[0]Garabicrule

makeatletter

define@keymyKeysnonnumbereddefmm@nonnumbered#1
define@keymyKeyslabeldefmm@label#1
define@keymyKeysheaderdefmm@header#1
define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

newcommand*mm@normal@increment@rule@ctrrefstepcounterrule
newcommand*mm@appendix@increment@rule@ctrstepcounterrule
letmm@increment@rule@ctr=mm@normal@increment@rule@ctr

newcommand*mm@normal@rule@label@cmd%
ifcsname mm@labelendcsname
expandafterlabelexpandaftermm@label%
fi

newcommand*mm@appendix@rule@label@cmd
letmm@set@rule@label=mm@normal@rule@label@cmd

NewDocumentCommandtypesetRulem% don't forget the percent sign here!
begingroup
setkeysmyKeys#1%reads the key=value pairs
mm@set@rule@label
begintabularp5cm
hline
ifcsname mm@nonnumberedendcsname
multicolumn2bfmm@header\
else
multicolumn2%
mm@increment@rule@ctr
bfmm@headerhfill Rule therule \
fi
hline
ifcsname mm@FUNKTORYendcsname
mm@FUNKTORY \
fi
ifcsname mm@OBLIGendcsname
Obligatory & mm@OBLIG \
fi
hline
endtabular%
endgroup


ExplSyntaxOn % Use LaTeX3-style input syntax (see expl3.pdf)

seq_new:N g_mm_rules_seq

NewDocumentCommand Rule m

seq_gput_right:Nn g_mm_rules_seq typesetRule #1
medskipnoindent
typesetRule #1


% Programming-level function
cs_new_protected:Npn mm_recap_all_rules:

group_begin: % limit effect of the cs_set_eq:NN
setcounter rule 0 % reset the rule counter
% Special version of two commands for use here (we used different versions
% in the main text). Note that cs_set_eq:NN is like let.
cs_set_eq:NN mm@increment@rule@ctr mm@appendix@increment@rule@ctr
cs_set_eq:NN mm@set@rule@label mm@appendix@rule@label@cmd
% Use all elements we've recorded, separated using the provided separator
seq_use:Nn g_mm_rules_seq par medskip noindent % separator
group_end:


% User-level function
NewDocumentCommand recapallrules

mm_recap_all_rules:


ExplSyntaxOff % end of LaTeX3-style input syntax

makeatother

begindocument

Rule
nonnumbered = yes,
header = Rules in general,
FUNKTORY = VALUE 1 & VALUE 2,


Rule
header = Rule 1,
FUNKTORY = X & Y,
label = rule:1,


Rule
header = Rule 2,
FUNKTORY = Z & T,
label = rule:2,


appendix

chapterAll rules

recapallrules

enddocument


On page 1:



On page 1



Appendix:



Appendix






share|improve this answer
































    3














    I wouldn't mix “legacy” programming with expl3. With careful usage of variants, it's easy to control what gets expanded and what doesn't.



    documentclassbook
    usepackagexparse

    newcounterrule
    renewcommandtherule[0]Garabicrule

    ExplSyntaxOn

    NewDocumentCommandRulem

    group_begin:
    tl_clear:N l__ansa_rule_body_tl
    keys_set:nn ansa/rule #1
    __ansa_rule:
    tl_gput_right:NV g__ansa_rule_all_tl l__ansa_rule_body_tl
    tl_gput_right:Nn g__ansa_rule_all_tl parbigskip
    group_end:

    NewDocumentCommandallrules

    begincenter
    cs_set_eq:NN __ansa_rule_label:n use_none:n
    tl_use:N g__ansa_rule_all_tl
    endcenter


    tl_new:N l__ansa_rule_body_tl
    tl_new:N g__ansa_rule_all_tl

    keys_define:nn ansa/rule

    nonnumbered .bool_set:N = l__ansa_rule_nonnumbered_bool,
    nonnumbered .default:n = true,
    nonnumbered .initial:n = false,
    label .tl_set:N = l__ansa_rule_label_tl,
    header .tl_set:N = l__ansa_rule_header_tl,
    FUNKTORY .tl_set:N = l__ansa_rule_funktory_tl,
    OBLIG .tl_set:N = l__ansa_rule_oblig_tl,


    cs_new_protected:Nn __ansa_rule:

    __ansa_rule_add:n begintabularp5cmhline
    bool_if:NTF l__ansa_rule_nonnumbered_bool

    __ansa_rule_add_multi:V l__ansa_rule_header_tl


    refstepcounterrule
    tl_if_empty:NF l__ansa_rule_label_tl __ansa_rule_label:n l__ansa_rule_label_tl
    __ansa_rule_add_multi_number:Vx l__ansa_rule_header_tl therule

    __ansa_rule_add:n hline
    tl_if_empty:NF l__ansa_rule_funktory_tl

    __ansa_rule_add:V l__ansa_rule_funktory_tl
    __ansa_rule_add:n \

    tl_if_empty:NF l__ansa_rule_oblig_tl

    __ansa_rule_add:V l__ansa_rule_oblig_tl
    __ansa_rule_add:n \

    __ansa_rule_add:n hlineendtabular
    tl_use:N l__ansa_rule_body_tl


    cs_new:Nn __ansa_rule_label:n label#1

    cs_new_protected:Nn __ansa_rule_add:n

    tl_put_right:Nn l__ansa_rule_body_tl #1

    cs_generate_variant:Nn __ansa_rule_add:n V

    cs_new_protected:Nn __ansa_rule_add_multi_number:nn

    __ansa_rule_add:n multicolumn2bfseries#1hfill Rule~#2 \

    cs_generate_variant:Nn __ansa_rule_add_multi_number:nn Vx

    cs_new_protected:Nn __ansa_rule_add_multi:n

    __ansa_rule_add:n multicolumn2bfseries#1 \

    cs_generate_variant:Nn __ansa_rule_add_multi:n V

    ExplSyntaxOff

    begindocument

    Rule
    nonnumbered,
    header = Rules in general,
    FUNKTORY = VALUE 1 & VALUE 2,


    Rule
    header = Rule 1,
    FUNKTORY = X & Y,
    label = rule:1,


    allrules

    enddocument


    enter image description here






    share|improve this answer

























      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
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f498155%2ffully-expand-toks-and-save-for-later-appendix-with-exact-copies-of-tables-from%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









      3














      It's not exactly clear what you want the final summary to look like, but this might get you started. As you see, the rules are all collected at the end.



      What I do here is create a 2nd token register globaltabtoks in parallel to the one employed by the OP, @tabtoks. Then, I can add pieces-parts of the rules into the globaltabtoks in the manner to construct a summary table. And I don't clear/reset the register between rules! So, for example, rather than setting a row between the title and the content, I merely employ a column separator.



      The key is to expand the keys into their text before placing them into the token registers. Here I create addglobaltabtoks to place literal text at the end of the globaltabtoks register, and xaddglobaltabtoks to expand-once the first token of the argument and then append it and the rest of the argument to globaltabtoks.



      In the case of therule, I need more than a single expansion to get the desired number, so I used the new TeX primitive expanded in the fashion of



      xaddglobaltabtoksexpandedtherule&


      However, if your installation does not yet support expanded, one could as an alternative use



      edeftmptherule
      xaddglobaltabtokstmp&


      Here is the MWE:



      documentclassbook
      usepackage[T1]fontenc
      usepackagexparse,keyval

      newcounterrule
      renewcommandtherule[0]Garabicrule

      makeatletter
      newtoks@tabtoks
      newtoksglobaltabtoks
      newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
      newcommandaddglobaltabtoks[1]%
      globalglobaltabtoksexpandaftertheglobaltabtoks#1%

      newcommandxaddglobaltabtoks[1]%
      expandafteraddglobaltabtoksexpandafter#1%

      newcommand*resettabtoks@tabtoks
      newcommand*resetglobaltabtoksglobaltabtoks
      newcommand*printtabtoksthe@tabtoks

      edefallrules
      edefoldallrulesallrules
      newcommand*addtoallrules[1]g@addto@macroallrules#1


      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      define@keymyKeysnonnumbereddefmm@nonnumbered#1
      define@keymyKeyslabeldefmm@label#1
      define@keymyKeysheaderdefmm@header#1
      define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

      %% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
      %% so instead of spitting out the rows of the table immediately,
      %% the content is added to @tabtoks via the command addtabtoks
      %% and printed when all parameters are read


      DeclareDocumentCommandRulem
      begingroup%
      setkeysmyKeys#1%reads the key=value pairs
      medskipnoindent
      begintable[ht]
      addtabtoksbegintabularp5cm
      hline
      ifcsname mm@nonnumberedendcsname
      addtabtoksmulticolumn2bfmm@header\
      addglobaltabtoks&
      else refstepcounterrule
      addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
      addglobaltabtoksRule xaddglobaltabtoksexpandedtherule&
      fi
      addtabtokshline
      ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \
      xaddglobaltabtoksmm@FUNKTORY \fi
      ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \
      addglobaltabtoksObligatory &
      xaddglobaltabtoksmm@OBLIG \fi
      addtabtokshline
      endtabular
      addglobaltabtokshline
      printtabtoks

      resettabtoks

      ifcsname mm@labelendcsname labelmm@labelfi
      endtable
      smallskip
      endgroup%

      makeatother

      begindocument
      Rule
      nonnumbered = yes,
      header = Rules in general,
      FUNKTORY = VALUE 1 & VALUE 2,


      Rule
      header = Rule 1,
      FUNKTORY = X & Y,
      label = rule:1


      Rule
      header = Rule 2,
      FUNKTORY = P & Q,
      label = rule:2,


      appendix SUMMARY

      noindent
      begintabularp5cm
      hline
      theglobaltabtoks
      endtabular

      enddocument


      enter image description here






      share|improve this answer

























      • Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

        – Ansa211
        Jul 1 at 12:04











      • If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

        – Ansa211
        Jul 1 at 12:07






      • 1





        @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

        – Steven B. Segletes
        Jul 1 at 12:32












      • @Ansa211 I have added commentary to describe what I did.

        – Steven B. Segletes
        Jul 1 at 12:41











      • @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

        – Steven B. Segletes
        Jul 1 at 12:45















      3














      It's not exactly clear what you want the final summary to look like, but this might get you started. As you see, the rules are all collected at the end.



      What I do here is create a 2nd token register globaltabtoks in parallel to the one employed by the OP, @tabtoks. Then, I can add pieces-parts of the rules into the globaltabtoks in the manner to construct a summary table. And I don't clear/reset the register between rules! So, for example, rather than setting a row between the title and the content, I merely employ a column separator.



      The key is to expand the keys into their text before placing them into the token registers. Here I create addglobaltabtoks to place literal text at the end of the globaltabtoks register, and xaddglobaltabtoks to expand-once the first token of the argument and then append it and the rest of the argument to globaltabtoks.



      In the case of therule, I need more than a single expansion to get the desired number, so I used the new TeX primitive expanded in the fashion of



      xaddglobaltabtoksexpandedtherule&


      However, if your installation does not yet support expanded, one could as an alternative use



      edeftmptherule
      xaddglobaltabtokstmp&


      Here is the MWE:



      documentclassbook
      usepackage[T1]fontenc
      usepackagexparse,keyval

      newcounterrule
      renewcommandtherule[0]Garabicrule

      makeatletter
      newtoks@tabtoks
      newtoksglobaltabtoks
      newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
      newcommandaddglobaltabtoks[1]%
      globalglobaltabtoksexpandaftertheglobaltabtoks#1%

      newcommandxaddglobaltabtoks[1]%
      expandafteraddglobaltabtoksexpandafter#1%

      newcommand*resettabtoks@tabtoks
      newcommand*resetglobaltabtoksglobaltabtoks
      newcommand*printtabtoksthe@tabtoks

      edefallrules
      edefoldallrulesallrules
      newcommand*addtoallrules[1]g@addto@macroallrules#1


      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      define@keymyKeysnonnumbereddefmm@nonnumbered#1
      define@keymyKeyslabeldefmm@label#1
      define@keymyKeysheaderdefmm@header#1
      define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

      %% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
      %% so instead of spitting out the rows of the table immediately,
      %% the content is added to @tabtoks via the command addtabtoks
      %% and printed when all parameters are read


      DeclareDocumentCommandRulem
      begingroup%
      setkeysmyKeys#1%reads the key=value pairs
      medskipnoindent
      begintable[ht]
      addtabtoksbegintabularp5cm
      hline
      ifcsname mm@nonnumberedendcsname
      addtabtoksmulticolumn2bfmm@header\
      addglobaltabtoks&
      else refstepcounterrule
      addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
      addglobaltabtoksRule xaddglobaltabtoksexpandedtherule&
      fi
      addtabtokshline
      ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \
      xaddglobaltabtoksmm@FUNKTORY \fi
      ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \
      addglobaltabtoksObligatory &
      xaddglobaltabtoksmm@OBLIG \fi
      addtabtokshline
      endtabular
      addglobaltabtokshline
      printtabtoks

      resettabtoks

      ifcsname mm@labelendcsname labelmm@labelfi
      endtable
      smallskip
      endgroup%

      makeatother

      begindocument
      Rule
      nonnumbered = yes,
      header = Rules in general,
      FUNKTORY = VALUE 1 & VALUE 2,


      Rule
      header = Rule 1,
      FUNKTORY = X & Y,
      label = rule:1


      Rule
      header = Rule 2,
      FUNKTORY = P & Q,
      label = rule:2,


      appendix SUMMARY

      noindent
      begintabularp5cm
      hline
      theglobaltabtoks
      endtabular

      enddocument


      enter image description here






      share|improve this answer

























      • Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

        – Ansa211
        Jul 1 at 12:04











      • If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

        – Ansa211
        Jul 1 at 12:07






      • 1





        @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

        – Steven B. Segletes
        Jul 1 at 12:32












      • @Ansa211 I have added commentary to describe what I did.

        – Steven B. Segletes
        Jul 1 at 12:41











      • @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

        – Steven B. Segletes
        Jul 1 at 12:45













      3












      3








      3







      It's not exactly clear what you want the final summary to look like, but this might get you started. As you see, the rules are all collected at the end.



      What I do here is create a 2nd token register globaltabtoks in parallel to the one employed by the OP, @tabtoks. Then, I can add pieces-parts of the rules into the globaltabtoks in the manner to construct a summary table. And I don't clear/reset the register between rules! So, for example, rather than setting a row between the title and the content, I merely employ a column separator.



      The key is to expand the keys into their text before placing them into the token registers. Here I create addglobaltabtoks to place literal text at the end of the globaltabtoks register, and xaddglobaltabtoks to expand-once the first token of the argument and then append it and the rest of the argument to globaltabtoks.



      In the case of therule, I need more than a single expansion to get the desired number, so I used the new TeX primitive expanded in the fashion of



      xaddglobaltabtoksexpandedtherule&


      However, if your installation does not yet support expanded, one could as an alternative use



      edeftmptherule
      xaddglobaltabtokstmp&


      Here is the MWE:



      documentclassbook
      usepackage[T1]fontenc
      usepackagexparse,keyval

      newcounterrule
      renewcommandtherule[0]Garabicrule

      makeatletter
      newtoks@tabtoks
      newtoksglobaltabtoks
      newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
      newcommandaddglobaltabtoks[1]%
      globalglobaltabtoksexpandaftertheglobaltabtoks#1%

      newcommandxaddglobaltabtoks[1]%
      expandafteraddglobaltabtoksexpandafter#1%

      newcommand*resettabtoks@tabtoks
      newcommand*resetglobaltabtoksglobaltabtoks
      newcommand*printtabtoksthe@tabtoks

      edefallrules
      edefoldallrulesallrules
      newcommand*addtoallrules[1]g@addto@macroallrules#1


      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      define@keymyKeysnonnumbereddefmm@nonnumbered#1
      define@keymyKeyslabeldefmm@label#1
      define@keymyKeysheaderdefmm@header#1
      define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

      %% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
      %% so instead of spitting out the rows of the table immediately,
      %% the content is added to @tabtoks via the command addtabtoks
      %% and printed when all parameters are read


      DeclareDocumentCommandRulem
      begingroup%
      setkeysmyKeys#1%reads the key=value pairs
      medskipnoindent
      begintable[ht]
      addtabtoksbegintabularp5cm
      hline
      ifcsname mm@nonnumberedendcsname
      addtabtoksmulticolumn2bfmm@header\
      addglobaltabtoks&
      else refstepcounterrule
      addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
      addglobaltabtoksRule xaddglobaltabtoksexpandedtherule&
      fi
      addtabtokshline
      ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \
      xaddglobaltabtoksmm@FUNKTORY \fi
      ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \
      addglobaltabtoksObligatory &
      xaddglobaltabtoksmm@OBLIG \fi
      addtabtokshline
      endtabular
      addglobaltabtokshline
      printtabtoks

      resettabtoks

      ifcsname mm@labelendcsname labelmm@labelfi
      endtable
      smallskip
      endgroup%

      makeatother

      begindocument
      Rule
      nonnumbered = yes,
      header = Rules in general,
      FUNKTORY = VALUE 1 & VALUE 2,


      Rule
      header = Rule 1,
      FUNKTORY = X & Y,
      label = rule:1


      Rule
      header = Rule 2,
      FUNKTORY = P & Q,
      label = rule:2,


      appendix SUMMARY

      noindent
      begintabularp5cm
      hline
      theglobaltabtoks
      endtabular

      enddocument


      enter image description here






      share|improve this answer















      It's not exactly clear what you want the final summary to look like, but this might get you started. As you see, the rules are all collected at the end.



      What I do here is create a 2nd token register globaltabtoks in parallel to the one employed by the OP, @tabtoks. Then, I can add pieces-parts of the rules into the globaltabtoks in the manner to construct a summary table. And I don't clear/reset the register between rules! So, for example, rather than setting a row between the title and the content, I merely employ a column separator.



      The key is to expand the keys into their text before placing them into the token registers. Here I create addglobaltabtoks to place literal text at the end of the globaltabtoks register, and xaddglobaltabtoks to expand-once the first token of the argument and then append it and the rest of the argument to globaltabtoks.



      In the case of therule, I need more than a single expansion to get the desired number, so I used the new TeX primitive expanded in the fashion of



      xaddglobaltabtoksexpandedtherule&


      However, if your installation does not yet support expanded, one could as an alternative use



      edeftmptherule
      xaddglobaltabtokstmp&


      Here is the MWE:



      documentclassbook
      usepackage[T1]fontenc
      usepackagexparse,keyval

      newcounterrule
      renewcommandtherule[0]Garabicrule

      makeatletter
      newtoks@tabtoks
      newtoksglobaltabtoks
      newcommandaddtabtoks[1]@tabtoksexpandafterthe@tabtoks#1
      newcommandaddglobaltabtoks[1]%
      globalglobaltabtoksexpandaftertheglobaltabtoks#1%

      newcommandxaddglobaltabtoks[1]%
      expandafteraddglobaltabtoksexpandafter#1%

      newcommand*resettabtoks@tabtoks
      newcommand*resetglobaltabtoksglobaltabtoks
      newcommand*printtabtoksthe@tabtoks

      edefallrules
      edefoldallrulesallrules
      newcommand*addtoallrules[1]g@addto@macroallrules#1


      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PARAMETERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

      define@keymyKeysnonnumbereddefmm@nonnumbered#1
      define@keymyKeyslabeldefmm@label#1
      define@keymyKeysheaderdefmm@header#1
      define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

      %% one ifcsname cannot directly generate more than a single table cell (problems with & and \ characters)
      %% so instead of spitting out the rows of the table immediately,
      %% the content is added to @tabtoks via the command addtabtoks
      %% and printed when all parameters are read


      DeclareDocumentCommandRulem
      begingroup%
      setkeysmyKeys#1%reads the key=value pairs
      medskipnoindent
      begintable[ht]
      addtabtoksbegintabularp5cm
      hline
      ifcsname mm@nonnumberedendcsname
      addtabtoksmulticolumn2bfmm@header\
      addglobaltabtoks&
      else refstepcounterrule
      addtabtoksmulticolumn2bfmm@headerhfill Rule therule \
      addglobaltabtoksRule xaddglobaltabtoksexpandedtherule&
      fi
      addtabtokshline
      ifcsname mm@FUNKTORYendcsname addtabtoksmm@FUNKTORY \
      xaddglobaltabtoksmm@FUNKTORY \fi
      ifcsname mm@OBLIGendcsname addtabtoksObligatory & mm@OBLIG \
      addglobaltabtoksObligatory &
      xaddglobaltabtoksmm@OBLIG \fi
      addtabtokshline
      endtabular
      addglobaltabtokshline
      printtabtoks

      resettabtoks

      ifcsname mm@labelendcsname labelmm@labelfi
      endtable
      smallskip
      endgroup%

      makeatother

      begindocument
      Rule
      nonnumbered = yes,
      header = Rules in general,
      FUNKTORY = VALUE 1 & VALUE 2,


      Rule
      header = Rule 1,
      FUNKTORY = X & Y,
      label = rule:1


      Rule
      header = Rule 2,
      FUNKTORY = P & Q,
      label = rule:2,


      appendix SUMMARY

      noindent
      begintabularp5cm
      hline
      theglobaltabtoks
      endtabular

      enddocument


      enter image description here







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Jul 1 at 12:47

























      answered Jul 1 at 9:33









      Steven B. SegletesSteven B. Segletes

      167k9 gold badges213 silver badges430 bronze badges




      167k9 gold badges213 silver badges430 bronze badges












      • Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

        – Ansa211
        Jul 1 at 12:04











      • If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

        – Ansa211
        Jul 1 at 12:07






      • 1





        @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

        – Steven B. Segletes
        Jul 1 at 12:32












      • @Ansa211 I have added commentary to describe what I did.

        – Steven B. Segletes
        Jul 1 at 12:41











      • @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

        – Steven B. Segletes
        Jul 1 at 12:45

















      • Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

        – Ansa211
        Jul 1 at 12:04











      • If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

        – Ansa211
        Jul 1 at 12:07






      • 1





        @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

        – Steven B. Segletes
        Jul 1 at 12:32












      • @Ansa211 I have added commentary to describe what I did.

        – Steven B. Segletes
        Jul 1 at 12:41











      • @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

        – Steven B. Segletes
        Jul 1 at 12:45
















      Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

      – Ansa211
      Jul 1 at 12:04





      Nice idea to construct a summary table! I have a vague idea that the trick is that the outer command xaddglobaltabtoks feeds an already expanded argument into the inner command addglobaltabtoks which cares for maintaining the global value of globaltabtoks, but if you could explain it a little further, it would be great.

      – Ansa211
      Jul 1 at 12:04













      If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

      – Ansa211
      Jul 1 at 12:07





      If I place your code into a file and compile with xelatex, it gives me ! Undefined control sequence. <argument> expanded (newline and indent) ` therule & l.85 }`

      – Ansa211
      Jul 1 at 12:07




      1




      1





      @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

      – Steven B. Segletes
      Jul 1 at 12:32






      @Ansa211 expanded is a new TeX primitive that has just been introduced to the language within the last 6 months or so. It basically allows you to fully expand its argument in an expandable context. You have two choices: 1) upgrade your latex installation to the latest version, or 2) replace that code with edeftmptherulexaddglobaltabtokstmp&}. Note the presence of the edef makes this latter code non-expandable.

      – Steven B. Segletes
      Jul 1 at 12:32














      @Ansa211 I have added commentary to describe what I did.

      – Steven B. Segletes
      Jul 1 at 12:41





      @Ansa211 I have added commentary to describe what I did.

      – Steven B. Segletes
      Jul 1 at 12:41













      @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

      – Steven B. Segletes
      Jul 1 at 12:45





      @Ansa211 Note, if the summary table gets too big to fit on a page, just change the summary tabular to the comparable syntax for longtable.

      – Steven B. Segletes
      Jul 1 at 12:45













      3














      I think what you want is something like what follows. Macros can record many things. Most things. Verbatim material is tricky, but you don't have any here, so you can just record the high-level commands with their arguments in a LaTeX3 sequence and use it in the appendix to replay everything (precisely, in recapallrules). I only had to introduce an indirection level in two places:



      • For the label command: there must be only one label with a given name, so I use mm@set@rule@label in typesetRule. mm@set@rule@label sets a label when used in the main text, but does nothing when used from recapallrules, i.e., in the appendix (the behavior is trivial to change).


      • For the counter incrementation: for the same reason, mm@increment@rule@ctr does refstepcounterrule when used in the main text and stepcounterrule when used from recapallrules (we don't want two different references—places recorded with a label command—for the same value of the rule counter).


      I also simplified your code by removing all the addtabtoks-like things, which appear not to be necessary at all (unless proven otherwise!).



      documentclassbook
      usepackagekeyval
      usepackagexparse

      newcounterrule
      renewcommandtherule[0]Garabicrule

      makeatletter

      define@keymyKeysnonnumbereddefmm@nonnumbered#1
      define@keymyKeyslabeldefmm@label#1
      define@keymyKeysheaderdefmm@header#1
      define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

      newcommand*mm@normal@increment@rule@ctrrefstepcounterrule
      newcommand*mm@appendix@increment@rule@ctrstepcounterrule
      letmm@increment@rule@ctr=mm@normal@increment@rule@ctr

      newcommand*mm@normal@rule@label@cmd%
      ifcsname mm@labelendcsname
      expandafterlabelexpandaftermm@label%
      fi

      newcommand*mm@appendix@rule@label@cmd
      letmm@set@rule@label=mm@normal@rule@label@cmd

      NewDocumentCommandtypesetRulem% don't forget the percent sign here!
      begingroup
      setkeysmyKeys#1%reads the key=value pairs
      mm@set@rule@label
      begintabularp5cm
      hline
      ifcsname mm@nonnumberedendcsname
      multicolumn2bfmm@header\
      else
      multicolumn2%
      mm@increment@rule@ctr
      bfmm@headerhfill Rule therule \
      fi
      hline
      ifcsname mm@FUNKTORYendcsname
      mm@FUNKTORY \
      fi
      ifcsname mm@OBLIGendcsname
      Obligatory & mm@OBLIG \
      fi
      hline
      endtabular%
      endgroup


      ExplSyntaxOn % Use LaTeX3-style input syntax (see expl3.pdf)

      seq_new:N g_mm_rules_seq

      NewDocumentCommand Rule m

      seq_gput_right:Nn g_mm_rules_seq typesetRule #1
      medskipnoindent
      typesetRule #1


      % Programming-level function
      cs_new_protected:Npn mm_recap_all_rules:

      group_begin: % limit effect of the cs_set_eq:NN
      setcounter rule 0 % reset the rule counter
      % Special version of two commands for use here (we used different versions
      % in the main text). Note that cs_set_eq:NN is like let.
      cs_set_eq:NN mm@increment@rule@ctr mm@appendix@increment@rule@ctr
      cs_set_eq:NN mm@set@rule@label mm@appendix@rule@label@cmd
      % Use all elements we've recorded, separated using the provided separator
      seq_use:Nn g_mm_rules_seq par medskip noindent % separator
      group_end:


      % User-level function
      NewDocumentCommand recapallrules

      mm_recap_all_rules:


      ExplSyntaxOff % end of LaTeX3-style input syntax

      makeatother

      begindocument

      Rule
      nonnumbered = yes,
      header = Rules in general,
      FUNKTORY = VALUE 1 & VALUE 2,


      Rule
      header = Rule 1,
      FUNKTORY = X & Y,
      label = rule:1,


      Rule
      header = Rule 2,
      FUNKTORY = Z & T,
      label = rule:2,


      appendix

      chapterAll rules

      recapallrules

      enddocument


      On page 1:



      On page 1



      Appendix:



      Appendix






      share|improve this answer





























        3














        I think what you want is something like what follows. Macros can record many things. Most things. Verbatim material is tricky, but you don't have any here, so you can just record the high-level commands with their arguments in a LaTeX3 sequence and use it in the appendix to replay everything (precisely, in recapallrules). I only had to introduce an indirection level in two places:



        • For the label command: there must be only one label with a given name, so I use mm@set@rule@label in typesetRule. mm@set@rule@label sets a label when used in the main text, but does nothing when used from recapallrules, i.e., in the appendix (the behavior is trivial to change).


        • For the counter incrementation: for the same reason, mm@increment@rule@ctr does refstepcounterrule when used in the main text and stepcounterrule when used from recapallrules (we don't want two different references—places recorded with a label command—for the same value of the rule counter).


        I also simplified your code by removing all the addtabtoks-like things, which appear not to be necessary at all (unless proven otherwise!).



        documentclassbook
        usepackagekeyval
        usepackagexparse

        newcounterrule
        renewcommandtherule[0]Garabicrule

        makeatletter

        define@keymyKeysnonnumbereddefmm@nonnumbered#1
        define@keymyKeyslabeldefmm@label#1
        define@keymyKeysheaderdefmm@header#1
        define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

        newcommand*mm@normal@increment@rule@ctrrefstepcounterrule
        newcommand*mm@appendix@increment@rule@ctrstepcounterrule
        letmm@increment@rule@ctr=mm@normal@increment@rule@ctr

        newcommand*mm@normal@rule@label@cmd%
        ifcsname mm@labelendcsname
        expandafterlabelexpandaftermm@label%
        fi

        newcommand*mm@appendix@rule@label@cmd
        letmm@set@rule@label=mm@normal@rule@label@cmd

        NewDocumentCommandtypesetRulem% don't forget the percent sign here!
        begingroup
        setkeysmyKeys#1%reads the key=value pairs
        mm@set@rule@label
        begintabularp5cm
        hline
        ifcsname mm@nonnumberedendcsname
        multicolumn2bfmm@header\
        else
        multicolumn2%
        mm@increment@rule@ctr
        bfmm@headerhfill Rule therule \
        fi
        hline
        ifcsname mm@FUNKTORYendcsname
        mm@FUNKTORY \
        fi
        ifcsname mm@OBLIGendcsname
        Obligatory & mm@OBLIG \
        fi
        hline
        endtabular%
        endgroup


        ExplSyntaxOn % Use LaTeX3-style input syntax (see expl3.pdf)

        seq_new:N g_mm_rules_seq

        NewDocumentCommand Rule m

        seq_gput_right:Nn g_mm_rules_seq typesetRule #1
        medskipnoindent
        typesetRule #1


        % Programming-level function
        cs_new_protected:Npn mm_recap_all_rules:

        group_begin: % limit effect of the cs_set_eq:NN
        setcounter rule 0 % reset the rule counter
        % Special version of two commands for use here (we used different versions
        % in the main text). Note that cs_set_eq:NN is like let.
        cs_set_eq:NN mm@increment@rule@ctr mm@appendix@increment@rule@ctr
        cs_set_eq:NN mm@set@rule@label mm@appendix@rule@label@cmd
        % Use all elements we've recorded, separated using the provided separator
        seq_use:Nn g_mm_rules_seq par medskip noindent % separator
        group_end:


        % User-level function
        NewDocumentCommand recapallrules

        mm_recap_all_rules:


        ExplSyntaxOff % end of LaTeX3-style input syntax

        makeatother

        begindocument

        Rule
        nonnumbered = yes,
        header = Rules in general,
        FUNKTORY = VALUE 1 & VALUE 2,


        Rule
        header = Rule 1,
        FUNKTORY = X & Y,
        label = rule:1,


        Rule
        header = Rule 2,
        FUNKTORY = Z & T,
        label = rule:2,


        appendix

        chapterAll rules

        recapallrules

        enddocument


        On page 1:



        On page 1



        Appendix:



        Appendix






        share|improve this answer



























          3












          3








          3







          I think what you want is something like what follows. Macros can record many things. Most things. Verbatim material is tricky, but you don't have any here, so you can just record the high-level commands with their arguments in a LaTeX3 sequence and use it in the appendix to replay everything (precisely, in recapallrules). I only had to introduce an indirection level in two places:



          • For the label command: there must be only one label with a given name, so I use mm@set@rule@label in typesetRule. mm@set@rule@label sets a label when used in the main text, but does nothing when used from recapallrules, i.e., in the appendix (the behavior is trivial to change).


          • For the counter incrementation: for the same reason, mm@increment@rule@ctr does refstepcounterrule when used in the main text and stepcounterrule when used from recapallrules (we don't want two different references—places recorded with a label command—for the same value of the rule counter).


          I also simplified your code by removing all the addtabtoks-like things, which appear not to be necessary at all (unless proven otherwise!).



          documentclassbook
          usepackagekeyval
          usepackagexparse

          newcounterrule
          renewcommandtherule[0]Garabicrule

          makeatletter

          define@keymyKeysnonnumbereddefmm@nonnumbered#1
          define@keymyKeyslabeldefmm@label#1
          define@keymyKeysheaderdefmm@header#1
          define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

          newcommand*mm@normal@increment@rule@ctrrefstepcounterrule
          newcommand*mm@appendix@increment@rule@ctrstepcounterrule
          letmm@increment@rule@ctr=mm@normal@increment@rule@ctr

          newcommand*mm@normal@rule@label@cmd%
          ifcsname mm@labelendcsname
          expandafterlabelexpandaftermm@label%
          fi

          newcommand*mm@appendix@rule@label@cmd
          letmm@set@rule@label=mm@normal@rule@label@cmd

          NewDocumentCommandtypesetRulem% don't forget the percent sign here!
          begingroup
          setkeysmyKeys#1%reads the key=value pairs
          mm@set@rule@label
          begintabularp5cm
          hline
          ifcsname mm@nonnumberedendcsname
          multicolumn2bfmm@header\
          else
          multicolumn2%
          mm@increment@rule@ctr
          bfmm@headerhfill Rule therule \
          fi
          hline
          ifcsname mm@FUNKTORYendcsname
          mm@FUNKTORY \
          fi
          ifcsname mm@OBLIGendcsname
          Obligatory & mm@OBLIG \
          fi
          hline
          endtabular%
          endgroup


          ExplSyntaxOn % Use LaTeX3-style input syntax (see expl3.pdf)

          seq_new:N g_mm_rules_seq

          NewDocumentCommand Rule m

          seq_gput_right:Nn g_mm_rules_seq typesetRule #1
          medskipnoindent
          typesetRule #1


          % Programming-level function
          cs_new_protected:Npn mm_recap_all_rules:

          group_begin: % limit effect of the cs_set_eq:NN
          setcounter rule 0 % reset the rule counter
          % Special version of two commands for use here (we used different versions
          % in the main text). Note that cs_set_eq:NN is like let.
          cs_set_eq:NN mm@increment@rule@ctr mm@appendix@increment@rule@ctr
          cs_set_eq:NN mm@set@rule@label mm@appendix@rule@label@cmd
          % Use all elements we've recorded, separated using the provided separator
          seq_use:Nn g_mm_rules_seq par medskip noindent % separator
          group_end:


          % User-level function
          NewDocumentCommand recapallrules

          mm_recap_all_rules:


          ExplSyntaxOff % end of LaTeX3-style input syntax

          makeatother

          begindocument

          Rule
          nonnumbered = yes,
          header = Rules in general,
          FUNKTORY = VALUE 1 & VALUE 2,


          Rule
          header = Rule 1,
          FUNKTORY = X & Y,
          label = rule:1,


          Rule
          header = Rule 2,
          FUNKTORY = Z & T,
          label = rule:2,


          appendix

          chapterAll rules

          recapallrules

          enddocument


          On page 1:



          On page 1



          Appendix:



          Appendix






          share|improve this answer















          I think what you want is something like what follows. Macros can record many things. Most things. Verbatim material is tricky, but you don't have any here, so you can just record the high-level commands with their arguments in a LaTeX3 sequence and use it in the appendix to replay everything (precisely, in recapallrules). I only had to introduce an indirection level in two places:



          • For the label command: there must be only one label with a given name, so I use mm@set@rule@label in typesetRule. mm@set@rule@label sets a label when used in the main text, but does nothing when used from recapallrules, i.e., in the appendix (the behavior is trivial to change).


          • For the counter incrementation: for the same reason, mm@increment@rule@ctr does refstepcounterrule when used in the main text and stepcounterrule when used from recapallrules (we don't want two different references—places recorded with a label command—for the same value of the rule counter).


          I also simplified your code by removing all the addtabtoks-like things, which appear not to be necessary at all (unless proven otherwise!).



          documentclassbook
          usepackagekeyval
          usepackagexparse

          newcounterrule
          renewcommandtherule[0]Garabicrule

          makeatletter

          define@keymyKeysnonnumbereddefmm@nonnumbered#1
          define@keymyKeyslabeldefmm@label#1
          define@keymyKeysheaderdefmm@header#1
          define@keymyKeysFUNKTORYdefmm@FUNKTORY#1

          newcommand*mm@normal@increment@rule@ctrrefstepcounterrule
          newcommand*mm@appendix@increment@rule@ctrstepcounterrule
          letmm@increment@rule@ctr=mm@normal@increment@rule@ctr

          newcommand*mm@normal@rule@label@cmd%
          ifcsname mm@labelendcsname
          expandafterlabelexpandaftermm@label%
          fi

          newcommand*mm@appendix@rule@label@cmd
          letmm@set@rule@label=mm@normal@rule@label@cmd

          NewDocumentCommandtypesetRulem% don't forget the percent sign here!
          begingroup
          setkeysmyKeys#1%reads the key=value pairs
          mm@set@rule@label
          begintabularp5cm
          hline
          ifcsname mm@nonnumberedendcsname
          multicolumn2bfmm@header\
          else
          multicolumn2%
          mm@increment@rule@ctr
          bfmm@headerhfill Rule therule \
          fi
          hline
          ifcsname mm@FUNKTORYendcsname
          mm@FUNKTORY \
          fi
          ifcsname mm@OBLIGendcsname
          Obligatory & mm@OBLIG \
          fi
          hline
          endtabular%
          endgroup


          ExplSyntaxOn % Use LaTeX3-style input syntax (see expl3.pdf)

          seq_new:N g_mm_rules_seq

          NewDocumentCommand Rule m

          seq_gput_right:Nn g_mm_rules_seq typesetRule #1
          medskipnoindent
          typesetRule #1


          % Programming-level function
          cs_new_protected:Npn mm_recap_all_rules:

          group_begin: % limit effect of the cs_set_eq:NN
          setcounter rule 0 % reset the rule counter
          % Special version of two commands for use here (we used different versions
          % in the main text). Note that cs_set_eq:NN is like let.
          cs_set_eq:NN mm@increment@rule@ctr mm@appendix@increment@rule@ctr
          cs_set_eq:NN mm@set@rule@label mm@appendix@rule@label@cmd
          % Use all elements we've recorded, separated using the provided separator
          seq_use:Nn g_mm_rules_seq par medskip noindent % separator
          group_end:


          % User-level function
          NewDocumentCommand recapallrules

          mm_recap_all_rules:


          ExplSyntaxOff % end of LaTeX3-style input syntax

          makeatother

          begindocument

          Rule
          nonnumbered = yes,
          header = Rules in general,
          FUNKTORY = VALUE 1 & VALUE 2,


          Rule
          header = Rule 1,
          FUNKTORY = X & Y,
          label = rule:1,


          Rule
          header = Rule 2,
          FUNKTORY = Z & T,
          label = rule:2,


          appendix

          chapterAll rules

          recapallrules

          enddocument


          On page 1:



          On page 1



          Appendix:



          Appendix







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jul 1 at 9:52

























          answered Jul 1 at 9:33









          frougonfrougon

          4,4121 gold badge10 silver badges20 bronze badges




          4,4121 gold badge10 silver badges20 bronze badges





















              3














              I wouldn't mix “legacy” programming with expl3. With careful usage of variants, it's easy to control what gets expanded and what doesn't.



              documentclassbook
              usepackagexparse

              newcounterrule
              renewcommandtherule[0]Garabicrule

              ExplSyntaxOn

              NewDocumentCommandRulem

              group_begin:
              tl_clear:N l__ansa_rule_body_tl
              keys_set:nn ansa/rule #1
              __ansa_rule:
              tl_gput_right:NV g__ansa_rule_all_tl l__ansa_rule_body_tl
              tl_gput_right:Nn g__ansa_rule_all_tl parbigskip
              group_end:

              NewDocumentCommandallrules

              begincenter
              cs_set_eq:NN __ansa_rule_label:n use_none:n
              tl_use:N g__ansa_rule_all_tl
              endcenter


              tl_new:N l__ansa_rule_body_tl
              tl_new:N g__ansa_rule_all_tl

              keys_define:nn ansa/rule

              nonnumbered .bool_set:N = l__ansa_rule_nonnumbered_bool,
              nonnumbered .default:n = true,
              nonnumbered .initial:n = false,
              label .tl_set:N = l__ansa_rule_label_tl,
              header .tl_set:N = l__ansa_rule_header_tl,
              FUNKTORY .tl_set:N = l__ansa_rule_funktory_tl,
              OBLIG .tl_set:N = l__ansa_rule_oblig_tl,


              cs_new_protected:Nn __ansa_rule:

              __ansa_rule_add:n begintabularp5cmhline
              bool_if:NTF l__ansa_rule_nonnumbered_bool

              __ansa_rule_add_multi:V l__ansa_rule_header_tl


              refstepcounterrule
              tl_if_empty:NF l__ansa_rule_label_tl __ansa_rule_label:n l__ansa_rule_label_tl
              __ansa_rule_add_multi_number:Vx l__ansa_rule_header_tl therule

              __ansa_rule_add:n hline
              tl_if_empty:NF l__ansa_rule_funktory_tl

              __ansa_rule_add:V l__ansa_rule_funktory_tl
              __ansa_rule_add:n \

              tl_if_empty:NF l__ansa_rule_oblig_tl

              __ansa_rule_add:V l__ansa_rule_oblig_tl
              __ansa_rule_add:n \

              __ansa_rule_add:n hlineendtabular
              tl_use:N l__ansa_rule_body_tl


              cs_new:Nn __ansa_rule_label:n label#1

              cs_new_protected:Nn __ansa_rule_add:n

              tl_put_right:Nn l__ansa_rule_body_tl #1

              cs_generate_variant:Nn __ansa_rule_add:n V

              cs_new_protected:Nn __ansa_rule_add_multi_number:nn

              __ansa_rule_add:n multicolumn2bfseries#1hfill Rule~#2 \

              cs_generate_variant:Nn __ansa_rule_add_multi_number:nn Vx

              cs_new_protected:Nn __ansa_rule_add_multi:n

              __ansa_rule_add:n multicolumn2bfseries#1 \

              cs_generate_variant:Nn __ansa_rule_add_multi:n V

              ExplSyntaxOff

              begindocument

              Rule
              nonnumbered,
              header = Rules in general,
              FUNKTORY = VALUE 1 & VALUE 2,


              Rule
              header = Rule 1,
              FUNKTORY = X & Y,
              label = rule:1,


              allrules

              enddocument


              enter image description here






              share|improve this answer



























                3














                I wouldn't mix “legacy” programming with expl3. With careful usage of variants, it's easy to control what gets expanded and what doesn't.



                documentclassbook
                usepackagexparse

                newcounterrule
                renewcommandtherule[0]Garabicrule

                ExplSyntaxOn

                NewDocumentCommandRulem

                group_begin:
                tl_clear:N l__ansa_rule_body_tl
                keys_set:nn ansa/rule #1
                __ansa_rule:
                tl_gput_right:NV g__ansa_rule_all_tl l__ansa_rule_body_tl
                tl_gput_right:Nn g__ansa_rule_all_tl parbigskip
                group_end:

                NewDocumentCommandallrules

                begincenter
                cs_set_eq:NN __ansa_rule_label:n use_none:n
                tl_use:N g__ansa_rule_all_tl
                endcenter


                tl_new:N l__ansa_rule_body_tl
                tl_new:N g__ansa_rule_all_tl

                keys_define:nn ansa/rule

                nonnumbered .bool_set:N = l__ansa_rule_nonnumbered_bool,
                nonnumbered .default:n = true,
                nonnumbered .initial:n = false,
                label .tl_set:N = l__ansa_rule_label_tl,
                header .tl_set:N = l__ansa_rule_header_tl,
                FUNKTORY .tl_set:N = l__ansa_rule_funktory_tl,
                OBLIG .tl_set:N = l__ansa_rule_oblig_tl,


                cs_new_protected:Nn __ansa_rule:

                __ansa_rule_add:n begintabularp5cmhline
                bool_if:NTF l__ansa_rule_nonnumbered_bool

                __ansa_rule_add_multi:V l__ansa_rule_header_tl


                refstepcounterrule
                tl_if_empty:NF l__ansa_rule_label_tl __ansa_rule_label:n l__ansa_rule_label_tl
                __ansa_rule_add_multi_number:Vx l__ansa_rule_header_tl therule

                __ansa_rule_add:n hline
                tl_if_empty:NF l__ansa_rule_funktory_tl

                __ansa_rule_add:V l__ansa_rule_funktory_tl
                __ansa_rule_add:n \

                tl_if_empty:NF l__ansa_rule_oblig_tl

                __ansa_rule_add:V l__ansa_rule_oblig_tl
                __ansa_rule_add:n \

                __ansa_rule_add:n hlineendtabular
                tl_use:N l__ansa_rule_body_tl


                cs_new:Nn __ansa_rule_label:n label#1

                cs_new_protected:Nn __ansa_rule_add:n

                tl_put_right:Nn l__ansa_rule_body_tl #1

                cs_generate_variant:Nn __ansa_rule_add:n V

                cs_new_protected:Nn __ansa_rule_add_multi_number:nn

                __ansa_rule_add:n multicolumn2bfseries#1hfill Rule~#2 \

                cs_generate_variant:Nn __ansa_rule_add_multi_number:nn Vx

                cs_new_protected:Nn __ansa_rule_add_multi:n

                __ansa_rule_add:n multicolumn2bfseries#1 \

                cs_generate_variant:Nn __ansa_rule_add_multi:n V

                ExplSyntaxOff

                begindocument

                Rule
                nonnumbered,
                header = Rules in general,
                FUNKTORY = VALUE 1 & VALUE 2,


                Rule
                header = Rule 1,
                FUNKTORY = X & Y,
                label = rule:1,


                allrules

                enddocument


                enter image description here






                share|improve this answer

























                  3












                  3








                  3







                  I wouldn't mix “legacy” programming with expl3. With careful usage of variants, it's easy to control what gets expanded and what doesn't.



                  documentclassbook
                  usepackagexparse

                  newcounterrule
                  renewcommandtherule[0]Garabicrule

                  ExplSyntaxOn

                  NewDocumentCommandRulem

                  group_begin:
                  tl_clear:N l__ansa_rule_body_tl
                  keys_set:nn ansa/rule #1
                  __ansa_rule:
                  tl_gput_right:NV g__ansa_rule_all_tl l__ansa_rule_body_tl
                  tl_gput_right:Nn g__ansa_rule_all_tl parbigskip
                  group_end:

                  NewDocumentCommandallrules

                  begincenter
                  cs_set_eq:NN __ansa_rule_label:n use_none:n
                  tl_use:N g__ansa_rule_all_tl
                  endcenter


                  tl_new:N l__ansa_rule_body_tl
                  tl_new:N g__ansa_rule_all_tl

                  keys_define:nn ansa/rule

                  nonnumbered .bool_set:N = l__ansa_rule_nonnumbered_bool,
                  nonnumbered .default:n = true,
                  nonnumbered .initial:n = false,
                  label .tl_set:N = l__ansa_rule_label_tl,
                  header .tl_set:N = l__ansa_rule_header_tl,
                  FUNKTORY .tl_set:N = l__ansa_rule_funktory_tl,
                  OBLIG .tl_set:N = l__ansa_rule_oblig_tl,


                  cs_new_protected:Nn __ansa_rule:

                  __ansa_rule_add:n begintabularp5cmhline
                  bool_if:NTF l__ansa_rule_nonnumbered_bool

                  __ansa_rule_add_multi:V l__ansa_rule_header_tl


                  refstepcounterrule
                  tl_if_empty:NF l__ansa_rule_label_tl __ansa_rule_label:n l__ansa_rule_label_tl
                  __ansa_rule_add_multi_number:Vx l__ansa_rule_header_tl therule

                  __ansa_rule_add:n hline
                  tl_if_empty:NF l__ansa_rule_funktory_tl

                  __ansa_rule_add:V l__ansa_rule_funktory_tl
                  __ansa_rule_add:n \

                  tl_if_empty:NF l__ansa_rule_oblig_tl

                  __ansa_rule_add:V l__ansa_rule_oblig_tl
                  __ansa_rule_add:n \

                  __ansa_rule_add:n hlineendtabular
                  tl_use:N l__ansa_rule_body_tl


                  cs_new:Nn __ansa_rule_label:n label#1

                  cs_new_protected:Nn __ansa_rule_add:n

                  tl_put_right:Nn l__ansa_rule_body_tl #1

                  cs_generate_variant:Nn __ansa_rule_add:n V

                  cs_new_protected:Nn __ansa_rule_add_multi_number:nn

                  __ansa_rule_add:n multicolumn2bfseries#1hfill Rule~#2 \

                  cs_generate_variant:Nn __ansa_rule_add_multi_number:nn Vx

                  cs_new_protected:Nn __ansa_rule_add_multi:n

                  __ansa_rule_add:n multicolumn2bfseries#1 \

                  cs_generate_variant:Nn __ansa_rule_add_multi:n V

                  ExplSyntaxOff

                  begindocument

                  Rule
                  nonnumbered,
                  header = Rules in general,
                  FUNKTORY = VALUE 1 & VALUE 2,


                  Rule
                  header = Rule 1,
                  FUNKTORY = X & Y,
                  label = rule:1,


                  allrules

                  enddocument


                  enter image description here






                  share|improve this answer













                  I wouldn't mix “legacy” programming with expl3. With careful usage of variants, it's easy to control what gets expanded and what doesn't.



                  documentclassbook
                  usepackagexparse

                  newcounterrule
                  renewcommandtherule[0]Garabicrule

                  ExplSyntaxOn

                  NewDocumentCommandRulem

                  group_begin:
                  tl_clear:N l__ansa_rule_body_tl
                  keys_set:nn ansa/rule #1
                  __ansa_rule:
                  tl_gput_right:NV g__ansa_rule_all_tl l__ansa_rule_body_tl
                  tl_gput_right:Nn g__ansa_rule_all_tl parbigskip
                  group_end:

                  NewDocumentCommandallrules

                  begincenter
                  cs_set_eq:NN __ansa_rule_label:n use_none:n
                  tl_use:N g__ansa_rule_all_tl
                  endcenter


                  tl_new:N l__ansa_rule_body_tl
                  tl_new:N g__ansa_rule_all_tl

                  keys_define:nn ansa/rule

                  nonnumbered .bool_set:N = l__ansa_rule_nonnumbered_bool,
                  nonnumbered .default:n = true,
                  nonnumbered .initial:n = false,
                  label .tl_set:N = l__ansa_rule_label_tl,
                  header .tl_set:N = l__ansa_rule_header_tl,
                  FUNKTORY .tl_set:N = l__ansa_rule_funktory_tl,
                  OBLIG .tl_set:N = l__ansa_rule_oblig_tl,


                  cs_new_protected:Nn __ansa_rule:

                  __ansa_rule_add:n begintabularp5cmhline
                  bool_if:NTF l__ansa_rule_nonnumbered_bool

                  __ansa_rule_add_multi:V l__ansa_rule_header_tl


                  refstepcounterrule
                  tl_if_empty:NF l__ansa_rule_label_tl __ansa_rule_label:n l__ansa_rule_label_tl
                  __ansa_rule_add_multi_number:Vx l__ansa_rule_header_tl therule

                  __ansa_rule_add:n hline
                  tl_if_empty:NF l__ansa_rule_funktory_tl

                  __ansa_rule_add:V l__ansa_rule_funktory_tl
                  __ansa_rule_add:n \

                  tl_if_empty:NF l__ansa_rule_oblig_tl

                  __ansa_rule_add:V l__ansa_rule_oblig_tl
                  __ansa_rule_add:n \

                  __ansa_rule_add:n hlineendtabular
                  tl_use:N l__ansa_rule_body_tl


                  cs_new:Nn __ansa_rule_label:n label#1

                  cs_new_protected:Nn __ansa_rule_add:n

                  tl_put_right:Nn l__ansa_rule_body_tl #1

                  cs_generate_variant:Nn __ansa_rule_add:n V

                  cs_new_protected:Nn __ansa_rule_add_multi_number:nn

                  __ansa_rule_add:n multicolumn2bfseries#1hfill Rule~#2 \

                  cs_generate_variant:Nn __ansa_rule_add_multi_number:nn Vx

                  cs_new_protected:Nn __ansa_rule_add_multi:n

                  __ansa_rule_add:n multicolumn2bfseries#1 \

                  cs_generate_variant:Nn __ansa_rule_add_multi:n V

                  ExplSyntaxOff

                  begindocument

                  Rule
                  nonnumbered,
                  header = Rules in general,
                  FUNKTORY = VALUE 1 & VALUE 2,


                  Rule
                  header = Rule 1,
                  FUNKTORY = X & Y,
                  label = rule:1,


                  allrules

                  enddocument


                  enter image description here







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 1 at 9:54









                  egregegreg

                  754k90 gold badges1977 silver badges3316 bronze badges




                  754k90 gold badges1977 silver badges3316 bronze badges



























                      draft saved

                      draft discarded
















































                      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.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f498155%2ffully-expand-toks-and-save-for-later-appendix-with-exact-copies-of-tables-from%23new-answer', 'question_page');

                      );

                      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







                      Popular posts from this blog

                      Category:9 (number) SubcategoriesMedia in category "9 (number)"Navigation menuUpload mediaGND ID: 4485639-8Library of Congress authority ID: sh85091979ReasonatorScholiaStatistics

                      Circuit construction for execution of conditional statements using least significant bitHow are two different registers being used as “control”?How exactly is the stated composite state of the two registers being produced using the $R_zz$ controlled rotations?Efficiently performing controlled rotations in HHLWould this quantum algorithm implementation work?How to prepare a superposed states of odd integers from $1$ to $sqrtN$?Why is this implementation of the order finding algorithm not working?Circuit construction for Hamiltonian simulationHow can I invert the least significant bit of a certain term of a superposed state?Implementing an oracleImplementing a controlled sum operation

                      Magento 2 “No Payment Methods” in Admin New OrderHow to integrate Paypal Express Checkout with the Magento APIMagento 1.5 - Sales > Order > edit order and shipping methods disappearAuto Invoice Check/Money Order Payment methodAdd more simple payment methods?Shipping methods not showingWhat should I do to change payment methods if changing the configuration has no effects?1.9 - No Payment Methods showing upMy Payment Methods not Showing for downloadable/virtual product when checkout?Magento2 API to access internal payment methodHow to call an existing payment methods in the registration form?