diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty b/Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty index 389849784aa..3e9778591d9 100644 --- a/Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty +++ b/Master/texmf-dist/tex/latex/tikzlings/tikzlings.sty @@ -12,7 +12,14 @@ % See http://www.latex-project.org/lppl.txt % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\ProvidesPackage{tikzlings}[2020/12/04 version v0.4 Collection of packages to draw animals and other beings in TikZ] +\ProvidesPackage{tikzlings}[2021/03/17 version v0.5 Collection of packages to draw animals and other beings in TikZ] + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% List of all TikZlings +% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\RequirePackage{tikzlings-list} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -20,25 +27,21 @@ % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \RequirePackage{tikz} -\RequirePackage{tikzlings-bears} -\RequirePackage{tikzlings-penguins} -\RequirePackage{tikzlings-marmots} -\RequirePackage{tikzlings-owls} -\RequirePackage{tikzlings-koalas} -\RequirePackage{tikzlings-coatis} -\RequirePackage{tikzlings-snowmans} -\RequirePackage{tikzlings-mice} -\RequirePackage{tikzlings-moles} -\RequirePackage{tikzlings-sloths} -\RequirePackage{tikzlings-pigs} -\RequirePackage{tikzlings-cats} -\RequirePackage{tikzlings-hippos} -\RequirePackage{tikzlings-rhinos} -\RequirePackage{tikzlings-pandas} -\RequirePackage{tikzlings-bees} -\RequirePackage{tikzlings-anteaters} -\RequirePackage{tikzlings-squirrels} -\RequirePackage{tikzlings-sheep} + +% from https://chat.stackexchange.com/transcript/message/56515698#56515698 +\ExplSyntaxOn +\cs_new_protected:Npn \tikzlings_load_packages:N #1 { + \clist_map_inline:Nn #1 { + \exp_args:Nx \RequirePackage { + tikzlings- \__tikzlings_after_slash:w ##1 / / \s_stop + } + } +} +\cs_new:Npn \__tikzlings_after_slash:w #1 / #2 / #3 \s_stop { \tl_trim_spaces:n {#2} } +\cs_new_eq:NN \tikzling@loadpackages \tikzlings_load_packages:N +\ExplSyntaxOff +\tikzling@loadpackages\tikzling@list + \RequirePackage{tikzlings-addons} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -61,9 +64,30 @@ \fi \pgfmathsetseed{\number\pdfrandomseed} \fi + +% from https://chat.stackexchange.com/transcript/message/56516469#56516469 +% To be able to x-expand \iterateTikzlings, it has to be expandable, so no 'protected'. Also \clist_map_inline:Nn is not expandable, so we have to use \clist_map_function:NN instead. +\cs_new:Npn \tikzlings_iterate:N #1 { + \clist_map_function:NN #1 \__tikzlings_braced_items:n +} +% \__tikzlings_braced_items:n will receive each clist item, then: +\cs_new:Npn \__tikzlings_braced_items:n #1 { + { % leave an open brace + % we don't want the x-expansion to expand the tikzling command, so we prevent expansion with \exp_not:c. The 'c' variant is used so it builds a csname from its argument, before preventing the expansion: and the argument is what's before the '/' + \exp_not:c { + \__tikzlings_before_slash:w #1 / \s_stop + } + } % leave a close brace +} +\cs_new:Npn \__tikzlings_before_slash:w #1 / #2 \s_stop { + \tl_trim_spaces:n {#1} % make sure there are no spaces around the string +} +\cs_new_eq:NN \tikzling@iteraterandom \tikzlings_iterate:N +\cs_new_eq:NN \ExpArgsNnx \exp_args:Nnx + \ExplSyntaxOff -\pgfmathdeclarerandomlist{tikzlings}{{\bear}{\penguin}{\marmot}{\owl}{\koala}{\coati}{\snowman}{\mouse}{\moles}{\sloth}{\pig}{\cat}{\hippo}{\rhino}{\bee}{\anteater}{\sheep}} +\ExpArgsNnx\pgfmathdeclarerandomlist{tikzlings}{\tikzling@iteraterandom\tikzling@list} \newcommand{\tikzling}[1][]{% \pgfmathrandomitem{\tikzling@random}{tikzlings}% |