summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/sillypage/sillypage.sty
blob: 2c304af0505c838fca5760a457f0f8e969ece6f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
%%
%% This is file `sillypage.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% sillypage.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright 2023 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
%% your option) any later version. The latest version of this license is in
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.3c or later is part of all distributions of LaTeX version
%% 2005/12/01 or later.
%% 
\def\sillypageDate{2023-03-04}
\def\sillypageVersion{1.6}
\ProvidesExplPackage
  {sillypage} {\sillypageDate} {\sillypageVersion}
  {The silly walk as page numbering style}
\RequirePackage{graphicx}
\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, samcarter and Ulrike Fischer.
%% 
%% This work consists of the files sillypage.dtx, and
%%                                 sillypage.ins,
%% and the derived files           sillypage.sty,
%%                                 sillypage.pdf,
%%                                 sillywalk-map.pdf, and
%%                                 README.md.
%%
%% End of file `sillypage.sty'.