Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gfngfn/expandparams
(La)TeX packages that makes you save the cost of writing thousands of \expandafter.
https://github.com/gfngfn/expandparams
latex latex-package tex
Last synced: about 1 month ago
JSON representation
(La)TeX packages that makes you save the cost of writing thousands of \expandafter.
- Host: GitHub
- URL: https://github.com/gfngfn/expandparams
- Owner: gfngfn
- Created: 2014-10-05T12:05:41.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-17T09:32:34.000Z (about 10 years ago)
- Last Synced: 2024-10-19T01:05:50.335Z (2 months ago)
- Topics: latex, latex-package, tex
- Language: TeX
- Homepage:
- Size: 406 KB
- Stars: 4
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# expandparams
`expandparams` is a (La)TeX package that controls the expansion of token list with ease.
By using the commands `\expandparams` and `\prexp` in this package
you can save the cost of writing thousands of `\expandafter`.
For example, let `\csone` and `\cstwo` be defined by below:\makeatletter
\def\csone{GF}%
\def\cstwo{\csone N}%
\def\separatetokens#1#2#3{%
\@tfor\ch:=#1\do{[\ch]}%
\@tfor\ch:=#2\do{(\ch)}%
\@tfor\ch:=#3\do{\{\ch\}%
}%Here, ordinary spec of `\separatetokens` is like
\separatetokens{AB}{PQRS}{XYZ}\par
% => [A][B](P)(Q)(R)(S){X}{Y}{Z}
\separatetokens{AB}{\cstwo}{\csone}\par
% => [A][B](GFN){GF}However, sometimes we need to expand parameters before the main control sequence is expanded.
When you want to expand `\csone` once before `\separatetokens` is expanded,
you can write\expandparams{\separatetokens{AB}{\cstwo}\prexp{\cstwo}}\par
% => [A][B](GFN){G}{F}instead of writing
\expandafter\separatetokens
\expandafter{\expandafter A\expandafter B\expandafter}%
\expandafter{\expandafter\cstwo\expandafter}%
\expandafter{\csone}\parby using enormous `\expandafter`s. Similarly, you can write
\expandparams{\separatetokens{AB}\prexp{\cstwo}\prexp{\csone}}\par
% => [A][B](GF)(N){G}{F}instead of
\expandafter\expandafter\expandafter\separatetokens
\expandafter\expandafter\expandafter{%
\expandafter\expandafter\expandafter A%
\expandafter\expandafter\expandafter B%
\expandafter\expandafter\expandafter}%
\expandafter\expandafter\expandafter
{\expandafter\cstwo\expandafter}\expandafter{\csone}\par
for expanding both `\csone` and `\cstwo` once. And you can also write\expandparams{\separatetokens{AB}\prexp\prexp{\cstwo}{\csone}}\par
% => [A][B](G)(F)(N){GF}instead of
\expandafter\expandafter\expandafter\separatetokens
\expandafter\expandafter\expandafter{%
\expandafter\expandafter\expandafter A%
\expandafter\expandafter\expandafter B%
\expandafter\expandafter\expandafter}%
\expandafter\expandafter\expandafter{\cstwo}{\csone}\parfor expanding `\cstwo` *twice*.