summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sillypage/sillypage.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/sillypage/sillypage.sty')
-rw-r--r--Master/texmf-dist/tex/latex/sillypage/sillypage.sty97
1 files changed, 74 insertions, 23 deletions
diff --git a/Master/texmf-dist/tex/latex/sillypage/sillypage.sty b/Master/texmf-dist/tex/latex/sillypage/sillypage.sty
index 5bfb15ddb1c..9426f012166 100644
--- a/Master/texmf-dist/tex/latex/sillypage/sillypage.sty
+++ b/Master/texmf-dist/tex/latex/sillypage/sillypage.sty
@@ -11,6 +11,7 @@
%% Copyright 2022 Phelype Oleinik /phelype.oleinik@latex-project.org/
%% Paulo Cereda /cereda.paulo@gmail.com/
%% samcarter /sam.carter8@aol.com/
+%% Ulrike Fischer /fischer@troubleshooting-tex.de/
%%
%% This work may be distributed and/or modified under the conditions of the
%% LaTeX Project Public License, either version 1.3c of this license or (at
@@ -21,32 +22,82 @@
%% and version 1.3c or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%%
-\def\sillypageDate{2022-01-20}
-\def\sillypageVersion{1.3}
-\ProvidesPackage{sillypage}[\sillypageDate\space\sillypageVersion\space
- The silly walk as page numbering style]
+\def\sillypageDate{2022-02-02}
+\def\sillypageVersion{1.4}
+\ProvidesExplPackage
+ {sillypage} {\sillypageDate} {\sillypageVersion}
+ {The silly walk as page numbering style}
\RequirePackage{graphicx}
-\newcommand*\silly[1]{\expandafter\@silly\csname c@#1\endcsname}
-\newcommand*\sillystep[1]{\@silly{#1}}
-\newcommand*\@silly[1]{\expandafter\@silly@walk
- \expandafter{\number\numexpr#1\relax}}
-\newcommand*\silly@steps{12}%
-\newcommand*\silly@height{.8cm}%
-\newcommand*\silly@picture{sillywalk-map.pdf}%
-\def\@silly@walk#1{%
- \@ifundefined{texorpdfstring}{\@firstoftwo}{\texorpdfstring}%
- {\@silly@walk@{#1}}% TeX
- {#1}}% pdf string
-\def\@silly@walk@#1{%
- \ifnum#1>\silly@steps\space
- \expandafter\@silly@walk@\expandafter
- {\number\numexpr#1-\silly@steps\expandafter}%
- \else
- \includegraphics[height=\silly@height,page=#1]{\silly@picture}%
- \fi}
+\newcommand*\silly@steps{12}
+\newcommand*\silly@height{.8cm}
+\newcommand*\silly@picture{sillywalk-map.pdf}
+\NewDocumentCommand \silly { m } { \exp_args:Nv \__silly_step:n { c@#1 } }
+\NewDocumentCommand \sillystep { m } { \__silly_step:n {#1} }
+\newcommand*\@silly { \__silly_step:n }
+\cs_new:Npn \__silly_step:n #1
+ {
+ \__silly_step_aux:eN
+ { \int_eval:n { \int_mod:nn { #1-1 } { \silly@steps } +1 } }
+ \c_false_bool
+ }
+\NewDocumentCommand \sillynumeral { m } { \__silly_numeral:n {#1} }
+\newcommand*\@sillynumeral { \__silly_numeral:n }
+\cs_new:Npn \__silly_numeral:n #1
+ {
+ \exp_args:Ne \str_map_function:nN
+ { \int_to_base:nn {#1} { 12 } } \__silly_numeral_aux:n
+ }
+\cs_new:Npn \__silly_numeral_aux:n #1
+ { \__silly_step_aux:eN { "\char_uppercase:N #1+1 } \c_true_bool }
+\cs_new:Npn \__silly_step_aux:nN #1 #2
+ {
+ \cs_if_exist_use:cF { texorpdfstring } { \use_i:nn }
+ { \__silly_trim_step:nN {#1} #2 }
+ {#1}
+ }
+\cs_generate_variant:Nn \__silly_step_aux:nN { e }
+\cs_new:Npn \__silly_trim_step:nN #1 #2
+ {
+ \exp_args:Nee \@@silly@place@picture@@nn
+ {
+ \bool_if:NT #2
+ {
+ trim = \int_case:nn {#1}
+ {
+ { 1 } { 57 ~ 0 ~ 42 ~ 0 }
+ { 2 } { 59 ~ 0 ~ 29 ~ 0 }
+ { 3 } { 53 ~ 0 ~ 21 ~ 0 }
+ { 4 } { 62 ~ 0 ~ 11 ~ 0 }
+ { 5 } { 50 ~ 0 ~ 8 ~ 0 }
+ { 6 } { 33 ~ 0 ~ 27 ~ 0 }
+ { 7 } { 45 ~ 0 ~ 13 ~ 0 }
+ { 8 } { 56 ~ 0 ~ 27 ~ 0 }
+ { 9 } { 38 ~ 0 ~ 12 ~ 0 }
+ { 10 } { 7 ~ 0 ~ 43 ~ 0 }
+ { 11 } { 33 ~ 0 ~ 33 ~ 0 }
+ { 12 } { 57 ~ 0 ~ 7 ~ 0 }
+ }
+ , clip
+ }
+ }
+ { \int_eval:n {#1} }
+ }
+\DeclareRobustCommand \@@silly@place@picture@@nn [2]
+ {
+ \includegraphics
+ [ #1, page=#2, height=\silly@height ]
+ { \silly@picture }
+ }
+\AtBeginDocument
+ {
+ \cs_if_exist_use:NF \pdfstringdefDisableCommands { \use_none:n }
+ { \cs_set:Npn \@@silly@place@picture@@nn #1 #2 {#2} }
+ }
+\DeclareHookRule { begindocument }
+ { sillypage } { after } { hyperref }
%%
%% This work is "maintained" (as per the LPPL maintenance status)
-%% by Phelype Oleinik, Paulo Cereda and samcarter.
+%% by Phelype Oleinik, Paulo Cereda, samcarter and Ulrike Fischer.
%%
%% This work consists of the files sillypage.dtx, and
%% sillypage.ins,