Debian Codegraph @

texmf-dist/source/latex/bearwear/bearwear.dtx

raw
1 % \iffalse meta-comment
2 %
3 %% File: bearwear.dtx
4 %
5 % Copyright (C) 2020 Ulrike Fischer / Bär
6 %
7 % It may be distributed and/or modified under the conditions of the
8 % LaTeX Project Public License (LPPL), either version 1.3c of this
9 % license or (at your option) any later version. The latest version
10 % of this license is in the file
11 %
12 % https://www.latex-project.org/lppl.txt
13 %
14 % This file is part of the "bearwear bundle" (The Work in LPPL)
15 % and all files in that bundle must be distributed together.
16 %
17 % -----------------------------------------------------------------------
18 %
19 % The development version of the bundle can be found at
20 %
21 % https://github.com/u-fischer/bearwear
22 %
23 % for those people who are interested.
24 %
25 %<*driver>
26 \documentclass{l3doc}
27 \OnlyDescription
28 \PassOptionsToPackage{svgnames}{xcolor}
29 \usepackage{tikzlings,tikzducks,bearwear}
30 \usetikzlibrary{patterns,patterns.meta}
31 \usepackage{csquotes,graphicx}
32 \usepackage{needspace}
33 \usepackage{AlegreyaSans}
34 \setmainfont{Heuristica}
35 \usepackage[most]{tcolorbox}
36
37 \lstdefinestyle{bearwarestyle}{% stolen and adapted from tikzlings
38 language={[latex]TeX},
39 tabsize=2,
40 breaklines,
41 basicstyle=\ttfamily,
42 commentstyle={\color{green!50!black}\slshape},
43 columns=fullflexible,
44 alsodigit={-},
45 alsoletter={3},
46 emphstyle=\color{red!60!black},
47 emph=[1]{
48 v-neckline,muscle, shirt, t-shirt, long, sleeves, round, neckline,
49 leftarm, rightarm,arms,deco,body, pattern,beartummy,
50 bearheart,color},
51 texcsstyle=*\color{SteelBlue!50!black}\bfseries,
52 keywordstyle=\color{red!60!black}\bfseries,
53 morekeywords={tikzpicture},
54 moretexcs={bearwear, bearwearsetup},
55 delim ={[s][\ttfamily\color{green!50!black}]{$}{$}},
56 moredelim=[is][\footnotesize\ttfamily\color{orange!70!black}]{|}{|},
57 index=[1][emph]
58 }
59 \tcbset{%
60 colframe=SteelBlue!50!black,
61 arc=0mm,
62 fonttitle=\bfseries,
63 sidebyside,
64 listing options={style=bearwarestyle},
65 center lower,
66 righthand width=4cm,
67 bottom=0pt,
68 top=0pt,
69 %tikz lower,
70 height plus=3cm,
71 colback=SteelBlue!30!white,
72 enlarge top initially by=10pt
73 }
74 \lstset{style=bearwarestyle}
75 \tikzset{
76 hippo/.pic = {
77 \begin{scope}[scale=0.2,transform shape]
78 \hippo;
79 \begin{scope}[yshift=0.15cm,xshift=-0.5cm,rotate=8]
80 \duck[invisible,bowtie]
81 \end{scope}
82 \end{scope}},}
83 \raggedbottom
84 \newcommand\bearwearkey{\lstinline[style=bearwarestyle,breaklines=false]}
85 \newcommand{\TikZ}{Ti\emph{k}Z}
86
87 \GetFileInfo{bearwear.sty}
88 \title{The \bearwearlogo{} Package%
89 \thanks{This file describes \fileversion,
90 last revised \filedate.}}
91 \author{Idea: Bär~~\includegraphics[trim=0pt 15pt 0pt 0pt,height=13pt]{baer}
92 \and Implementation: Ulrike Fischer%
93 \thanks{Issues should be reported at https://github.com/u-fischer/bearwear}
94 ~\includegraphics[trim=0pt 15pt 0pt 0pt,height=15pt]{ulrike}}
95 \date{\filedate}
96 \begin{document}
97 \DocInput{\jobname.dtx}
98 \end{document}
99 %</driver>
100 % \fi
101 % \maketitle
102 % {\catcode`\%=14 \input{bearwear-doc}}
103 %
104 % \StopEventually{}
105 % \begin{macrocode}
106 %<@@=bearwear>
107 %<*package>
108 \RequirePackage{xparse}
109 \RequirePackage{tikzlings-bears}
110 \ProvidesExplPackage {bearwear} {2020-04-21} {0.2}
111 {A package for tikz bear fashion}
112 \ProcessOptions\relax
113 % a tikzset style to reverse the clip:
114 \tikzset
115 {@@reverseclip/.style=
116 {insert~path=
117 {
118 (current~bounding~box.south~west) -- (current~bounding~box.north~west)
119 --
120 (current~bounding~box.north~east) -- (current~bounding~box.south~east)
121 -- cycle
122 }
123 }
124 }
125
126 \definecolor{@@europablue}{RGB}{00,33,99}
127
128 \cs_new_protected:Npn \@@_rightarm_path:nn #1 #2 %#1 fill, clip, #2 user
129 {
130 \path[#1,#2,rotate~around={-50\char_generate:nn{58}{12}(0.525,0.9)}]
131 (0.525,0.9) ellipse (0.35~and~0.15);
132 }
133
134 \cs_new_protected:Npn \@@_leftarm_path:nn #1 #2 %#1 fill, clip, #2 user
135 {
136 \path[#1,#2,rotate~around={50\char_generate:nn{58}{12}(-0.525,0.9)}]
137 (-0.525,0.9) ellipse (0.35~and~0.15);
138 }
139
140 \cs_new_protected:Npn \@@_body_path:nn #1 #2 %#1 fill, clip, #2 user
141 {
142 \path[#1,#2] (0,0.75) ellipse (0.55~and~0.65);
143 }
144
145 \cs_new_protected:Npn \@@_init_path:
146 {
147 \@@_rightarm_path:nn {}{}
148 \@@_leftarm_path:nn {}{}
149 \@@_body_path:nn {}{}
150 }
151
152 \cs_new_protected:Npn \@@_set_coordinates:
153 {
154 \coordinate (beartummy) at (0,0.75);
155 \coordinate (bearheart) at (0.25,0.9);
156 }
157
158 \cs_new_protected:Npn \@@_clipping_path:
159 {
160 \bool_if:NTF \l__bearwear_v_neckline_bool
161 {
162 \clip (0, 1.55) circle (0.5) [__bearwearreverseclip]; %head
163 \clip (-0.4, 1.55) -- (0.4, 1.55) -- (0,0.8) --cycle[__bearwearreverseclip];
164 %v-neck
165 }
166 {
167 \clip (0, 1.55) circle (0.53) [__bearwearreverseclip]; %head
168 }
169 \clip (0.425, 0.3) circle (0.28) [@@reverseclip];
170 \clip (-0.425, 0.3) circle (0.28) [@@reverseclip];
171 \bool_if:NTF \l_@@_t_shirt_bool
172 {
173 \clip (-1,0.6) --++ (0.45,0)--++(-0.5,5) --cycle[@@reverseclip] ;
174 \clip ( 1,0.6) --++ (-0.45,0)--++(0.5,5) --cycle[@@reverseclip] ;
175 }
176 {
177 \clip (-1,0.6) --++ (0.45,0)--++(-0.5,1) --cycle[@@reverseclip] ;
178 \clip ( 1,0.6) --++ (-0.45,0)--++(0.5,1) --cycle[@@reverseclip] ;
179 }
180 \clip(-1,0.5) rectangle (1,1.2);
181 }
182
183 \cs_new_protected:Npn \@@_shirt_color:
184 {
185 \bool_if:NF \l_@@_muscle_shirt_bool
186 {
187 \exp_args:Nno \@@_leftarm_path:nn {fill}{\l_@@_leftarm_color_tl}
188 \exp_args:Nno \@@_rightarm_path:nn {fill}{\l_@@_rightarm_color_tl}
189 }
190 \exp_args:Nno \@@_body_path:nn {fill}{\l_@@_body_color_tl}
191 }
192
193 \cs_new_protected:Npn \@@_shirt_pattern:
194 {
195 \bool_if:NF \l_@@_muscle_shirt_bool
196 {
197 \exp_args:Nno \@@_leftarm_path:nn {}{\l_@@_leftarm_pattern_tl}
198 \exp_args:Nno \@@_rightarm_path:nn {}{\l_@@_rightarm_pattern_tl}
199 }
200 \exp_args:Nno \@@_body_path:nn {}{\l_@@_body_pattern_tl}
201 }
202
203 \cs_new_protected:Npn \@@_shirt_deco:
204 {
205 \bool_if:NF \l_@@_muscle_shirt_bool
206 {
207 \exp_args:Nno \@@_leftarm_path:nn {}{\l_@@_leftarm_deco_tl}
208 \exp_args:Nno \@@_rightarm_path:nn {}{\l_@@_rightarm_deco_tl}
209 }
210 \exp_args:Nno \@@_body_path:nn {}{\l_@@_body_deco_tl}
211 }
212
213 \bool_new:N \l_@@_t_shirt_bool
214 \bool_new:N \l_@@_muscle_shirt_bool
215 \bool_new:N \l__bearwear_round_neckline_bool
216
217 \tl_new:N \l_@@_leftarm_color_tl
218 \tl_new:N \l_@@_rightarm_color_tl
219 \tl_new:N \l_@@_body_color_tl
220
221 \tl_new:N \l_@@_leftarm_pattern_tl
222 \tl_new:N \l_@@_rightarm_pattern_tl
223 \tl_new:N \l_@@_body_pattern_tl
224 \tl_new:N \l_@@_leftarm_deco_tl
225 \tl_new:N \l_@@_rightarm_deco_tl
226 \tl_new:N \l_@@_body_deco_tl
227 \tl_new:N \l_@@_tikzkeys_tl
228
229 \keys_define:nn {@@}
230 {
231 ,leftarm .tl_set:N = \l_@@_leftarm_color_tl
232 ,leftarm .initial:n = {@@europablue}
233 ,leftarm~pattern .tl_set:N = \l_@@_leftarm_pattern_tl
234 ,leftarm~deco .code:n =
235 {\tl_set:Nn \l_@@_leftarm_deco_tl {path~picture = {#1}}}
236 ,rightarm .tl_set:N = \l_@@_rightarm_color_tl
237 ,rightarm .initial:n = {@@europablue}
238 ,rightarm~pattern .tl_set:N = \l_@@_rightarm_pattern_tl
239 ,rightarm~deco .code:n =
240 {\tl_set:Nn \l_@@_rightarm_deco_tl {path~picture = {#1}}}
241 ,body .tl_set:N = \l_@@_body_color_tl
242 ,body .initial:n = {@@europablue}
243 ,body~pattern .tl_set:N = \l_@@_body_pattern_tl
244 ,arms .meta:n = {leftarm={#1},rightarm={#1}}
245 ,arms~pattern .meta:n = {leftarm~pattern={#1},rightarm~pattern={#1}}
246 ,arms~deco .meta:n = {leftarm~deco={#1},rightarm~deco={#1}}
247 ,shirt .meta:n = {body={#1},leftarm={#1},rightarm={#1}}
248 ,shirt~pattern .meta:n =
249 {body~pattern={#1},leftarm~pattern={#1},rightarm~pattern={#1}}
250 ,shirt~deco .meta:n =
251 {body~deco={#1},leftarm~deco={#1},rightarm~deco={#1}}
252 ,long~sleeves .bool_set_inverse:N = \l_@@_t_shirt_bool
253 ,t-shirt .bool_set:N = \l_@@_t_shirt_bool
254 ,muscle~shirt .bool_set:N = \l_@@_muscle_shirt_bool
255 ,body~deco .code:n =
256 {\tl_set:Nn \l_@@_body_deco_tl {path~picture = {#1}}}
257 ,round~neckline .bool_set_inverse:N = \l__bearwear_v_neckline_bool
258 ,v-neckline .bool_set:N = \l__bearwear_v_neckline_bool
259 }
260
261 \NewDocumentCommand\bearwearsetup { m }
262 {
263 \keys_set:nn { @@ } {#1}
264 }
265 \NewDocumentCommand\bearwear { O {} }
266 {
267 \begin{scope}[even~odd~rule]
268 % handle keys
269 \keys_set_known:nnN { @@ } {#1}\l_@@_tikzkeys_tl
270 \exp_args:No\tikzset{\l_@@_tikzkeys_tl}
271 \@@_init_path:
272 \@@_set_coordinates:
273 \@@_clipping_path:
274 \@@_shirt_color:
275 \@@_shirt_pattern:
276 \@@_shirt_deco:
277 \end{scope}
278 }
279
280 \NewDocumentCommand\bearwearlogo {} {{
281 \normalfont\fontencoding{T1}\fontfamily{AlegreyaSans-LF}\selectfont
282 BearWear
283 \raisebox{0.8ex}[0pt][0pt]{
284 %\textcircled{
285 \begin{tikzpicture}[baseline={(0,0.03)},scale=\fp_eval:n{\f@size/100}]
286 \bear;
287 \bearwear[body~deco={\node[text=white] at (beartummy)
288 {\fontsize{\fp_eval:n{\f@size/20}pt}{\fp_eval:n{\f@size/20}pt}
289 \sffamily
290 BearWear};}]
291 \end{tikzpicture}}}}%}
292 %</package>
293 % \end{macrocode}
294 %<*docu>
295 \section{Basic Usage}
296
297 The package is based on \TikZ{} and the main command should be used in a \texttt{tikzpicture} or -- as shown in some of the examples -- with \verb+\tikz+.
298
299 \subsection{The shirts}
300 The package provides a number of shirts for the bear, \bearwearkey{long sleeves} and \bearwearkey{round neckline} are the defaults:
301 \begin{tcblisting}{righthand width=6cm}
302 \tikz\bearwear % default
303 [long sleeves,
304 round neckline];
305 \tikz\bearwear
306 [t-shirt];
307 \tikz\bearwear
308 [muscle shirt];
309
310 \tikz\bearwear
311 [v-neckline];
312 \tikz\bearwear
313 [t-shirt,v-neckline];
314 \tikz\bearwear
315 [muscle shirt,v-neckline];
316 \end{tcblisting}
317
318 \subsection{Dressing the bear}
319
320 To dress the bear with the shirt, simply add the \verb+\bear+ command from the \bearwearkey{tikzlings-bears} package.
321
322 \begin{tcblisting}{before=\parindent0pt\nopagebreak}
323 \tikz{\bear\bearwear[v-neckline];}
324 \tikz{\bear\bearwear[muscle shirt];}
325 \end{tcblisting}
326
327 \subsection{Coloring the shirts}
328
329 The body and the arms of the shirts can be colored. They are three basic keys: \bearwearkey{leftarm}, \bearwearkey{rightarm} and \bearwearkey{body}, and two meta keys: \bearwearkey{arms} and \bearwearkey{shirt}.
330 Basically every option that would make sense in a \lstinline|\fill| is allowed here.
331 Patterns e.g. would work too.
332 \begin{tcblisting}{tikz lower}
333 \bear
334 \bearwear
335 [v-neckline,
336 leftarm=red,
337 rightarm=green,
338 body=blue]
339 \end{tcblisting}
340 \begin{tcblisting}{tikz lower}
341 \bear
342 \bearwear[arms=green]
343 \end{tcblisting}
344 \begin{tcblisting}{tikz lower}
345 \bear
346 \bearwear
347 [shirt=
348 {shade,
349 top color=blue,
350 bottom color=red}]
351 \end{tcblisting}
352
353
354
355 \begin{tcblisting}{tikz lower,before=\parindent0pt\nopagebreak}
356 \bear
357 \bearwear
358 [v-neckline,
359 shirt =
360 {pattern=
361 horizontal lines light blue}]
362 \end{tcblisting}
363
364 \subsection{Additional patterns}
365
366 As seen in the last example patterns can be added instead of colors, but sometimes it makes sense to
367 add them on top to preserve a background color. For this the package provides special \texttt{pattern} keys:\\
368 \bearwearkey{leftarm pattern}, \bearwearkey{rightarm pattern}, \bearwearkey{arms pattern},
369 \bearwearkey{body pattern}, \bearwearkey{shirt pattern},
370
371 \begin{tcblisting}{tikz lower}
372 \bear
373 \bearwear
374 [v-neckline,
375 shirt=red,
376 body pattern =
377 {pattern=
378 {Stars[points=6,
379 radius=0.5mm,distance=1.5mm]},
380 pattern color=yellow}]
381 \end{tcblisting}
382
383 \subsection{Decorations}
384
385 The \lstinline|deco| keys add their value to a \texttt{path picture} key. This can be used to place emblems or use graphics as pattern. To help with the placement two coordinates are
386 predefined: \bearwearkey{bearheart} and \bearwearkey{beartummy}.
387
388 \begin{tcblisting}{tikz lower}
389 \bear
390 \bearwear[shirt deco =
391 {\fill[red] (beartummy) circle (1pt);
392 \fill[red] (bearheart) circle (1pt);}
393 ]
394 \end{tcblisting}
395
396 \begin{tcblisting}{tikz lower}
397 \bear
398 \bearwear[shirt deco =
399 {\node at (beartummy)
400 {\includegraphics[width=5cm]
401 {tartan3}};}]
402 \end{tcblisting}
403
404 \begin{tcblisting}{tikz lower}
405 \bear
406 \bearwear[body deco=
407 {\node at ([yshift=-1mm]bearheart)
408 {\includegraphics[width=0.3cm]
409 {flag}};}]
410 \end{tcblisting}
411
412 \begin{tcblisting}{tikz lower}
413 \bear
414 \bearwear[
415 shirt=Beige!80!black,
416 body deco=
417 {\node at ([yshift=-1mm]bearheart)
418 {\includegraphics[width=0.5cm]
419 {latex-project-logo}};}]
420 \end{tcblisting}
421
422 \begin{tcblisting}{tikz lower}
423 \bear
424 \bearwear[
425 shirt=HotPink,
426 body deco=
427 {\path (bearheart)--++(0,-3mm)
428 pic{hippo};}];
429 \end{tcblisting}
430
431 \begin{tcblisting}{tikz lower}
432 \bear
433 \bearwear[
434 arms= DeepSkyBlue,
435 body deco =
436 {\node at ([yshift=-2mm]beartummy)
437 {\includegraphics[width=4cm]
438 {montblanc}};
439 \node[text=white,
440 font=\tiny\sffamily]
441 at ([yshift=1.95mm]beartummy)
442 {{Mont Blanc}};
443 }]
444 \end{tcblisting}
445
446 \subsection{Scaling}
447
448 Scaling works as expected, but don't forget that nodes in \TikZ{} normally don't scale if you don't use the \lstinline|transform shape| key.
449 You can use a scope for the scaling, or the \texttt{scale} key as as unknown keys are passed to tikz --
450 in this case don't forget that both
451 the bear and the shirt needs the same scaling factor.
452
453 \begin{tcblisting}{tikz lower,before=\parindent0pt\nopagebreak,}
454 \begin{scope}[scale=1.5]
455 \bear
456 \bearwear[
457 arms= DeepSkyBlue,
458 body deco =
459 {\node at ([yshift=-2mm]beartummy)
460 {\includegraphics[width=4cm]
461 {montblanc}};
462 \node[text=white,
463 font=\tiny\sffamily]
464 at ([yshift=2mm]beartummy)
465 {{Mont Blanc}};
466 }]
467 \end{scope}
468 \end{tcblisting}
469
470 \begin{tcblisting}{tikz lower,before=\parindent0pt\nopagebreak,}
471 \bear[scale=0.7]
472 \bearwear[scale=0.7,
473 arms= DeepSkyBlue,
474 body deco =
475 {\node at ([yshift=-2mm]beartummy)
476 {\includegraphics[width=4cm]
477 {montblanc}};
478 \node[text=white,
479 font=\tiny\sffamily]
480 at ([yshift=2mm]beartummy)
481 {{Mont Blanc}};
482 }]
483 \end{tcblisting}
484
485 \subsection{Moving}
486
487 It is possible to move the bear and the shirt with it. Ensure that the same shift
488 is used if you don't want to undress the bear.
489
490 \begin{tcblisting}{tikz lower,before=\parindent0pt\nopagebreak,}
491 \coordinate (newbear) at (3,0);
492 \bear\bearwear
493 \bear[shift=(newbear)]\bearwear[shirt=red,shift=(newbear)]
494 \end{tcblisting}
495
496 \subsection{Setting up defaults}
497
498 With \lstinline|\bearwearsetup| you can change the defaults:
499
500 \begin{tcblisting}{}
501 \bearwearsetup
502 {body=green!50!black,arms=green}
503 \tikz{\bear;\bearwear;}
504 \tikz{\bear;\bearwear;}
505 \end{tcblisting}
506 \section{The brains behind \texorpdfstring{\bearwearlogo{}}{BearWear}}
507 \includegraphics[width=3cm]{baer}
508 \begin{description}
509 \item[Ulrike]
510 Bär, your decision to create \bearwearlogo{} has come as a surprise to many. Did you expect this?
511 \item[Bär] Quite true, Ulrike. I am better known as an outdoor type
512 and the fashionistas didn't reckon with me at all.
513 \item[Ulrike] So, why did you take this step?
514 \item[Bär] There were quite a few reasons -- most importantly
515 my deeply felt desire to bring more justice to the world.
516 Look at the wonderful world of \TikZ ducks fashion, and even Marmots have come
517 far in the area of refinement. Why should \TikZ bears be left behind?
518 \item[Ulrike] You are also concerned with the more momentous issues of our day.
519 \item[Bär] Correct! My fashion line is the first ever to have practically
520 no negative influence on our environment. Manufacture and transportation
521 are ecologically neutral. In fact it's the first time in the
522 history of world economy that goods are produced without
523 the use of raw materials.
524 \item[Ulrike] You claim that \bearwearlogo{} will have a global impact.
525 \item[Bär] Yes, the issue of globalization is one which has been interesting
526 me for a long time. \bearwearlogo{} caters for the needs of \TikZ bears all
527 over the world. There is the Longshirt Line for those who live near the poles,
528 t-shirts for those in temperate regions and even a Muscle Shirt Line for the
529 bears of Australia.
530 \item[Ulrike] How about individuality?
531 \item[Bär] I am particularly proud that \bearwearlogo{} enables every single
532 bear to create his own personal shirt -- free of the dictates of the modern
533 Brummells. He may use my suggestions but he need not do so.
534 \item[Ulrike] Will you be seen wearing your own creations?
535 \item[Bär] Well Ulrike, I am afraid this is not very likely.
536 I have got this most beautiful fur and I'd hate to cover it with artifical
537 patterns -- no matter how ravishing.
538 \item[Ulrike] One last question: what impulse got you moving towards
539 \bearwearlogo{}?
540 \item[Bär] The death of Karl Lagerfeld. Someone had to fill the void.
541 \end{description}
542 %</docu>