Debian Codegraph @

texmf-dist/tex/latex/realhats/realhats.sty

raw
1 %%
2 %% This is file `realhats.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% realhats.dtx (with options: `realhats')
8 %% Copyright (c) 2019 Matthew Scroggs & Adam Townsend
9 %%
10 %% Permission is hereby granted, free of charge, to any person obtaining a copy
11 %% of this software and associated documentation files (the "Software"), to deal
12 %% in the Software without restriction, including without limitation the rights
13 %% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 %% copies of the Software, and to permit persons to whom the Software is
15 %% furnished to do so, subject to the following conditions:
16 %%
17 %% The above copyright notice and this permission notice shall be included in all
18 %% copies or substantial portions of the Software.
19 %%
20 %% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21 %% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 %% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23 %% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 %% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25 %% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 %% SOFTWARE.
27 %%
28
29 \NeedsTeXFormat{LaTeX2e}
30 \ProvidesPackage{realhats}[2022/06/13 realhats 6.0]
31
32 \RequirePackage{amsmath}
33 \RequirePackage{graphicx}
34 \RequirePackage{ifthen}
35 \RequirePackage[first=0, last=14, counter=hat]{lcg}
36 \RequirePackage{calc}
37 \RequirePackage{stackengine}
38
39 \newcommand\myhat{}
40 \newlength{\hatwidth} %hat width
41 \newlength{\hshif} %horizontal shift
42 \newlength{\vshif} %vertical shift
43
44 \global\def\hatused{-1}
45 \DeclareOption{beret}{\global\def\hatused{beret}}
46 \DeclareOption{santa}{\global\def\hatused{santa}}
47 \DeclareOption{sombrero}{\global\def\hatused{sombrero}}
48 \DeclareOption{witch}{\global\def\hatused{witch}}
49 \DeclareOption{tophat}{\global\def\hatused{tophat}}
50 \DeclareOption{ash}{\global\def\hatused{ash}}
51 \DeclareOption{fez}{\global\def\hatused{fez}}
52 \DeclareOption{cowboy}{\global\def\hatused{cowboy}}
53 \DeclareOption{crown}{\global\def\hatused{crown}}
54 \DeclareOption{dunce}{\global\def\hatused{dunce}}
55 \DeclareOption{policeman}{\global\def\hatused{policeman}}
56 \DeclareOption{scottish}{\global\def\hatused{scottish}}
57 \DeclareOption{birthday}{\global\def\hatused{birthday}}
58 \DeclareOption{mortarboard}{\global\def\hatused{mortarboard}}
59 \DeclareOption{tile-white}{\global\def\hatused{tile-white}}
60 \DeclareOption{tile-gray}{\global\def\hatused{tile-gray}}
61 \DeclareOption{tile-light-blue}{\global\def\hatused{tile-light-blue}}
62 \DeclareOption{tile-blue}{\global\def\hatused{tile-blue}}
63 \ProcessOptions\relax
64
65 \newcommand{\gethat}{%
66 \ifcase\thehat beret%
67 \or santa%
68 \or sombrero%
69 \or witch%
70 \or tophat%
71 \or ash%
72 \or fez%
73 \or cowboy%
74 \or crown%
75 \or dunce%
76 \or policeman%
77 \or scottish%
78 \or birthday%
79 \or mortarboard%
80 \or tile-white%
81 \or tile-gray%
82 \or tile-light-blue%
83 \or tile-blue%
84 \fi
85 }
86
87 \renewcommand{\hat}[2][]{%
88 \ifthenelse{\equal{#1}{}}{%
89 \ifthenelse{\equal{\hatused}{-1}}%
90 {\rand\hatn{#2}{\gethat}}%
91 {\hatn{#2}{\hatused}}%
92 }{%
93 \ifthenelse{\equal{#1}{beret}}{\hatn{#2}{beret}}{}%
94 \ifthenelse{\equal{#1}{santa}}{\hatn{#2}{santa}}{}%
95 \ifthenelse{\equal{#1}{sombrero}}{\hatn{#2}{sombrero}}{}%
96 \ifthenelse{\equal{#1}{witch}}{\hatn{#2}{witch}}{}%
97 \ifthenelse{\equal{#1}{tophat}}{\hatn{#2}{tophat}}{}%
98 \ifthenelse{\equal{#1}{ash}}{\hatn{#2}{ash}}{}%
99 \ifthenelse{\equal{#1}{fez}}{\hatn{#2}{fez}}{}%
100 \ifthenelse{\equal{#1}{cowboy}}{\hatn{#2}{cowboy}}{}%
101 \ifthenelse{\equal{#1}{crown}}{\hatn{#2}{crown}}{}%
102 \ifthenelse{\equal{#1}{dunce}}{\hatn{#2}{dunce}}{}%
103 \ifthenelse{\equal{#1}{policeman}}{\hatn{#2}{policeman}}{}%
104 \ifthenelse{\equal{#1}{scottish}}{\hatn{#2}{scottish}}{}%
105 \ifthenelse{\equal{#1}{birthday}}{\hatn{#2}{birthday}}{}%
106 \ifthenelse{\equal{#1}{mortarboard}}{\hatn{#2}{mortarboard}}{}%
107 \ifthenelse{\equal{#1}{tile-white}}{\hatn{#2}{tile-white}}{}%
108 \ifthenelse{\equal{#1}{tile-gray}}{\hatn{#2}{tile-gray}}{}%
109 \ifthenelse{\equal{#1}{tile-light-blue}}{\hatn{#2}{tile-light-blue}}{}%
110 \ifthenelse{\equal{#1}{tile-blue}}{\hatn{#2}{tile-blue}}{}%
111 }%
112 }
113
114 \newcommand{\hatn}[2]{\hatnoptions{#1}{#2}{0ex}{0ex}}
115
116 \newcommand{\hatnoptions}[4]{%
117 \setlength{\hshif}{1pt}
118 \setlength{\hatwidth}{2ex}
119 \ifthenelse{\equal{#2}{beret}}{\renewcommand\myhat{hats/realhats-beret}\setlength{\vshif}{-0.6ex} \setlength{\hshif}{0.5ex} }{}%
120 \ifthenelse{\equal{#2}{santa}}{\renewcommand\myhat{hats/realhats-santa}\setlength{\vshif}{-0.1ex} }{}%
121 \ifthenelse{\equal{#2}{sombrero}}{\renewcommand\myhat{hats/realhats-sombrero}\setlength{\vshif}{-0.17ex} \addtolength{\hshif}{-1pt}}{}%
122 \ifthenelse{\equal{#2}{witch}}{\renewcommand\myhat{hats/realhats-witch}\setlength{\vshif}{-0.12ex} \addtolength{\hshif}{-1pt}}{}%
123 \ifthenelse{\equal{#2}{tophat}}{\renewcommand\myhat{hats/realhats-tophat}\setlength{\vshif}{-0.4ex} \setlength{\hatwidth}{1.8ex} \addtolength{\hshif}{-1pt}}{}%
124 \ifthenelse{\equal{#2}{ash}}{\renewcommand\myhat{hats/realhats-ash}\setlength{\vshif}{-0.6ex} \setlength{\hatwidth}{1.8ex} \addtolength{\hshif}{-1pt}}{}%
125 \ifthenelse{\equal{#2}{fez}}{\renewcommand\myhat{hats/realhats-fez}\setlength{\vshif}{-0.4ex} \setlength{\hatwidth}{1ex} \addtolength{\hshif}{-1pt}}{}%
126 \ifthenelse{\equal{#2}{cowboy}}{\renewcommand\myhat{hats/realhats-cowboy}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0.2ex}}{}%
127 \ifthenelse{\equal{#2}{crown}}{\renewcommand\myhat{hats/realhats-crown}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0.2ex}}{}%
128 \ifthenelse{\equal{#2}{dunce}}{\renewcommand\myhat{hats/realhats-dunce}\setlength{\vshif}{-0.3ex} \setlength{\hatwidth}{1.4ex}}{}%
129 \ifthenelse{\equal{#2}{policeman}}{\renewcommand\myhat{hats/realhats-policeman}\setlength{\vshif}{-0.4ex} \setlength{\hatwidth}{1.8ex} \addtolength{\hshif}{-1pt}}{}%
130 \ifthenelse{\equal{#2}{scottish}}{\renewcommand\myhat{hats/realhats-scottish}\setlength{\vshif}{-0.6ex} \setlength{\hshif}{0.5ex} }{}%
131 \ifthenelse{\equal{#2}{birthday}}{\renewcommand\myhat{hats/realhats-birthday}\setlength{\vshif}{-0.2ex} \setlength{\hshif}{-0.1ex} }{}%
132 \ifthenelse{\equal{#2}{mortarboard}}{\renewcommand\myhat{hats/realhats-mortarboard}\setlength{\vshif}{-0.15ex} \setlength{\hshif}{0ex} }{}%
133 \ifthenelse{\equal{#2}{tile-white}}{\renewcommand\myhat{hats/realhats-tile-white}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0ex} }{}%
134 \ifthenelse{\equal{#2}{tile-gray}}{\renewcommand\myhat{hats/realhats-tile-gray}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0ex} }{}%
135 \ifthenelse{\equal{#2}{tile-light-blue}}{\renewcommand\myhat{hats/realhats-tile-light-blue}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0ex} }{}%
136 \ifthenelse{\equal{#2}{tile-blue}}{\renewcommand\myhat{hats/realhats-tile-blue}\setlength{\vshif}{-0.3ex} \setlength{\hshif}{0ex} }{}%
137 \ifthenelse{\equal{#2}{,1}}{\renewcommand\myhat{hats/realhats-,1}\setlength{\vshif}{-0.15ex} \setlength{\hshif}{0ex} }{}%
138 \addtolength{\hshif}{#3}%
139 \addtolength{\vshif}{#4}%
140 \stackMath %
141 \stackon[\vshif]{#1}{\hspace{\hshif}\includegraphics[width=\hatwidth]{\myhat}}
142 }
143 \endinput
144 %%
145 %% End of file `realhats.sty'.