Debian Codegraph @

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

raw
1 % \iffalse meta-comment
2 %
3 % File: ducksay.dtx Copyright (C) 2017-2025 Jonathan P. Spratte
4 %
5 % This work may be distributed and/or modified under the conditions of the
6 % LaTeX Project Public License (LPPL), either version 1.3c of this license or
7 % (at your option) any later version. The latest version of this license is in
8 % the file:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % ------------------------------------------------------------------------------
13 %
14 %<*driver>^^A>>=
15 \def\nameofplainTeX{plain}
16 \ifx\fmtname\nameofplainTeX\else
17 \expandafter\begingroup
18 \fi
19 \input l3docstrip.tex
20 \askforoverwritefalse
21 \preamble
22
23 --------------------------------------------------------------
24 ducksay -- cowsay for LaTeX
25 E-mail: [email protected]
26 Released under the LaTeX Project Public License v1.3c or later
27 See http://www.latex-project.org/lppl.txt
28 --------------------------------------------------------------
29
30 Copyright (C) 2017-2025 Jonathan P. Spratte
31
32 This work may be distributed and/or modified under the conditions of the
33 LaTeX Project Public License (LPPL), either version 1.3c of this license or
34 (at your option) any later version. The latest version of this license is in
35 the file:
36
37 http://www.latex-project.org/lppl.txt
38
39 This work is "maintained" (as per LPPL maintenance status) by
40 Jonathan P. Spratte.
41
42 This work consists of the file ducksay.dtx
43 and the derived files ducksay.pdf
44 ducksay.sty
45 ducksay.code.v1.tex
46 ducksay.code.v2.tex and
47 ducksay.animals.tex.
48
49 \endpreamble
50 % stop docstrip adding \endinput
51 \postamble
52 \endpostamble
53 \generate{\file{ducksay.sty}{\from{ducksay.dtx}{pkg}}}
54 \generate{\file{ducksay.code.v1.tex}{\from{ducksay.dtx}{code.v1}}}
55 \generate{\file{ducksay.code.v2.tex}{\from{ducksay.dtx}{code.v2}}}
56 \generate{\file{ducksay.animals.tex}{\from{ducksay.dtx}{animals}}}
57 \ifx\fmtname\nameofplainTeX
58 \expandafter\endbatchfile
59 \else
60 \expandafter\endgroup
61 \fi
62 %
63 \ProvidesFile{ducksay.dtx}
64 [\csname ducksay@date\endcsname\ cowsay for LaTeX]
65 \documentclass{l3doc}
66 % silence the false positives about internal control sequences in the animals
67 \csname msg_redirect_name:nnn\endcsname{l3doc}{foreign-internal}{none}
68 \usepackage[version=2]{ducksay}
69 \usepackage{marginnote}
70 \AddColoredAnimal{colored-small-duck}
71 { \
72 \
73 \color{orange}>\color{yellow}()_
74 \color{yellow}(__)\color{blue}__ _}
75 \usepackage{xcolor}
76 \newcommand\sinceversion[1]
77 {\marginnote{\footnotesize\textsf{v#1}\kern-\marginparsep}}
78 \let\metaORIG\meta
79 \protected\def\meta #1{\texttt{\metaORIG{#1}}}
80 \DucksayOptions{arg=tab,msg-align=l,vpad=1}
81 \renewcommand*\thefootnote{\fnsymbol{footnote}}
82 \newcommand*\anml{\meta{animal}}
83 \newcommand*\msg{\meta{message}}
84 \newcommand*\PolesInfo
85 {%
86 \href{https://ctan.org/pkg/l3kernel}{\file{interface3.pdf}} and the
87 documentation of \href{https://ctan.org/pkg/xcoffins}{\pkg{xcoffins}} for
88 information about coffin poles%
89 }
90 \usepackage{enumitem}
91 \newenvironment{options}[1][]
92 {%
93 \begin{description}
94 [
95 style=nextline
96 ,font=\normalfont\ttfamily
97 ,labelindent=-.5\marginparwidth
98 ,labelwidth=\dimexpr.5\marginparwidth-5pt\relax
99 ,labelsep*=5pt
100 ,leftmargin=!
101 ,#1
102 ]%
103 \renewenvironment{options}[1][]
104 {%
105 \begin{description}
106 [
107 style=nextline
108 ,font=\normalfont\ttfamily
109 ,#1
110 ]%
111 }
112 {\end{description}}%
113 }
114 {\end{description}}
115 \makeatletter
116 \renewcommand*\paragraph
117 {%
118 \@startsection
119 {paragraph}
120 {4}
121 {\z@}
122 {-3.25ex \@plus -1ex \@minus -.2ex}
123 {1ex \@plus .2ex}
124 {\normalfont\normalsize\bfseries}%
125 }
126 \newcommand*\availableAnimal[1]
127 {%
128 \@for\cs:=#1\do
129 {%
130 \ifx\cs\@empty\else
131 \rlap{\expandafter\ducksay\expandafter[\cs]{\cs}}\hfill\null\par%
132 \fi
133 }%
134 }
135 \def\@oddfoot
136 {%
137 \null\hfil
138 \makebox[0pt][c]
139 {%
140 \smash
141 {%
142 \ducksay
143 [dog,body=\tiny,wd=3,msg-align=c,out-v=T,MSG=\normalsize,vpad=0]
144 {\thepage}%
145 }%
146 }%
147 \hfil\null
148 }
149 \let\@evenfoot\@oddfoot
150 \def\@oddhead
151 {%
152 \null\hfill\firstmark
153 }
154 \let\@evenhead\@oddhead
155 \newcommand\DocImp{}
156 \newcommand\SetVersion[1]
157 {%
158 \clearpage
159 \if\relax\detokenize{#1}\relax
160 \markboth{}{}%
161 \else
162 \markboth{}{\DocImp\ of Version #1}%
163 \fi
164 }
165 \makeatother
166 \setcounter{secnumdepth}{5}
167 \setcounter{tocdepth}{3}
168 \NewDocumentCommand \tocmsg {}
169 {%
170 \marginpar
171 {%
172 \tiny
173 \hfil
174 \makebox[.\marginparwidth][l]
175 {%
176 \ducksay[head-in,MSG=\footnotesize,msg-align=c]
177 {It's always\\good to\\keep the\\overview!}%
178 }%
179 }%
180 \unskip
181 }
182 \addtocontents{toc}{\protect\tocmsg\vspace*{-\baselineskip}}
183 \newcommand*\closingpage%>>=
184 {%
185 \clearpage
186 \thispagestyle{empty}
187 \bgroup
188 \Huge
189 \null\vfill
190 \centering
191 \makebox[0pt]{\duckthink{Who's gonna use it anyway?}}
192 \vfill
193 \hfill
194 \smash
195 {%
196 \footnotesize
197 \ducksay[small-yoda,wd=39,ht=3,msg-align=c,body-align=r]
198 {Hosted at\\\url{https://github.com/Skillmon/ltx_ducksay}\\it is.}%
199 }
200 \egroup
201 \clearpage
202 }%=<<
203 \begin{document}
204 \DocInput{ducksay.dtx}
205 \end{document}
206 %</driver>^^A=<<
207 %<*pkg>^^A>>=
208 \NeedsTeXFormat{LaTeX2e}
209 \@ifundefined{NewDocumentCommand}{\RequirePackage{xparse}}{}
210
211 \def\ducksay@version{2.8}
212 \def\ducksay@date{2025-11-22}
213
214 \ProvidesExplPackage
215 {ducksay} {\ducksay@date}
216 {\ducksay@version} {cowsay for LaTeX}
217
218 %</pkg>
219 %^^A=<<
220 % \fi
221 %
222 % \begin{titlepage}^^A>>=
223 % \DucksayOptions{vpad=0}%
224 % \makeatletter
225 % \centering
226 % \Large
227 % \ducksay[duck,MSG=\huge,msg-align=c]{This is\\\pkg{ducksay}!}\\
228 % \vfill
229 % \normalsize
230 % \hspace*{-2cm}
231 % \ducksay[cow,MSG=\large,body-mirrored,body-align=r,msg-to-body=hc,out-h=r]
232 % {v\ducksay@version}\\
233 % \small
234 % \vspace*{-5cm}\hspace*{5cm}
235 % \ducksay[small-duck,MSG=\normalsize]{But which Version?}
236 % \null\hfil
237 % \vspace{2cm}
238 % \vfill
239 % \vfill
240 % \hspace*{-0cm}
241 % \large
242 % \smash{%
243 % \ducksay[r2d2,MSG=\large,body-mirrored,msg-to-body=hc,body-to-msg=r]
244 % {by Jonathan P. Spratte}}
245 % \small
246 % \ducksay[hedgehog,MSG=\normalsize]{Today is \ducksay@date}
247 % \makeatother
248 % \end{titlepage}^^A=<<
249 % \tableofcontents
250 %
251 % \begin{documentation}^^A>>=
252 %
253 % \marginpar^^A>>=
254 % {
255 % \tiny
256 % \hfill
257 % \ducksay
258 % [sheep,MSG=\footnotesize,t,body-align=c,msg-align=c,body-mirrored]
259 % {Give credit\\where credit is due!}
260 % }^^A=<<
261 % \section{Acknowledgements}%
262 % \begingroup
263 % \scriptsize
264 % \DucksayOptions{MSG=\normalsize}
265 % \ducksay[sheep]{I was created by Plergux!\footnotemark}
266 % \footnotetext
267 % {\url{https://chat.stackexchange.com/transcript/message/55986902\#55986902}}
268 % \endgroup
269 % \clearpage
270 %
271 % \marginpar^^A>>=
272 % {
273 % \tiny
274 % \hfill
275 % \ducksay
276 % [knight,MSG=\footnotesize,t,body-align=r,msg-align=c]
277 % {Just beest mod'rn,\\thee peasant!}
278 % }^^A=<<
279 % \section{Documentation}\def\DocImp{Documentation}%
280 %
281 % This is \pkg{ducksay}! A \texttt{cowsay} for \LaTeX. \pkg{ducksay} is part of
282 % \TeX Live and MiK\TeX\ since September 2017. If it is not part of your
283 % installation it means that your \LaTeX\ installation is \emph{really} out of
284 % date, you have two options: Update your installation or try to install
285 % \pkg{ducksay} yourself. Chances are that if you opt for the latter, the
286 % version of \pkg{expl3} in your \LaTeX\ installation is too old, too, and the
287 % \pkg{l3regex} module is not yet part of \pkg{expl3}. In that case you'll get a
288 % few undefined control sequence errors. |\usepackage{l3regex}| prior to loading
289 % \pkg{ducksay} might fix these issues. Additionally you'll need
290 % \href{https://ctan.org/pkg/grabbox}{\pkg{grabbox}} for version~2 of
291 % \pkg{ducksay} that won't be part of your \LaTeX\ installation, too. Please
292 % note that I don't actively support out of date \LaTeX\ installations, so if
293 % loading \pkg{l3regex} doesn't fix the issues and you're on an old
294 % installation, I won't provide further support.
295 %
296 % \subsection{Downward Compatibility Issues}\label{sec:down}^^A>>=
297 % \marginpar^^A>>=
298 % {
299 % \tiny
300 % \ducksay[snail,MSG=\footnotesize]{Yep, I screwed up!}
301 % }^^A=<<
302 %
303 % In the following list I use the term ``version'' to refer to package versions,
304 % the same is true if I use an abbreviation like ``v2.0'' (or anything that
305 % matches the regular expression |v\d+(.\d+)?|). For the code variant which can
306 % be set using the |version| option I'll use the term ``variant'' or specify
307 % directly that I'm referring to that option (the used font may be a hint, too).
308 %
309 % \begin{itemize}
310 % \item
311 % \sinceversion{2.0}
312 % Versions prior to v2.0 did use a regular expression for the option
313 % |ligatures|, see \autoref{sec:options} for more on this issue.
314 % \item In a document created with package versions prior to v2.0 you'll have
315 % to specify the option |version=1| with newer package versions to make
316 % those old documents behave like they used to.
317 % \item
318 % \sinceversion{2.3}
319 % Since v2.3 \cs{AddAnimal} and \cs{AddColoredAnimal} behave
320 % differently. You no longer have to make sure that in the first three lines
321 % every backslash which is only preceded by spaces is the bubble's tail.
322 % Instead you can specify which symbol should be the tail and how many of
323 % such symbols there are. See \autoref{sec:macros} for more about the
324 % current behaviour.
325 % \item
326 % \sinceversion{2.4}
327 % The |add-think| key was deprecated in v2.3 and was removed in v2.4 since
328 % the output symbols of the bubble tail are handled differently and more
329 % efficiently now.
330 % \item
331 % \sinceversion{2.8}
332 % The |tail-symbol| key no longer fixes the category code of its value to 12
333 % and you have to make sure that the correct category code is handed in. The
334 % key |gen-tail-symbol| might help. See \autoref{sec:addoptions}.
335 % \end{itemize}^^A=<<
336 %
337 % \subsection{Shared between versions}^^A>>=
338 %
339 % \subsubsection{Macros}\label{sec:macros}^^A>>=
340 % \marginpar^^A>>=
341 % {
342 % \tiny
343 % \hfill
344 % \ducksay[bunny,MSG=\footnotesize,body-mirrored]
345 % {Macros for everyone!}
346 % }^^A=<<
347 %
348 % A careful reader might notice that in the below list of macros there is no
349 % \cs{ducksay} and no \cs{duckthink} contained. This is due to differences
350 % between the two usable code variants (see the |version| key in
351 % \autoref{sec:options} for the code variants, \autoref{sec:macros1} and
352 % \autoref{sec:macros2} for descriptions of the two macros).
353 %
354 % \begin{function}{\DefaultAnimal}^^A>>=
355 % \begin{syntax}
356 % \cs{DefaultAnimal}\marg{animal}
357 % \end{syntax}
358 % use the \anml\ if none is given in the optional argument to \cs{ducksay}
359 % or \cs{duckthink}. Package default is |duck|.
360 % \end{function}^^A=<<
361 %
362 % \begin{function}{\DucksayOptions}^^A>>=
363 % \begin{syntax}
364 % \cs{DucksayOptions}\marg{options}
365 % \end{syntax}
366 % set the defaults to the keys described in \autoref{sec:options},
367 % \autoref{sec:options1} and \autoref{sec:options2}. Don't use an \anml\ here,
368 % it has no effect.
369 % \end{function}^^A=<<
370 %
371 % \begin{function}{\AddAnimal}^^A>>=
372 % \begin{syntax}
373 % \cs{AddAnimal}\meta{*}\oarg{options}\marg{animal}\meta{ascii-art}
374 % \end{syntax}
375 % adds \anml\ to the known animals. \meta{ascii-art} is multi-line verbatim
376 % and therefore should be delimited either by matching braces or by anything
377 % that works for \cs{verb}. If the star is given \anml\ is the new default.
378 % One space is added to the begin of \anml\ (compensating the opening symbol).
379 % The symbols signalizing the speech bubble's tail (in the |hedgehog| example
380 % below the two |s|) can be set using the |tail-symbol| option and only the
381 % first |tail-count| occurrences will be substituted (see
382 % \autoref{sec:addoptions} for more about these options). For example,
383 % |hedgehog| is added with:\\[1ex]
384 % \begin{minipage}{\linewidth}
385 %\begin{verbatim}
386 % \AddAnimal[tail-symbol=s]{hedgehog}
387 % { s .\|//||\||.
388 % s |/\/||/|//|/|
389 % /. `|/\\|/||/||
390 % o__,_|//|/||\||'}
391 %\end{verbatim}
392 % \end{minipage}\\[1ex]
393 % It is not checked whether the animal already exists, you could therefore
394 % redefine existing animals with this macro.
395 % \end{function}^^A=<<
396 %
397 % \begin{function}{\AddColoredAnimal}^^A>>=
398 % \begin{syntax}
399 % \cs{AddColoredAnimal}\meta{*}\oarg{options}\marg{animal}\meta{ascii-art}
400 % \end{syntax}
401 % \newcommand*\bp{\hspace{0pt}}^^A
402 % It does the same as \cs{AddAnimal} but allows three different colouring
403 % syntaxes. You can use \cs{textcolor} in the \meta{ascii-art} with the syntax
404 % \texttt{\cs{textcolor}\marg{color}\marg{text}}. Note that you can't
405 % use braces in the arguments of \cs{textcolor}.\\
406 % You can also use a delimited \cs{color} of the form
407 % \texttt
408 % {\cs{bgroup}\bp\cs{color}\bp\marg{color}\bp\meta{text}\bp\cs{egroup}},
409 % a space after that |\egroup| will be considered a space in the output, so
410 % you don't have to care for correct termination of the |\egroup| (so
411 % \texttt{\cs{bgroup}\bp \cs{color}\bp\{red\}\bp RedText\bp
412 % \cs{egroup}OtherText} is valid syntax). You can't nest delimited
413 % \cs{color}s.\\
414 % Also you can use an undelimited \cs{color}. It affects anything until the
415 % end of the current line (or, if used inside of the \meta{text} of a
416 % delimited \cs{color}, anything until the end of that delimited \cs{color}'s
417 % \meta{text}). The syntax would be \cs{color}\marg{color}.\\
418 % The package doesn't load anything providing those colouring commands for you
419 % and it doesn't provide any coloured animals. The parsing is done using
420 % regular expressions provided by \LaTeX3. It is therefore slower than the
421 % normal \cs{AddAnimal}.\\[1ex]
422 % \begin{minipage}{.6\linewidth}
423 %\begin{verbatim}
424 % \AddAnimal{colored-small-duck}
425 % { \
426 % \
427 % \color{orange}>\color{yellow}()_
428 % \color{yellow}(__)\color{blue}__ _}
429 %\end{verbatim}
430 % \end{minipage}\hfill
431 % \ducksay[colored-small-duck]{Don't I look fabulous?}
432 % \end{function}^^A=<<
433 %
434 % \begin{function}{\AnimalOptions}^^A>>=
435 % \begin{syntax}
436 % \cs{AnimalOptions}\meta{*}\marg{animal}\marg{options}
437 % \end{syntax}
438 % With this macro you can set \anml\ specific \meta{options}. If the star is
439 % given any currently set options for this \anml\ are dropped and only the
440 % ones specified in \meta{options} will be applied, else \meta{options} will
441 % be added to the set options for this \anml. The set \meta{options} can
442 % set the |tail-1| and |tail-2| options and therefore overwrite the effects of
443 % \cs{duckthink}, as \cs{duckthink} really is just \cs{ducksay} with the
444 % |think| option.
445 % \end{function}^^A=<<
446 %
447 %^^A=<<
448 %
449 % \subsubsection{Options}\label{sec:options}^^A>>=
450 % \marginpar
451 % {%
452 % \vspace*{-2em}\tiny
453 % \ducksay[pig,MSG=\footnotesize]{Options.\\For every occasion}%
454 % }
455 % The following options are available independent on the used code variant (the
456 % value of the |version| key). They might be used as package options -- unless
457 % otherwise specified -- or used in the macros \cs{DucksayOptions}, \cs{ducksay}
458 % and \cs{duckthink} -- again unless otherwise specified. Some options might be
459 % accessible in both code variants but do slightly different things. If that's
460 % the case they will be explained in \autoref{sec:options1} and
461 % \autoref{sec:options2} for |version| 1 and 2, respectively.
462 % \begin{options}
463 % \item[version=\meta{number}]
464 % With this you can choose the code variant to be used. Currently |1| and
465 % |2| are available. This can be set only during package load time. For a
466 % dedicated description of each version look into \autoref{sec:v1} and
467 % \autoref{sec:v2}. The package author would choose |version=2|, the other
468 % version is mostly for legacy reasons. The default is |2|.
469 % \item[\anml]
470 % One of the animals listed in \autoref{sec:animals} or any of the ones
471 % added with \cs{AddAnimal}. Not useable as package option. Also don't use
472 % it in \cs{DucksayOptions}, it'll break the default animal selection.
473 % \item[animal=\anml]
474 % Locally sets the default animal. Note that \cs{ducksay} and \cs{duckthink}
475 % do digest their options inside of a group, so it just results in
476 % a longer alternative to the use of \anml\ if used in their options.
477 % \item[ligatures=\meta{token list}]
478 % each token you don't want to form ligatures during \cs{AddAnimal} should
479 % be contained in this list. All of them get enclosed by grouping |{| and
480 % |}| so that they can't form ligatures. Giving no argument (or an empty
481 % one) might enhance compilation speed by disabling this replacement. The
482 % formation of ligatures was only observed in combination with
483 % |\usepackage[T1]{fontenc}| by the author of this package. Therefore giving
484 % the option |ligatures| without an argument might enhance the compilation
485 % speed for you without any drawbacks. Initially this is set to
486 % \texttt{\csuse{\detokenize{l_ducksay_ligatures_tl}}}.\\
487 % \textbf{Note:} In earlier releases this option's expected argument was a
488 % regular expression. This means that this option is not fully
489 % downward compatible with older versions. The speed gain however seems
490 % worth it (and I hope the affected documents are few).
491 % \item[no-tail]
492 % Sets |tail-1| and |tail-2| to be a space.
493 % \item[random=\meta{bool}]
494 % If |true| a random animal will be used instead of the default one on each
495 % usage of \cs{ducksay} or \cs{duckthink}. The initial value is false and it
496 % defaults to true.
497 % \item[say]
498 % Sets |tail-1| and |tail-2| as backslashes.
499 % \item[schroedinger]
500 % Sets randomly either |animal=schroedinger-alive| or
501 % |animal=schroedinger-dead| at the time of use. Both have the same size, so
502 % this doesn't affect the needed space.
503 % \item[tail-1=\meta{token list}]
504 % Sets the first tail symbol in the output to be \meta{token list}. If set
505 % outside of \cs{ducksay} and \cs{duckthink} it will be overwritten inside
506 % of \cs{duckthink} to be |O|.
507 % \item[tail-2=\meta{token list}]
508 % Sets every other tail symbol except the first one in the output to be
509 % \meta{token list}. If set outside of \cs{ducksay} and \cs{duckthink} it
510 % will be overwritten inside of \cs{duckthink} to be |o|.
511 % \item[think]
512 % Sets |tail-1=O| and |tail-2=o|.
513 % \end{options}
514 %
515 % \paragraph{Options for \cs{AddAnimal}}\label{sec:addoptions}
516 % The options described here are only available in \cs{AddAnimal} and
517 % \cs{AddColoredAnimal}.
518 % \begin{options}
519 % \item[tail-count=\meta{int}]
520 % sets the number of tail symbols to be replaced in \cs{AddAnimal} and
521 % \cs{AddColoredAnimal}. Initial value is 2. If the value is negative every
522 % occurrence of |tail-symbol| will be replaced.
523 % \item[tail-symbol=\meta{tl}]
524 % the symbol used in \cs{AddAnimal} and \cs{AddColoredAnimal} to mark the
525 % bubble's tail. In \LaTeX\ versions prior to 2025-06-01 the argument gets
526 % \cs{detokenize}d, starting with the 2025-06-01 kernel release you have to
527 % make sure that whatever you give to this key has the same category codes
528 % as are produced by the |v| argument type of |ltcmd| (you can use
529 % |tail-symbol:e| to fully expand the value which might help in producing
530 % the desired token). Initially a single backslash.
531 % \item[gen-tail-symbol=\meta{character}]
532 % this is a helper for |tail-symbol|. It sets |tail-symbol| to
533 % \meta{character} which might either be the character itself or an escaped
534 % variant of it for special characters. The |tail-symbol| will then be
535 % \meta{character} but with category code~12 (other). For instance you could
536 % use |gen-tail-symbol = \%| to use a percent character or
537 % |gen-tail-symbol = \\| for a backslash both with category 12 as
538 % |tail-symbol|.
539 % \end{options}
540 %^^A=<<
541 %
542 %^^A=<<
543 %
544 % \SetVersion{1}%
545 % \subsection{Version 1}\label{sec:v1}^^A>>=
546 %
547 % \subsubsection{Introducktion}^^A>>=
548 %
549 % This version is included for legacy support (old documents should behave the
550 % same without any change to them -- except the usage of |version=1| as an
551 % option, for a more or less complete list of downward compatibility related
552 % problems see \autoref{sec:down}). For the bleeding edge version of
553 % \pkg{ducksay} skip this subsection and read \autoref{sec:v2}.
554 %^^A=<<
555 %
556 % \subsubsection{Macros}\label{sec:macros1}^^A>>=
557 % \marginpar
558 % {%
559 % \rlap
560 % {%
561 % \tiny
562 % \ducksay[yoda,MSG=\footnotesize]{Use those, you might}%
563 % }%
564 % }
565 % The following is the description of macros which differ in behaviour from
566 % those of version 2.
567 %
568 % \begin{function}{\ducksay}^^A>>=
569 % \begin{syntax}
570 % \cs{ducksay}\oarg{options}\marg{message}
571 % \end{syntax}
572 % options might include any of the options described in \autoref{sec:options}
573 % and \autoref{sec:options1} if not otherwise specified. Prints an \anml\
574 % saying \msg. \msg\ is not read in verbatim. Multi-line \msg s are possible
575 % using |\\|. |\\| should not be contained in a macro definition but at
576 % toplevel. Else use the option |ht|.
577 % \end{function}^^A=<<
578 %
579 % \begin{function}{\duckthink}^^A>>=
580 % \begin{syntax}
581 % \cs{duckthink}\oarg{options}\marg{message}
582 % \end{syntax}
583 % options might include any of the options described in \autoref{sec:options}
584 % and \autoref{sec:options1} if not otherwise specified. Prints an \anml\
585 % thinking \msg. \msg\ is not read in verbatim. Multi-line \msg s are possible
586 % using |\\|. |\\| should not be contained in a macro definition but at
587 % toplevel. Else use the option |ht|.
588 % \end{function}^^A=<<
589 %^^A=<<
590 %
591 % \subsubsection{Options}\label{sec:options1}^^A>>=
592 % \marginpar
593 % {%
594 % \vspace*{-2em}\tiny
595 % \hfill
596 % \ducksay[hedgehog,MSG=\footnotesize]{Everyone likes\\options}%
597 % }
598 % The following options are available to \cs{ducksay}, \cs{duckthink}, and
599 % \cs{DucksayOptions} and if not otherwise specified also as package options:
600 % \begin{options}
601 % \item[bubble=\meta{code}]
602 % use \meta{code} in a group right before the bubble (for font switches).
603 % Might be used as a package option but not all control sequences work out
604 % of the box there.
605 % \item[body=\meta{code}]
606 % use \meta{code} in a group right before the body (meaning the \anml).
607 % Might be used as a package option but not all control sequences work out
608 % of the box there. E.g.\@ to right-align the \anml\ to the bubble, use
609 % |body=\hfill|.
610 % \item[align=\meta{valign}]
611 % use \meta{valign} as the vertical alignment specifier given to the
612 % \env{tabular} which is around the contents of \cs{ducksay} and
613 % \cs{duckthink}.
614 % \item[msg-align=\meta{halign}]
615 % use \meta{halign} for alignment of the rows of multi-line \msg s. It
616 % should match a \texttt{tabular} column specifier. Default is |l|. It only
617 % affects the contents of the speech bubble not the bubble.
618 % \item[rel-align=\meta{column}]
619 % use \meta{column} for alignment of the bubble and the body. It should
620 % match a \env{tabular} column specifier. Default is |l|.
621 % \item[wd=\meta{count}]
622 % in order to detect the width the \msg\ is expanded. This might not work
623 % out for some commands (e.g.\@ \cs{url} from \pkg{hyperref}). If you
624 % specify the width using |wd| the \msg\ is not expanded and
625 % therefore the command \emph{might} work out. \meta{count} should be the
626 % character count.
627 % \item[ht=\meta{count}]
628 % you might explicitly set the height (the row count) of the \msg. This only
629 % has an effect if you also specify |wd|.
630 % \end{options}
631 %^^A=<<
632 %
633 % \subsubsection{Defects}^^A>>=
634 % \begingroup
635 % \reversemarginpar
636 % \marginpar
637 % {\tiny\hfill\ducksay[frog,MSG=\footnotesize,t]{Ohh, no!}}
638 % \endgroup
639 % \begin{itemize}
640 % \item no automatic line wrapping
641 % \item message width detection based on token count with \cs{edef} expansion,
642 % might fail badly
643 % \end{itemize}^^A=<<
644 %
645 %^^A=<<
646 %
647 % \SetVersion{2}%
648 % \subsection{Version 2}\label{sec:v2}^^A>>=
649 % \marginpar^^A>>=
650 % {
651 % \fontsize{3.5pt}{3.5pt}\selectfont
652 % \makebox[\marginparwidth]
653 % {\ducksay[unicorn,MSG=\footnotesize]{Here's all the good stuff!}}%
654 % }^^A=<<
655 %
656 % \subsubsection{Introducktion}^^A>>=
657 %
658 % Version~2 is the current version of \pkg{ducksay}. It features automatic line
659 % wrapping (if you specify a fixed width) and in general more options (with some
660 % nasty argument parsing).
661 %
662 % If you're already used to version~1 you should note one important thing: You
663 % should only specify the |version| and the |ligatures| during package load time
664 % as arguments to \cs{usepackage}. The other keys might not work or do
665 % unintended things and only don't throw errors or warnings because of the
666 % legacy support of version~1. After the package is loaded, keys only used for
667 % version~1 will throw an error.
668 %
669 %^^A=<<
670 %
671 % \subsubsection{Macros}\label{sec:macros2}^^A>>=
672 % \marginpar^^A>>=
673 % {
674 % \tiny
675 % \ducksay[duck-family,MSG=\footnotesize,t,body-mirrored]
676 % {Look at those, kids!}
677 % }^^A=<<
678 %
679 % The following is the description of macros which differ in behaviour from
680 % those of version 1.
681 %
682 % \begin{function}{\ducksay}^^A>>=
683 % \begin{syntax}
684 % \cs{ducksay}\oarg{options}\marg{message}
685 % \end{syntax}
686 % options might include any of the options described in \autoref{sec:options}
687 % and \autoref{sec:options2} if not otherwise specified. Prints an \anml\
688 % saying \msg.\\
689 % The \msg\ can be read in in four different ways. For an explanation of the
690 % \msg\ reading see the description of the |arg| key in
691 % \autoref{sec:options2}.\\
692 % The height and width of the message is determined by measuring its
693 % dimensions and the bubble will be set accordingly. The box surrounding the
694 % message will be placed both horizontally and vertically centred inside of
695 % the bubble. The output utilizes \LaTeX3's coffin mechanism described in
696 % \href{https://ctan.org/pkg/l3kernel}{\file{interface3.pdf}} and the
697 % documentation of \href{https://ctan.org/pkg/xcoffins}{\pkg{xcoffins}}.
698 % \end{function}^^A=<<
699 %
700 % \begin{function}{\duckthink}^^A>>=
701 % \begin{syntax}
702 % \cs{duckthink}\oarg{options}\marg{message}
703 % \end{syntax}
704 % The only difference to \cs{ducksay} is that in \cs{duckthink} the \anml s
705 % think the \msg\ and don't say it.\\
706 % \end{function}^^A=<<
707 %
708 %^^A=<<
709 %
710 % \subsubsection{Options}\label{sec:options2}^^A>>=
711 % \marginpar^^A>>=
712 % {
713 % \tiny
714 % \hfill\ducksay[small-rabbit,MSG=\footnotesize]
715 % {Fast, use options!}
716 % }^^A=<<
717 % In version 2 the following options are available. Keep in mind that you
718 % shouldn't use them during package load time but in the arguments of
719 % \cs{ducksay}, \cs{duckthink} or \cs{DucksayOptions}.
720 % \begin{options}
721 % \item[arg=\meta{choice}]
722 % specifies how the \msg\ argument of \cs{ducksay} and \cs{duckthink} should
723 % be read in. Available options are |box|, |tab| and |tab*|:
724 % \begin{options}
725 % \item[box]
726 % the argument is read in either as a \cs{hbox} or a \cs{vbox} (the
727 % latter if a fixed width is specified with either |wd| or |wd*|). Note
728 % that in this mode any arguments relying on category code changes like
729 % e.g.\@ \cs{verb} will work (provided that you don't use \cs{ducksay}
730 % or \cs{duckthink} inside of an argument of another macro of course).
731 % \item[tab]
732 % the argument is read in as the contents of a \env{tabular}. Note that
733 % in this mode any arguments relying on category code changes like
734 % e.g.\@ \cs{verb} will \emph{not} work. This mode comes closest to the
735 % behaviour of version 1 of \pkg{ducksay}.
736 % \item[tab*]
737 % the argument is read in as the contents of a \env{tabular}. However it
738 % is read in verbatim and uses \cs{scantokens} to rescan the argument.
739 % Note that in this mode any arguments relying on category code changes
740 % like e.g.\@ \cs{verb} will work. You can't use \cs{ducksay} or
741 % \cs{duckthink} as an argument to another macro in this mode however.
742 % \end{options}
743 % \item[b]
744 % shortcut for |out-v=b|.
745 % \item[body=\meta{font}]
746 % add \meta{font} to the font definitions in use to typeset the \anml's
747 % body.
748 % \item[body*=\meta{font}]
749 % clear any definitions previously made (including the package default) and
750 % set the font definitions in use to typeset the \anml's body to
751 % \meta{font}. The package default is \cs{verbatim@font}. In addition
752 % \cs{frenchspacing} will always be used prior to the defined \meta{font}.
753 % \item[body-align=\meta{choice}]
754 % sets the relative alignment of the \anml\ to the \msg. Possible choices
755 % are |l|, |c| and |r|. For |l| the \anml\ is flushed to the left of the
756 % \msg, for |c| it is centred and for |r| it is flushed right. More fine
757 % grained control over the alignment can be obtained with the keys
758 % |msg-to-body|, |body-to-msg|, |body-x| and |body-y|. Package default is
759 % |l|.
760 % \item[body-bigger=\meta{count}]
761 % vertically enlarge the body by \meta{count} empty lines added to the
762 % bottom. This way top-aligning two different body types is easier (by
763 % actually bottom aligning the two):\par
764 % {\tiny
765 % \hfill\ducksay[ghost,body-x=-7mm,b,body-mirrored]{Buuuh!}
766 % \ducksay[crusader,body-bigger=4,b,out-h=r,no-bubble]{}
767 % }
768 % \hfill\begin{minipage}[b]{.6\textwidth}
769 % \footnotesize
770 %\begin{verbatim}
771 % \ducksay[ghost,body-x=-7mm,b,body-mirrored]{Buuuh!}
772 % \ducksay[crusader,body-bigger=4,b,out-h=r,no-bubble]{}
773 %
774 %
775 %\end{verbatim}
776 % \end{minipage}\hfill\null
777 % \item[body-mirrored=\meta{bool}]
778 % if set true the \anml\ will be mirrored along its vertical centre axis.
779 % Package default is |false|. If you set it |true| you'll most likely need
780 % to manually adjust the alignment of the body with one or more of the
781 % keys |body-align|, |body-to-msg|, |msg-to-body|, |body-x| and |body-y|.
782 % \item[body-to-msg=\meta{pole}]
783 % defines the horizontal coffin \meta{pole} to be used for the placement of
784 % the \anml\ beneath the \msg. See \PolesInfo.
785 % \item[body-x=\meta{dimen}]
786 % defines a horizontal offset of \meta{dimen} length of the \anml\ from its
787 % placement beneath the \msg.
788 % \item[body-y=\meta{dimen}]
789 % defines a vertical offset of \meta{dimen} length of the \anml\ from its
790 % placement beneath the \msg.
791 % \item[bubble=\meta{font}]
792 % add \meta{font} to the font definitions in use to typeset the bubble. This
793 % does not affect the \msg\ only the bubble put around it.
794 % \item[bubble*=\meta{font}]
795 % clear any definitions previously made (including the package default) and
796 % set the font definitions in use to typeset the bubble to \meta{font}. This
797 % does not affect the \msg\ only the bubble put around it. The package
798 % default is \cs{verbatim@font}.
799 % \item[bubble-bot-kern=\meta{dimen}]
800 % specifies a vertical offset of the placement of the lower border of the
801 % bubble from the bottom of the left and right borders.
802 % \item[bubble-delim-left-1=\meta{token list}]
803 % the left delimiter used if only one line of delimiters is needed. Package
804 % default is |(|.
805 % \item[bubble-delim-left-2=\meta{token list}]
806 % the upper most left delimiter used if more than one line of delimiters is
807 % needed. Package default is |/|.
808 % \item[bubble-delim-left-3=\meta{token list}]
809 % the left delimiters used to fill the gap if more than two lines of
810 % delimiters are needed. Package default is \verb+|+.
811 % \item[bubble-delim-left-4=\meta{token list}]
812 % the lower most left delimiter used if more than one line of delimiters is
813 % needed. Package default is |\|.
814 % \item[bubble-delim-right-1=\meta{token list}]
815 % the right delimiter used if only one line of delimiters is needed. Package
816 % default is |)|.
817 % \item[bubble-delim-right-2=\meta{token list}]
818 % the upper most right delimiter used if more than one line of delimiters is
819 % needed. Package default is |\|.
820 % \item[bubble-delim-right-3=\meta{token list}]
821 % the right delimiters used to fill the gap if more than two lines of
822 % delimiters are needed. Package default is \verb+|+.
823 % \item[bubble-delim-right-4=\meta{token list}]
824 % the lower most right delimiter used if more than one line of delimiters
825 % is needed. Package default is |/|.
826 % \item[bubble-delim-top=\meta{token list}]
827 % the delimiter used to create the top and bottom border of the bubble. The
828 % package default is |{-}| (the braces are important to suppress ligatures
829 % here).
830 % \item[bubble-side-kern=\meta{dimen}]
831 % specifies the kerning used to move the sideways delimiters added to fill
832 % the gap for more than two lines of bubble height. (the left one is moved
833 % to the left, the right one to the right)
834 % \item[bubble-top-kern=\meta{dimen}]
835 % specifies a vertical offset of the placement of the upper border of the
836 % bubble from the top of the left and right borders.
837 % \item[c]
838 % shortcut for |out-v=vc|.
839 % \item[col=\meta{column}]
840 % specifies the used column specifier used for the \msg\ enclosing
841 % \env{tabular} for |arg=tab| and |arg=tab*|. Has precedence over
842 % |msg-align|. You can also use more than one column this way:
843 % |\ducksay[arg=tab,col=cc]{ You & can \\ do & it }| would be valid syntax.
844 % \item[hpad=\meta{count}]
845 % Add \meta{count} times more |bubble-delim-top| instances than necassary to
846 % the upper and lower border of the bubble. Package default is 2.
847 % \item[ht=\meta{count}]
848 % specifies a minimum height (in lines) of the \msg. The lines' count is
849 % that of the needed lines of the horizontal bubble delimiters. If the
850 % count of the actually needed lines is smaller than the specified
851 % \meta{count}, \meta{count} lines will be used. Else the required lines
852 % will be used.
853 % \item[ignore-body=\meta{bool}]
854 % If set |true| the \anml's body will be added to the output but it will not
855 % contribute to the bounding box (so will not take up any space).
856 % \item[msg=\meta{font}]
857 % add \meta{font} to the font definitions in use to typeset the \msg.
858 % \item[msg*=\meta{font}]
859 % clear any definitions previously made (including the package default) and
860 % set the font definitions in use to typeset the \msg\ to \meta{font}. The
861 % package default is \cs{verbatim@font}.
862 % \item[MSG=\meta{font}]
863 % same as \texttt{msg=\meta{font}, bubble=\meta{font}}.
864 % \item[MSG*=\meta{font}]
865 % same as \texttt{msg*=\meta{font}, bubble*=\meta{font}}.
866 % \item[msg-align=\meta{choice}]
867 % specifies the alignment of the \msg. Possible values are |l| for flushed
868 % left, |c| for centred, |r| for flushed right and |j| for justified. If
869 % |arg=tab| or |arg=tab*| the |j| choice is only available for fixed width
870 % contents. Package default is |l|.
871 % \item[msg-align-c=\meta{token list}]
872 % set the \meta{token list} which is responsible to typeset the message
873 % centred if the option |msg-align=c| is used. It is used independent of the
874 % |arg| key. For |arg=tab| and |arg=tab*| it is only used if a fixed width
875 % is specified and the macro \cs{arraybackslash} provided by \pkg{array} is
876 % used afterwards. The package default is |\centering|. It might be useful
877 % if you want to use \pkg{ragged2e}'s \cs{Centering} for example.
878 % \item[msg-align-j=\meta{token list}]
879 % set the \meta{token list} which is responsible to typeset the message
880 % justified if the option |msg-align=j| is used. It is used independent of
881 % the |arg| key. For |arg=tab| and |arg=tab*| it is only used if a fixed
882 % width is specified and the macro \cs{arraybackslash} provided by
883 % \pkg{array} is used afterwards. The package default is empty as
884 % justification is the default behaviour of contents of a |p| column and of
885 % a \cs{vbox}. It might be useful if you want to use \pkg{ragged2e}'s
886 % \cs{justifying} for example.
887 % \item[msg-align-l=\meta{token list}]
888 % set the \meta{token list} which is responsible to typeset the message
889 % flushed left if the option |msg-align=l| is used. It is used independent
890 % of the |arg| key. For |arg=tab| and |arg=tab*| it is only used if a fixed
891 % width is specified and the macro \cs{arraybackslash} provided by
892 % \pkg{array} is used afterwards. The package default is |\raggedright|. It
893 % might be useful if you want to use \pkg{ragged2e}'s \cs{RaggedRight} for
894 % example.
895 % \item[msg-align-r=\meta{token list}]
896 % set the \meta{token list} which is responsible to typeset the message
897 % flushed right if the option |msg-align=r| is used. It is used independent
898 % of the |arg| key. For |arg=tab| and |arg=tab*| it is only used if a fixed
899 % width is specified and the macro \cs{arraybackslash} provided by
900 % \pkg{array} is used afterwards. The package default is |\raggedleft|. It
901 % might be useful if you want to use \pkg{ragged2e}'s \cs{RaggedLeft} for
902 % example.
903 % \item[msg-to-body=\meta{pole}]
904 % defines the horizontal coffin \meta{pole} to be used as the reference
905 % point for the placement of the \anml\ beneath the \msg. See \PolesInfo.
906 % \item[no-bubble=\meta{bool}]
907 % If |true| the \msg\ will not be surrounded by a bubble. Package default is
908 % of course |false|.
909 % \item[none=\meta{bool}]
910 % One could say this is a special animal. If |true| no animal body will be
911 % used (resulting in just the speech bubble). Package default is of course
912 % |false|.
913 % \item[out-h=\meta{pole}]
914 % defines the horizontal coffin \meta{pole} to be used as the anchor point
915 % for the print out of the complete result of \cs{ducksay} and
916 % \cs{duckthink}. See \PolesInfo.
917 % \item[out-v=\meta{pole}]
918 % defines the vertical coffin \meta{pole} to be used as the anchor point for
919 % the print out of the complete result of \cs{ducksay} and \cs{duckthink}.
920 % See \PolesInfo.
921 % \item[out-x=\meta{dimen}]
922 % specifies an additional horizontal offset of the print out of the complete
923 % result of \cs{ducksay} and \cs{duckthink}.
924 % \item[out-y=\meta{dimen}]
925 % specifies an additional vertical offset of the print out of the complete
926 % result of \cs{ducksay} and \cs{duckthink}
927 % \item[strip-spaces=\meta{bool}]
928 % if set |true| leading and trailing spaces are stripped from the \msg\ if
929 % |arg=box| is used. Initially this is set to |false|.
930 % \item[t]
931 % shortcut for |out-v=t|.
932 % \item[vpad=\meta{count}]
933 % add \meta{count} to the lines used for the bubble, resulting in
934 % \meta{count} more lines than necessary to enclose the \msg\ inside of the
935 % bubble.
936 % \item[wd=\meta{count}]
937 % specifies the width of the \msg\ to be fixed to \meta{count} times the
938 % width of an upper case M in the \msg's font declaration. A value smaller
939 % than 0 is considered deactivated, else the width is considered as fixed.
940 % For a fixed width the argument of \cs{ducksay} and \cs{duckthink} is read
941 % in as a \cs{vbox} for |arg=box| and the column definition uses a |p|-type
942 % column for |arg=tab| and |arg=tab*|. If both |wd| is not smaller than 0
943 % and |wd*| is not smaller than 0pt, |wd*| will take precedence.
944 % \item[wd*=\meta{dimen}]
945 % specifies the width of the \msg\ to be fixed to \meta{dimen}. A value
946 % smaller than 0pt is considered deactivated, else the width is considered
947 % as fixed. For a fixed width the argument of \cs{ducksay} and
948 % \cs{duckthink} is read in as a \cs{vbox} for |arg=box| and the column
949 % definition uses a |p|-type column for |arg=tab| and |arg=tab*|. If both
950 % |wd| is not smaller than 0 and |wd*| is not smaller than 0pt, |wd*| will
951 % take precedence.
952 % \item[wd-eq-body=\meta{bool}]
953 % if this is |true|, |wd| is smaller than 0, and |wd*| is smaller than 0pt
954 % the \msg\ will be as wide as the \anml's body. Note that because the
955 % \anml\ bodies contain white space on their left end and due to the
956 % additional horizontal bubble delimiters the bubble will be wider than the
957 % \anml's body. If the |none| option was also used this option has no
958 % effect.
959 % \end{options}
960 %
961 %^^A=<<
962 %
963 %^^A=<<
964 %
965 % \SetVersion{}%
966 % \subsection{Dependencies}^^A>>=
967 % \marginpar
968 % {%
969 % \tiny
970 % \rlap
971 % {%
972 % \ducksay
973 % [
974 % kangaroo,MSG=\footnotesize
975 % ,body-mirrored,body-to-msg=r,msg-to-body=hc
976 % ]
977 % {We rely on you}%
978 % }%
979 % }
980 % The package depends on the \LaTeX\ kernel, for older versions of \LaTeX\ the
981 % two packages \pkg{xparse} and \pkg{l3keys2e} and all of their dependencies are
982 % loaded. Version 2 additionally depends on \pkg{array} and \pkg{grabbox}.
983 %^^A=<<
984 %
985 % \subsection{Available Animals}\label{sec:animals}^^A>>=
986 % \marginpar
987 % {%
988 % \tiny
989 % \hfill
990 % \ducksay[ladybug,MSG=\footnotesize,msg-align=c]
991 % {This is a\\bug(fix) release.}%
992 % }
993 % The following animals are provided by this package. I did not create them (but
994 % altered some), they belong to their original creators.
995 % \bgroup
996 % \fontsize{6pt}{6pt}\selectfont
997 % \parindent=0pt
998 % \DucksayOptions{MSG=\footnotesize,vpad=0,arg=tab}
999 % \begin{multicols}{2}
1000 % \availableAnimal{^^A>>=
1001 % ,duck^^A
1002 % ,small-duck^^A
1003 % ,duck-family^^A
1004 % ,small-rabbit^^A
1005 % ,squirrel^^A
1006 % ,cow^^A
1007 % ,tux^^A
1008 % ,head-in^^A
1009 % ,pig^^A
1010 % ,frog^^A
1011 % ,snowman^^A
1012 % ,ladybug^^A
1013 % ,bunny^^A
1014 % ,dragon^^A
1015 % ,sodomized^^A
1016 % ,hedgehog^^A
1017 % ,platypus^^A
1018 % ,turtle^^A
1019 % ,kangaroo^^A
1020 % ,small-horse^^A
1021 % ,dog^^A
1022 % ,sheep^^A
1023 % ,rabbit^^A
1024 % ,snail^^A
1025 % ,whale^^A
1026 % ,snake^^A
1027 % ,cat^^A
1028 % ,sleepy-cat^^A
1029 % ,schroedinger-dead^^A
1030 % ,schroedinger-alive^^A
1031 % ,crusader^^A
1032 % ,knight^^A
1033 % ,fairy^^A
1034 % ,ghost^^A
1035 % ,unicorn^^A
1036 %^^A }\end{multicols}\begin{multicols}{2}
1037 %^^A \availableAnimal{^^A
1038 % ,r2d2^^A
1039 % ,vader^^A
1040 % ,yoda-head^^A
1041 % ,small-yoda^^A
1042 % ,yoda^^A
1043 % ,only-tail^^A
1044 % ,only-tail3^^A
1045 % }^^A=<<
1046 % \end{multicols}
1047 % \egroup
1048 %^^A=<<
1049 %
1050 % \subsection{License and Bug Reports}^^A>>=
1051 % \marginpar
1052 % {%
1053 % \rlap
1054 % {%
1055 % \tiny
1056 % \ducksay[squirrel,MSG=\footnotesize,t]
1057 % {WTFPL would be a\\better license.}%
1058 % }%
1059 % }
1060 % This work may be distributed and/or modified under the conditions of the
1061 % \LaTeX\ Project Public License (LPPL), either version 1.3c of this license
1062 % or (at your option) any later version. The latest version of this license is
1063 % in the file:
1064 % \url{http://www.latex-project.org/lppl.txt}
1065 %
1066 % The package is hosted on \url{https://github.com/Skillmon/ltx_ducksay}, you
1067 % might report bugs there.
1068 %^^A=<<
1069 %
1070 % \end{documentation}^^A=<<
1071 %
1072 % \begin{implementation}^^A>>=
1073 %
1074 % \clearpage
1075 %
1076 % \SetVersion{}\def\DocImp{Implementation}%
1077 % \section{Implementation}^^A>>=
1078 % \marginpar
1079 % {%
1080 % \smash
1081 % {%
1082 % \tiny
1083 % \ducksay
1084 % [vader,MSG=\footnotesize,arg=tab,msg-align=c,body-align=c]
1085 % {%
1086 % Only rebel scum reads\\documentation!\\
1087 % Join the dark side,\\read the implementation.%
1088 % }%
1089 % }%
1090 % }
1091 %
1092 %^^A main file >>=
1093 % \begin{macrocode}
1094 %<*pkg>
1095 % \end{macrocode}
1096 %
1097 % \subsection{Shared between versions}^^A>>=
1098 %
1099 % \subsubsection{Variables}^^A>>=
1100 % \paragraph{Integers}
1101 % \begin{macrocode}
1102 \int_new:N \l_ducksay_msg_width_int
1103 \int_new:N \l_ducksay_msg_height_int
1104 \int_new:N \l_ducksay_tail_symbol_count_int
1105 % \end{macrocode}
1106 % \paragraph{Sequences}
1107 % \begin{macrocode}
1108 \seq_new:N \l_ducksay_msg_lines_seq
1109 \seq_new:N \l_ducksay_defined_animals_seq
1110 % \end{macrocode}
1111 % \paragraph{Token lists}
1112 % \begin{macrocode}
1113 \tl_new:N \l_ducksay_align_tl
1114 \tl_new:N \l_ducksay_msg_align_tl
1115 \tl_new:N \l_ducksay_animal_tl
1116 \tl_new:N \l_ducksay_body_tl
1117 \tl_new:N \l_ducksay_bubble_tl
1118 \tl_new:N \l_ducksay_tmpa_tl
1119 \tl_new:N \l_ducksay_tail_symbol_out_one_tl
1120 \tl_new:N \l_ducksay_tail_symbol_out_two_tl
1121 \tl_new:N \l_ducksay_tail_symbol_in_tl
1122 % \end{macrocode}
1123 % \paragraph{Boolean}
1124 % \begin{macrocode}
1125 \bool_new:N \l_ducksay_version_one_bool
1126 \bool_new:N \l_ducksay_version_two_bool
1127 \bool_new:N \l_ducksay_random_animal_bool
1128 % \end{macrocode}
1129 % \paragraph{Boxes}
1130 % \begin{macrocode}
1131 \box_new:N \l_ducksay_tmpa_box
1132 % \end{macrocode}
1133 %
1134 %^^A=<<
1135 %
1136 % \subsubsection{Regular Expressions}^^A>>=
1137 % Regular expressions for \cs{AddColoredAnimal}
1138 % \begin{macrocode}
1139 \regex_const:Nn \c_ducksay_textcolor_regex
1140 { \\textcolor\{(.*?)\}\{(.*?)\} }
1141 \regex_const:Nn \c_ducksay_color_delim_regex
1142 { \\bgroup\\color\{(.*?)\}(.*)\\egroup }
1143 \regex_const:Nn \c_ducksay_color_regex
1144 { \\color\{(.*?)\} }
1145 % \end{macrocode}
1146 %^^A=<<
1147 %
1148 % \subsubsection{Messages}^^A>>=
1149 % \begin{macrocode}
1150 \msg_new:nnn { ducksay } { load-time-only }
1151 { The~`#1`~key~is~to~be~used~only~during~package~load~time. }
1152 % \end{macrocode}
1153 %^^A\msg_new:nnn { ducksay } { deprecated-key }
1154 %^^A { The~`\l_keys_key_tl`~key~is~deprecated.~Sorry~for~the~inconvenience. }
1155 %^^A=<<
1156 %
1157 % \subsubsection{Key-value setup}^^A>>=
1158 % \begin{macrocode}
1159 \keys_define:nn { ducksay }
1160 {
1161 ,bubble .tl_set:N = \l_ducksay_bubble_tl
1162 ,body .tl_set:N = \l_ducksay_body_tl
1163 ,align .tl_set:N = \l_ducksay_align_tl
1164 ,align .value_required:n = true
1165 ,wd .int_set:N = \l_ducksay_msg_width_int
1166 ,wd .initial:n = -\c_max_int
1167 ,wd .value_required:n = true
1168 ,ht .int_set:N = \l_ducksay_msg_height_int
1169 ,ht .initial:n = -\c_max_int
1170 ,ht .value_required:n = true
1171 ,animal .code:n =
1172 { \keys_define:nn { ducksay } { default_animal .meta:n = { #1 } } }
1173 ,animal .initial:n = duck
1174 ,msg-align .tl_set:N = \l_ducksay_msg_align_tl
1175 ,msg-align .initial:n = l
1176 ,msg-align .value_required:n = true
1177 ,rel-align .tl_set:N = \l_ducksay_rel_align_tl
1178 ,rel-align .initial:n = l
1179 ,rel-align .value_required:n = true
1180 ,ligatures .tl_set:N = \l_ducksay_ligatures_tl
1181 ,ligatures .initial:n = { `<>,'- }
1182 ,tail-1 .tl_set:N = \l_ducksay_tail_symbol_out_one_tl
1183 ,tail-1 .initial:x = \c_backslash_str
1184 ,tail-2 .tl_set:N = \l_ducksay_tail_symbol_out_two_tl
1185 ,tail-2 .initial:x = \c_backslash_str
1186 ,no-tail .meta:n = { tail-1 = { ~ }, tail-2 = { ~ } }
1187 ,think .meta:n = { tail-1 = { O }, tail-2 = { o } }
1188 ,random .bool_set:N = \l_ducksay_random_animal_bool
1189 ,say .code:n =
1190 {
1191 \exp_args:Nx \DucksayOptions
1192 { tail-1 = { \c_backslash_str }, tail-2 = { \c_backslash_str } }
1193 }
1194 ,schroedinger .code:n =
1195 {
1196 \int_compare:nNnTF { \int_rand:n { 2 } } = \c_one_int
1197 { \keys_set:nn { ducksay } { animal = schroedinger-dead } }
1198 { \keys_set:nn { ducksay } { animal = schroedinger-alive } }
1199 }
1200 ,schroedinger .value_forbidden:n = true
1201 ,version .choice:
1202 ,version / 1 .code:n =
1203 {
1204 \bool_set_false:N \l_ducksay_version_two_bool
1205 \bool_set_true:N \l_ducksay_version_one_bool
1206 }
1207 ,version / 2 .code:n =
1208 {
1209 \bool_set_false:N \l_ducksay_version_one_bool
1210 \bool_set_true:N \l_ducksay_version_two_bool
1211 }
1212 ,version .initial:n = 2
1213 }
1214 % \end{macrocode}
1215 %
1216 % \begin{macrocode}
1217 \cs_if_exist:NTF \ProcessKeyOptions
1218 { \ProcessKeyOptions [ ducksay ] }
1219 {
1220 \RequirePackage { l3keys2e }
1221 \ProcessKeysOptions { ducksay }
1222 }
1223 % \end{macrocode}
1224 %
1225 % Undefine the load-time-only keys
1226 % \begin{macrocode}
1227 \keys_define:nn { ducksay }
1228 {
1229 version .code:n = \msg_error:nnn { ducksay } { load-time-only } { version }
1230 }
1231 % \end{macrocode}
1232 %
1233 % \paragraph{Keys for \cs{AddAnimal}}^^A>>=
1234 % Define keys meant for \cs{AddAnimal} and \cs{AddColoredAnimal} only in their
1235 % own regime:
1236 % \begin{macrocode}
1237 \IfFormatAtLeastTF{2025-06-01}
1238 {
1239 \keys_define:nn { ducksay / add-animal }
1240 { tail-symbol .tl_set:N = \l_ducksay_tail_symbol_in_tl }
1241 }
1242 {
1243 \keys_define:nn { ducksay / add-animal }
1244 {
1245 tail-symbol .code:n =
1246 \tl_set:Ne \l_ducksay_tail_symbol_in_tl { \tl_to_str:n {#1} }
1247 }
1248 }
1249 \keys_define:nn { ducksay / add-animal }
1250 {
1251 tail-symbol .initial:o = \c_backslash_str
1252 ,tail-count .int_set:N = \l_ducksay_tail_symbol_count_int
1253 ,tail-count .initial:n = 2
1254 ,gen-tail-symbol .code:n =
1255 \tl_set:Ne \l_ducksay_tail_symbol_in_tl
1256 { \char_generate:nn { `#1 } { 12 } }
1257 }
1258 % \end{macrocode}
1259 %
1260 %^^A=<<
1261 %
1262 %^^A=<<
1263 %
1264 % \subsubsection{Functions}^^A>>=
1265 %
1266 % \paragraph{Generating Variants of External Functions}^^A>>=
1267 %
1268 % \begin{macrocode}
1269 \cs_generate_variant:Nn \tl_replace_once:Nnn { NVn }
1270 \cs_generate_variant:Nn \tl_replace_all:Nnn { NVn }
1271 \cs_generate_variant:Nn \keys_set:nn { nx }
1272 % \end{macrocode}
1273 %^^A=<<
1274 %
1275 % \paragraph{Internal}^^A>>=
1276 %
1277 % \begin{macro}[internal]{\__ducksay_everyeof:w}^^A>>=
1278 % \begin{macrocode}
1279 \cs_set_eq:NN \__ducksay_everyeof:w \tex_everyeof:D
1280 % \end{macrocode}
1281 % \end{macro}^^A=<<
1282 %
1283 % \begin{macro}[internal]{\__ducksay_scantokens:w}^^A>>=
1284 % \begin{macrocode}
1285 \cs_set_eq:NN \__ducksay_scantokens:w \tex_scantokens:D
1286 % \end{macrocode}
1287 % \end{macro}^^A=<<
1288 %
1289 % \begin{macro}[internal]{\ducksay_replace_verb_newline:Nn}^^A>>=
1290 % \begin{macrocode}
1291 \IfFormatAtLeastTF{2024-06-01}
1292 {
1293 \cs_new_protected:Npn \ducksay_replace_verb_newline:Nn #1 #2
1294 { \tl_replace_all:Nnn #1 \obeyedline {#2} }
1295 }
1296 {
1297 \cs_new_protected:Npx \ducksay_replace_verb_newline:Nn #1 #2
1298 { \tl_replace_all:Nnn #1 { \char_generate:nn { 13 } { 12 } } {#2} }
1299 }
1300 % \end{macrocode}
1301 % \end{macro}^^A=<<
1302 %
1303 % \begin{macro}[internal]{\ducksay_replace_verb_newline_newline:Nn}^^A>>=
1304 % \begin{macrocode}
1305 \IfFormatAtLeastTF{2024-06-01}
1306 {
1307 \cs_new_protected:Npn \ducksay_replace_verb_newline_newline:Nn #1 #2
1308 { \tl_replace_all:Nnn #1 { \obeyedline \obeyedline } {#2} }
1309 }
1310 {
1311 \cs_new_protected:Npx \ducksay_replace_verb_newline_newline:Nn #1 #2
1312 {
1313 \tl_replace_all:Nnn #1
1314 { \char_generate:nn { 13 } { 12 } \char_generate:nn { 13 } { 12 } }
1315 {#2}
1316 }
1317 }
1318 % \end{macrocode}
1319 % \end{macro}^^A=<<
1320 %
1321 % \begin{macro}[internal]{\ducksay_process_verb_newline:nnn}^^A>>=
1322 % \begin{macrocode}
1323 \cs_new_protected:Npn \ducksay_process_verb_newline:nnn #1 #2 #3
1324 {
1325 \tl_set:Nn \ProcessedArgument { #3 }
1326 \ducksay_replace_verb_newline_newline:Nn \ProcessedArgument { #2 }
1327 \ducksay_replace_verb_newline:Nn \ProcessedArgument { #1 }
1328 }
1329 % \end{macrocode}
1330 % \end{macro}^^A=<<
1331 %
1332 % \begin{macro}[internal]{\ducksay_add_animal_inner:nnnn}^^A>>=
1333 % \begin{macrocode}
1334 \cs_new_protected:Npn \ducksay_add_animal_inner:nnnn #1 #2 #3 #4
1335 {
1336 \group_begin:
1337 \keys_set:nn { ducksay / add-animal } { #1 }
1338 \tl_set:Nn \l_ducksay_tmpa_tl { \ #3 }
1339 \int_compare:nNnTF { \l_ducksay_tail_symbol_count_int } < { \c_zero_int }
1340 {
1341 \tl_replace_once:NVn
1342 \l_ducksay_tmpa_tl
1343 \l_ducksay_tail_symbol_in_tl
1344 \l_ducksay_tail_symbol_out_one_tl
1345 \tl_replace_all:NVn
1346 \l_ducksay_tmpa_tl
1347 \l_ducksay_tail_symbol_in_tl
1348 \l_ducksay_tail_symbol_out_two_tl
1349 }
1350 {
1351 \int_compare:nNnT { \l_ducksay_tail_symbol_count_int } >
1352 { \c_zero_int }
1353 {
1354 \tl_replace_once:NVn
1355 \l_ducksay_tmpa_tl
1356 \l_ducksay_tail_symbol_in_tl
1357 \l_ducksay_tail_symbol_out_one_tl
1358 \int_step_inline:nnn { 2 } { \l_ducksay_tail_symbol_count_int }
1359 {
1360 \tl_replace_once:NVn
1361 \l_ducksay_tmpa_tl
1362 \l_ducksay_tail_symbol_in_tl
1363 \l_ducksay_tail_symbol_out_two_tl
1364 }
1365 }
1366 }
1367 \tl_map_inline:Nn \l_ducksay_ligatures_tl
1368 { \tl_replace_all:Nnn \l_ducksay_tmpa_tl { ##1 } { { ##1 } } }
1369 \ducksay_replace_verb_newline:Nn \l_ducksay_tmpa_tl
1370 { \tabularnewline\null }
1371 \exp_args:NNnV
1372 \group_end:
1373 \tl_set:cn { l_ducksay_animal_#2_tl } \l_ducksay_tmpa_tl
1374 \exp_args:Nnx \keys_define:nn { ducksay }
1375 {
1376 #2 .code:n =
1377 {
1378 \exp_not:n { \tl_set_eq:NN \l_ducksay_animal_tl }
1379 \exp_not:c { l_ducksay_animal_#2_tl }
1380 \exp_not:n { \exp_args:NV \DucksayOptions }
1381 \exp_not:c { l_ducksay_animal_#2_options_tl }
1382 }
1383 }
1384 \tl_if_exist:cF { l_ducksay_animal_#2_options_tl }
1385 { \tl_new:c { l_ducksay_animal_#2_options_tl } }
1386 \IfBooleanT { #4 }
1387 { \keys_define:nn { ducksay } { default_animal .meta:n = { #2 } } }
1388 \seq_if_in:NnF \l_ducksay_defined_animals_seq { #2 }
1389 { \seq_push:Nn \l_ducksay_defined_animals_seq { #2 } }
1390 }
1391 \cs_generate_variant:Nn \ducksay_add_animal_inner:nnnn { nnVn }
1392 % \end{macrocode}
1393 % \end{macro}^^A=<<
1394 %
1395 % \begin{macro}[internal]{\ducksay_default_or_random_animal:}
1396 % \begin{macrocode}
1397 \cs_new_protected:Npn \ducksay_default_or_random_animal:
1398 {
1399 \tl_if_empty:NT \l_ducksay_animal_tl
1400 {
1401 \bool_if:NTF \l_ducksay_random_animal_bool
1402 {
1403 \keys_set:nx { ducksay }
1404 { \seq_rand_item:N \l_ducksay_defined_animals_seq }
1405 }
1406 { \keys_set:nn { ducksay } { default_animal } }
1407 }
1408 }
1409 % \end{macrocode}
1410 % \end{macro}
1411 %
1412 %^^A=<<
1413 %
1414 % \paragraph{Document level}^^A>>=
1415 %
1416 % \begin{macro}{\DefaultAnimal}^^A>>=
1417 % \begin{macrocode}
1418 \NewDocumentCommand \DefaultAnimal { m }
1419 {
1420 \keys_define:nn { ducksay } { default_animal .meta:n = { #1 } }
1421 }
1422 % \end{macrocode}
1423 % \end{macro}^^A=<<
1424 %
1425 % \begin{macro}{\DucksayOptions}^^A>>=
1426 % \begin{macrocode}
1427 \NewDocumentCommand \DucksayOptions { m }
1428 {
1429 \keys_set:nn { ducksay } { #1 }
1430 }
1431 % \end{macrocode}
1432 % \end{macro}^^A=<<
1433 %
1434 % \begin{macro}{\AddAnimal}^^A>>=
1435 % \begin{macrocode}
1436 \NewDocumentCommand \AddAnimal { s O{} m +v }
1437 {
1438 \ducksay_add_animal_inner:nnnn { #2 } { #3 } { #4 } { #1 }
1439 }
1440 % \end{macrocode}
1441 % \end{macro}^^A=<<
1442 %
1443 % \begin{macro}{\AddColoredAnimal}^^A>>=
1444 % \begin{macrocode}
1445 \NewDocumentCommand \AddColoredAnimal { s O{} m +v }
1446 {
1447 \tl_set:Nn \l_ducksay_tmpa_tl { #4 }
1448 \regex_replace_all:NnN \c_ducksay_color_delim_regex
1449 { \c{bgroup}\c{color}\cB\{\1\cE\}\2\c{egroup} }
1450 \l_ducksay_tmpa_tl
1451 \regex_replace_all:NnN \c_ducksay_color_regex
1452 { \c{color}\cB\{\1\cE\} }
1453 \l_ducksay_tmpa_tl
1454 \regex_replace_all:NnN \c_ducksay_textcolor_regex
1455 { \c{textcolor}\cB\{\1\cE\}\cB\{\2\cE\} }
1456 \l_ducksay_tmpa_tl
1457 \ducksay_add_animal_inner:nnVn { #2 } { #3 } \l_ducksay_tmpa_tl { #1 }
1458 }
1459 % \end{macrocode}
1460 % \end{macro}^^A=<<
1461 %
1462 % \begin{macro}{\AnimalOptions}^^A>>=
1463 % \begin{macrocode}
1464 \NewDocumentCommand \AnimalOptions { s m m }
1465 {
1466 \tl_if_exist:cTF { l_ducksay_animal_#2_options_tl }
1467 {
1468 \IfBooleanTF { #1 }
1469 { \tl_set:cn }
1470 { \tl_put_right:cn }
1471 }
1472 { \tl_set:cn }
1473 { l_ducksay_animal_#2_options_tl } { #3, }
1474 }
1475 % \end{macrocode}
1476 % \end{macro}^^A=<<
1477 %
1478 %^^A=<<
1479 %
1480 %^^A=<<
1481 %
1482 % \subsubsection{Load the Correct Version and the Animals}^^A>>=
1483 % \begin{macrocode}
1484 \bool_if:NT \l_ducksay_version_one_bool
1485 { \file_input:n { ducksay.code.v1.tex } }
1486 \bool_if:NT \l_ducksay_version_two_bool
1487 { \file_input:n { ducksay.code.v2.tex } }
1488 % \end{macrocode}
1489 %
1490 % \begin{macrocode}
1491 \ExplSyntaxOff
1492 \input{ducksay.animals.tex}
1493 % \end{macrocode}
1494 %^^A=<<
1495 %
1496 %^^A=<<
1497 %
1498 % \begin{macrocode}
1499 %</pkg>
1500 % \end{macrocode}
1501 %^^A=<<
1502 %
1503 % \SetVersion{1}%
1504 % \subsection{Version 1}^^A>>=
1505 % \begin{macrocode}
1506 %<*code.v1>
1507 \ProvidesFile{ducksay.code.v1.tex}
1508 [\ducksay@date\space v\ducksay@version\space ducksay code version 1]
1509 % \end{macrocode}
1510 %
1511 % \subsubsection{Functions}^^A>>=
1512 %
1513 % \paragraph{Internal}^^A>>=
1514 %
1515 % \begin{macro}[internal]{\ducksay_longest_line:n}^^A>>=
1516 % Calculate the length of the longest line
1517 % \begin{macrocode}
1518 \cs_new:Npn \ducksay_longest_line:n #1
1519 {
1520 \int_incr:N \l_ducksay_msg_height_int
1521 \exp_args:NNx \tl_set:Nn \l_ducksay_tmpa_tl { #1 }
1522 \regex_replace_all:nnN { \s } { \c { space } } \l_ducksay_tmpa_tl
1523 \int_set:Nn \l_ducksay_msg_width_int
1524 {
1525 \int_max:nn
1526 { \l_ducksay_msg_width_int } { \tl_count:N \l_ducksay_tmpa_tl }
1527 }
1528 }
1529 % \end{macrocode}
1530 % \end{macro}^^A=<<
1531 %
1532 % \begin{macro}[internal]{\ducksay_open_bubble:}^^A>>=
1533 % Draw the opening bracket of the bubble
1534 % \begin{macrocode}
1535 \cs_new:Npn \ducksay_open_bubble:
1536 {
1537 \begin{tabular}{@{}l@{}}
1538 \null\\
1539 \int_compare:nNnTF { \l_ducksay_msg_height_int } = { 1 } { ( }
1540 {
1541 /
1542 \int_step_inline:nnn
1543 { 3 } { \l_ducksay_msg_height_int } { \\\kern-0.2em| }
1544 \\\detokenize{\ }
1545 }
1546 \\[-1ex]\null
1547 \end{tabular}
1548 \begin{tabular}{@{}l@{}}
1549 _\\
1550 \int_step_inline:nnn { 2 } { \l_ducksay_msg_height_int } { \\ } \\[-1ex]
1551 \mbox { - }
1552 \end{tabular}
1553 }
1554 % \end{macrocode}
1555 % \end{macro}^^A=<<
1556 %
1557 % \begin{macro}[internal]{\ducksay_close_bubble:}^^A>>=
1558 % Draw the closing bracket of the bubble
1559 % \begin{macrocode}
1560 \cs_new:Npn \ducksay_close_bubble:
1561 {
1562 \begin{tabular}{@{}l@{}}
1563 _\\
1564 \int_step_inline:nnn { 2 } { \l_ducksay_msg_height_int } { \\ } \\[-1ex]
1565 { - }
1566 \end{tabular}
1567 \begin{tabular}{@{}r@{}}
1568 \null\\
1569 \int_compare:nNnTF { \l_ducksay_msg_height_int } = { 1 }
1570 { ) }
1571 {
1572 \detokenize {\ }
1573 \int_step_inline:nnn
1574 { 3 } { \l_ducksay_msg_height_int } { \\|\kern-0.2em }
1575 \\/
1576 }
1577 \\[-1ex]\null
1578 \end{tabular}
1579 }
1580 % \end{macrocode}
1581 % \end{macro}^^A=<<
1582 %
1583 % \begin{macro}[internal]{\ducksay_print_msg:nn}^^A>>=
1584 % Print out the message
1585 % \begin{macrocode}
1586 \cs_new:Npn \ducksay_print_msg:nn #1 #2
1587 {
1588 \begin{tabular}{@{} #2 @{}}
1589 \int_step_inline:nn { \l_ducksay_msg_width_int } { _ } \\
1590 #1\\[-1ex]
1591 \int_step_inline:nn { \l_ducksay_msg_width_int } { { - } }
1592 \end{tabular}
1593 }
1594 \cs_generate_variant:Nn \ducksay_print_msg:nn { nV }
1595 % \end{macrocode}
1596 % \end{macro}^^A=<<
1597 %
1598 % \begin{macro}[internal]{\ducksay_print:nn}^^A>>=
1599 % Print out the whole thing
1600 % \begin{macrocode}
1601 \cs_new:Npn \ducksay_print:nn #1 #2
1602 {
1603 \int_compare:nNnTF { \l_ducksay_msg_width_int } < { 0 }
1604 {
1605 \int_zero:N \l_ducksay_msg_height_int
1606 \seq_set_split:Nnn \l_ducksay_msg_lines_seq { \\ } { #1 }
1607 \seq_map_function:NN \l_ducksay_msg_lines_seq \ducksay_longest_line:n
1608 }
1609 {
1610 \int_compare:nNnT { \l_ducksay_msg_height_int } < { 0 }
1611 {
1612 \regex_count:nnN { \c { \\ } } { #1 } \l_ducksay_msg_height_int
1613 \int_incr:N \l_ducksay_msg_height_int
1614 }
1615 }
1616 \group_begin:
1617 \frenchspacing
1618 \verbatim@font
1619 \@noligs
1620 \begin{tabular}[\l_ducksay_align_tl]{@{}#2@{}}
1621 \l_ducksay_bubble_tl
1622 \begin{tabular}{@{}l@{}}
1623 \ducksay_open_bubble:
1624 \ducksay_print_msg:nV { #1 } \l_ducksay_msg_align_tl
1625 \ducksay_close_bubble:
1626 \end{tabular}\\
1627 \l_ducksay_body_tl
1628 \begin{tabular}{@{}l@{}}
1629 \l_ducksay_animal_tl
1630 \end{tabular}
1631 \end{tabular}
1632 \group_end:
1633 }
1634 \cs_generate_variant:Nn \ducksay_print:nn { nV }
1635 % \end{macrocode}
1636 % \end{macro}^^A=<<
1637 %
1638 % \begin{macro}[internal]{\ducksay_say_and_think:nn}^^A>>=
1639 % Reset some variables
1640 % \begin{macrocode}
1641 \cs_new:Npn \ducksay_say_and_think:nn #1 #2
1642 {
1643 \group_begin:
1644 \int_set:Nn \l_ducksay_msg_width_int { -\c_max_int }
1645 \int_set:Nn \l_ducksay_msg_height_int { -\c_max_int }
1646 \keys_set:nn { ducksay } { #1 }
1647 \ducksay_default_or_random_animal:
1648 \ducksay_print:nV { #2 } \l_ducksay_rel_align_tl
1649 \group_end:
1650 }
1651 % \end{macrocode}
1652 % \end{macro}^^A=<<
1653 %^^A=<<
1654 %
1655 % \paragraph{Document level}^^A>>=
1656 %
1657 % \begin{macro}{\ducksay}^^A>>=
1658 % \begin{macrocode}
1659 \NewDocumentCommand \ducksay { O{} m }
1660 {
1661 \ducksay_say_and_think:nn { #1 } { #2 }
1662 }
1663 % \end{macrocode}
1664 % \end{macro}^^A=<<
1665 %
1666 % \begin{macro}{\duckthink}^^A>>=
1667 % \begin{macrocode}
1668 \NewDocumentCommand \duckthink { O{} m }
1669 {
1670 \ducksay_say_and_think:nn { think, #1 } { #2 }
1671 }
1672 % \end{macrocode}
1673 % \end{macro}^^A=<<
1674 %^^A=<<
1675 %
1676 %^^A=<<
1677 %
1678 % \begin{macrocode}
1679 %</code.v1>
1680 % \end{macrocode}^^A=<<
1681 %
1682 % \SetVersion{2}%
1683 % \subsection{Version 2}^^A>>=
1684 % \begin{macrocode}
1685 %<*code.v2>
1686 \ProvidesFile{ducksay.code.v2.tex}
1687 [\ducksay@date\space v\ducksay@version\space ducksay code version 2]
1688 % \end{macrocode}
1689 %
1690 % Load the additional dependencies of version 2.
1691 % \begin{macrocode}
1692 \RequirePackage{array,grabbox}
1693 % \end{macrocode}
1694 %
1695 % \subsubsection{Messages}^^A>>=
1696 % \begin{macrocode}
1697 \msg_new:nnn { ducksay } { justify~unavailable }
1698 {
1699 Justified~content~is~not~available~for~tabular~argument~mode~without~fixed~
1700 width.~`l`~column~is~used~instead.
1701 }
1702 \msg_new:nnn { ducksay } { v1-key-only }
1703 { The~`\l_keys_key_str`~key~is~only~available~for~`version=1`. }
1704 \msg_new:nnn { ducksay } { zero-baselineskip }
1705 { Current~ baselineskip~ is~ 0pt. }
1706 % \end{macrocode}
1707 %^^A=<<
1708 %
1709 % \subsubsection{Variables}^^A>>=
1710 %
1711 % \paragraph{Token Lists}
1712 % \begin{macrocode}
1713 \tl_new:N \l_ducksay_msg_align_vbox_tl
1714 % \end{macrocode}
1715 %
1716 % \paragraph{Boxes}
1717 % \begin{macrocode}
1718 \box_new:N \l_ducksay_msg_box
1719 % \end{macrocode}
1720 %
1721 % \paragraph{Bools}
1722 % \begin{macrocode}
1723 \bool_new:N \l_ducksay_eat_arg_box_bool
1724 \bool_new:N \l_ducksay_eat_arg_tab_verb_bool
1725 \bool_new:N \l_ducksay_mirrored_body_bool
1726 \bool_new:N \l_ducksay_msg_eq_body_width_bool
1727 % \end{macrocode}
1728 %
1729 % \paragraph{Coffins}
1730 % \begin{macrocode}
1731 \coffin_new:N \l_ducksay_body_coffin
1732 \coffin_new:N \l_ducksay_bubble_close_coffin
1733 \coffin_new:N \l_ducksay_bubble_open_coffin
1734 \coffin_new:N \l_ducksay_bubble_top_coffin
1735 \coffin_new:N \l_ducksay_msg_coffin
1736 % \end{macrocode}
1737 %
1738 % \paragraph{Dimensions}
1739 % \begin{macrocode}
1740 \dim_new:N \l_ducksay_hpad_dim
1741 \dim_new:N \l_ducksay_bubble_bottom_kern_dim
1742 \dim_new:N \l_ducksay_bubble_top_kern_dim
1743 \dim_new:N \l_ducksay_msg_width_dim
1744 % \end{macrocode}
1745 %
1746 %^^A=<<
1747 %
1748 % \subsubsection{Options}^^A>>=
1749 %
1750 % \begin{macrocode}
1751 \keys_define:nn { ducksay }
1752 {
1753 ,arg .choice:
1754 ,arg / box .code:n = \bool_set_true:N \l_ducksay_eat_arg_box_bool
1755 ,arg / tab .code:n =
1756 {
1757 \bool_set_false:N \l_ducksay_eat_arg_box_bool
1758 \bool_set_false:N \l_ducksay_eat_arg_tab_verb_bool
1759 }
1760 ,arg / tab* .code:n =
1761 {
1762 \bool_set_false:N \l_ducksay_eat_arg_box_bool
1763 \bool_set_true:N \l_ducksay_eat_arg_tab_verb_bool
1764 }
1765 ,arg .initial:n = tab
1766 ,wd* .dim_set:N = \l_ducksay_msg_width_dim
1767 ,wd* .initial:n = -\c_max_dim
1768 ,wd* .value_required:n = true
1769 ,wd-eq-body .bool_set:N = \l_ducksay_msg_eq_body_width_bool
1770 ,none .bool_set:N = \l_ducksay_no_body_bool
1771 ,no-bubble .bool_set:N = \l_ducksay_no_bubble_bool
1772 ,body-mirrored .bool_set:N = \l_ducksay_mirrored_body_bool
1773 ,ignore-body .bool_set:N = \l_ducksay_ignored_body_bool
1774 ,body-x .dim_set:N = \l_ducksay_body_x_offset_dim
1775 ,body-x .value_required:n = true
1776 ,body-y .dim_set:N = \l_ducksay_body_y_offset_dim
1777 ,body-y .value_required:n = true
1778 ,body-to-msg .tl_set:N = \l_ducksay_body_to_msg_align_body_tl
1779 ,msg-to-body .tl_set:N = \l_ducksay_body_to_msg_align_msg_tl
1780 ,body-align .choice:
1781 ,body-align / l .meta:n = { body-to-msg = l , msg-to-body = l }
1782 ,body-align / c .meta:n = { body-to-msg = hc , msg-to-body = hc }
1783 ,body-align / r .meta:n = { body-to-msg = r , msg-to-body = r }
1784 ,body-align .initial:n = l
1785 ,body-bigger .int_set:N = \l_ducksay_body_bigger_int
1786 ,body-bigger .initial:n = \c_zero_int
1787 ,msg-align .choice:
1788 ,msg-align / l .code:n = { \tl_set:Nn \l_ducksay_msg_align_tl { l } }
1789 ,msg-align / c .code:n = { \tl_set:Nn \l_ducksay_msg_align_tl { c } }
1790 ,msg-align / r .code:n = { \tl_set:Nn \l_ducksay_msg_align_tl { r } }
1791 ,msg-align / j .code:n = { \tl_set:Nn \l_ducksay_msg_align_tl { j } }
1792 ,msg-align-l .tl_set:N = \l_ducksay_msg_align_l_tl
1793 ,msg-align-l .initial:n = \raggedright
1794 ,msg-align-c .tl_set:N = \l_ducksay_msg_align_c_tl
1795 ,msg-align-c .initial:n = \centering
1796 ,msg-align-r .tl_set:N = \l_ducksay_msg_align_r_tl
1797 ,msg-align-r .initial:n = \raggedleft
1798 ,msg-align-j .tl_set:N = \l_ducksay_msg_align_j_tl
1799 ,msg-align-j .initial:n = {}
1800 ,out-h .tl_set:N = \l_ducksay_output_h_pole_tl
1801 ,out-h .initial:n = l
1802 ,out-v .tl_set:N = \l_ducksay_output_v_pole_tl
1803 ,out-v .initial:n = vc
1804 ,out-x .dim_set:N = \l_ducksay_output_x_offset_dim
1805 ,out-x .value_required:n = true
1806 ,out-y .dim_set:N = \l_ducksay_output_y_offset_dim
1807 ,out-y .value_required:n = true
1808 ,t .meta:n = { out-v = t }
1809 ,c .meta:n = { out-v = vc }
1810 ,b .meta:n = { out-v = b }
1811 ,body* .tl_set:N = \l_ducksay_body_fount_tl
1812 ,msg* .tl_set:N = \l_ducksay_msg_fount_tl
1813 ,bubble* .tl_set:N = \l_ducksay_bubble_fount_tl
1814 ,body* .initial:n = \verbatim@font
1815 ,msg* .initial:n = \verbatim@font
1816 ,bubble* .initial:n = \verbatim@font
1817 ,body .code:n = \tl_put_right:Nn \l_ducksay_body_fount_tl { #1 }
1818 ,msg .code:n = \tl_put_right:Nn \l_ducksay_msg_fount_tl { #1 }
1819 ,bubble .code:n = \tl_put_right:Nn \l_ducksay_bubble_fount_tl { #1 }
1820 ,MSG .meta:n = { msg = #1 , bubble = #1 }
1821 ,MSG* .meta:n = { msg* = #1 , bubble* = #1 }
1822 ,hpad .int_set:N = \l_ducksay_hpad_int
1823 ,hpad .initial:n = 2
1824 ,hpad .value_required:n = true
1825 ,vpad .int_set:N = \l_ducksay_vpad_int
1826 ,vpad .value_required:n = true
1827 ,col .tl_set:N = \l_ducksay_msg_tabular_column_tl
1828 ,bubble-top-kern .tl_set:N = \l_ducksay_bubble_top_kern_tl
1829 ,bubble-top-kern .initial:n = { -.5ex }
1830 ,bubble-top-kern .value_required:n = true
1831 ,bubble-bot-kern .tl_set:N = \l_ducksay_bubble_bottom_kern_tl
1832 ,bubble-bot-kern .initial:n = { .2ex }
1833 ,bubble-bot-kern .value_required:n = true
1834 ,bubble-side-kern .tl_set:N = \l_ducksay_bubble_side_kern_tl
1835 ,bubble-side-kern .initial:n = { .2em }
1836 ,bubble-side-kern .value_required:n = true
1837 ,bubble-delim-top .tl_set:N = \l_ducksay_bubble_delim_top_tl
1838 ,bubble-delim-left-1 .tl_set:N = \l_ducksay_bubble_delim_left_a_tl
1839 ,bubble-delim-left-2 .tl_set:N = \l_ducksay_bubble_delim_left_b_tl
1840 ,bubble-delim-left-3 .tl_set:N = \l_ducksay_bubble_delim_left_c_tl
1841 ,bubble-delim-left-4 .tl_set:N = \l_ducksay_bubble_delim_left_d_tl
1842 ,bubble-delim-right-1 .tl_set:N = \l_ducksay_bubble_delim_right_a_tl
1843 ,bubble-delim-right-2 .tl_set:N = \l_ducksay_bubble_delim_right_b_tl
1844 ,bubble-delim-right-3 .tl_set:N = \l_ducksay_bubble_delim_right_c_tl
1845 ,bubble-delim-right-4 .tl_set:N = \l_ducksay_bubble_delim_right_d_tl
1846 ,bubble-delim-top .initial:n = { { - } }
1847 ,bubble-delim-left-1 .initial:n = (
1848 ,bubble-delim-left-2 .initial:n = /
1849 ,bubble-delim-left-3 .initial:n = |
1850 ,bubble-delim-left-4 .initial:n = \c_backslash_str
1851 ,bubble-delim-right-1 .initial:n = )
1852 ,bubble-delim-right-2 .initial:n = \c_backslash_str
1853 ,bubble-delim-right-3 .initial:n = |
1854 ,bubble-delim-right-4 .initial:n = /
1855 ,strip-spaces .bool_set:N = \l_ducksay_msg_strip_spaces_bool
1856 }
1857 % \end{macrocode}
1858 %
1859 % Redefine keys only intended for version~1 to throw an error:
1860 %
1861 % \begin{macrocode}
1862 \clist_map_inline:nn
1863 { align, rel-align }
1864 {
1865 \keys_define:nn { ducksay }
1866 { #1 .code:n = \msg_error:nn { ducksay } { v1-key-only } }
1867 }
1868 % \end{macrocode}
1869 %
1870 %
1871 %^^A=<<
1872 %
1873 % \subsubsection{Functions}^^A>>=
1874 %
1875 % \paragraph{Internal}^^A>>=
1876 %
1877 % \begin{macro}[internal]
1878 % {\ducksay_evaluate_message_alignment_fixed_width_common:}^^A>>=
1879 % \begin{macrocode}
1880 \cs_new:Npn \ducksay_evaluate_message_alignment_fixed_width_common:
1881 {
1882 \str_case:Vn \l_ducksay_msg_align_tl
1883 {
1884 { l } { \exp_not:N \l_ducksay_msg_align_l_tl }
1885 { c } { \exp_not:N \l_ducksay_msg_align_c_tl }
1886 { r } { \exp_not:N \l_ducksay_msg_align_r_tl }
1887 { j } { \exp_not:N \l_ducksay_msg_align_j_tl }
1888 }
1889 }
1890 % \end{macrocode}
1891 % \end{macro}^^A=<<
1892 %
1893 % \begin{macro}[internal]
1894 % {\ducksay_evaluate_message_alignment_fixed_width_tabular:}^^A>>=
1895 % \begin{macrocode}
1896 \cs_new:Npn \ducksay_evaluate_message_alignment_fixed_width_tabular:
1897 {
1898 \tl_if_empty:NT \l_ducksay_msg_tabular_column_tl
1899 {
1900 \tl_set:Nx \l_ducksay_msg_tabular_column_tl
1901 {
1902 >
1903 {
1904 \ducksay_evaluate_message_alignment_fixed_width_common:
1905 \exp_not:N \arraybackslash
1906 }
1907 p { \exp_not:N \l_ducksay_msg_width_dim }
1908 }
1909 }
1910 }
1911 % \end{macrocode}
1912 % \end{macro}^^A=<<
1913 %
1914 % \begin{macro}[internal]
1915 % {\ducksay_evaluate_message_alignment_fixed_width_vbox:}^^A>>=
1916 % \begin{macrocode}
1917 \cs_new:Npn \ducksay_evaluate_message_alignment_fixed_width_vbox:
1918 {
1919 \tl_set:Nx \l_ducksay_msg_align_vbox_tl
1920 { \ducksay_evaluate_message_alignment_fixed_width_common: }
1921 }
1922 % \end{macrocode}
1923 % \end{macro}^^A=<<
1924 %
1925 % \begin{macro}[internal]{\ducksay_calculate_msg_width_from_int:}^^A>>=
1926 % \begin{macrocode}
1927 \cs_new:Npn \ducksay_calculate_msg_width_from_int:
1928 {
1929 \hbox_set:Nn \l_ducksay_tmpa_box { { \l_ducksay_msg_fount_tl M } }
1930 \dim_set:Nn \l_ducksay_msg_width_dim
1931 { \l_ducksay_msg_width_int \box_wd:N \l_ducksay_tmpa_box }
1932 }
1933 % \end{macrocode}
1934 % \end{macro}^^A=<<
1935 %
1936 % \begin{macro}[internal]{\ducksay_msg_tabular_begin:}^^A>>=
1937 % \begin{macrocode}
1938 \cs_new:Npn \ducksay_msg_tabular_begin:
1939 {
1940 \ducksay_msg_tabular_begin_inner:V \l_ducksay_msg_tabular_column_tl
1941 }
1942 \cs_new:Npn \ducksay_msg_tabular_begin_inner:n #1
1943 {
1944 \begin { tabular } { @{} #1 @{} }
1945 }
1946 \cs_generate_variant:Nn \ducksay_msg_tabular_begin_inner:n { V }
1947 % \end{macrocode}
1948 % \end{macro}^^A=<<
1949 %
1950 % \begin{macro}[internal]{\ducksay_msg_tabular_end:}^^A>>=
1951 % \begin{macrocode}
1952 \cs_new:Npn \ducksay_msg_tabular_end:
1953 {
1954 \end { tabular }
1955 }
1956 % \end{macrocode}
1957 % \end{macro}^^A=<<
1958 %
1959 % \begin{macro}[internal]{\ducksay_width_case_none_int_dim:nnn}^^A>>=
1960 % \begin{macrocode}
1961 \cs_new:Npn \ducksay_width_case_none_int_dim:nnn #1 #2 #3
1962 {
1963 \dim_compare:nNnTF { \l_ducksay_msg_width_dim } < { \c_zero_dim }
1964 {
1965 \int_compare:nNnTF { \l_ducksay_msg_width_int } < { \c_zero_int }
1966 { #1 }
1967 { #2 }
1968 }
1969 { #3 }
1970 }
1971 % \end{macrocode}
1972 % \end{macro}^^A=<<
1973 %
1974 % \begin{macro}[internal]{\ducksay_digest_options:n}^^A>>=
1975 % \begin{macrocode}
1976 \cs_new:Npn \ducksay_digest_options:n #1
1977 {
1978 \group_begin:
1979 \keys_set:nn { ducksay } { #1 }
1980 \ducksay_default_or_random_animal:
1981 \bool_if:NF \l_ducksay_no_body_bool
1982 {
1983 \hcoffin_set:Nn \l_ducksay_body_coffin
1984 {
1985 \frenchspacing
1986 \l_ducksay_body_fount_tl
1987 \begin{tabular} { @{} l @{} }
1988 \l_ducksay_animal_tl
1989 \ducksay_make_body_bigger:
1990 \relax
1991 \end{tabular}
1992 }
1993 \bool_if:NT \l_ducksay_msg_eq_body_width_bool
1994 {
1995 \bool_lazy_and:nnT
1996 { \int_compare_p:nNn \l_ducksay_msg_width_int < \c_zero_int }
1997 { \dim_compare_p:nNn \l_ducksay_msg_width_dim < \c_zero_dim }
1998 {
1999 \dim_set:Nn \l_ducksay_msg_width_dim
2000 { \coffin_wd:N \l_ducksay_body_coffin }
2001 }
2002 }
2003 }
2004 \bool_if:NTF \l_ducksay_eat_arg_box_bool
2005 {
2006 \ducksay_width_case_none_int_dim:nnn
2007 { \ducksay_eat_argument_hbox:w }
2008 {
2009 \ducksay_calculate_msg_width_from_int:
2010 \ducksay_eat_argument_vbox:w
2011 }
2012 { \ducksay_eat_argument_vbox:w }
2013 }
2014 {
2015 \ducksay_width_case_none_int_dim:nnn
2016 {
2017 \tl_if_empty:NT \l_ducksay_msg_tabular_column_tl
2018 {
2019 \str_case:Vn \l_ducksay_msg_align_tl
2020 {
2021 { l } { \tl_set:Nn \l_ducksay_msg_tabular_column_tl { l } }
2022 { c } { \tl_set:Nn \l_ducksay_msg_tabular_column_tl { c } }
2023 { r } { \tl_set:Nn \l_ducksay_msg_tabular_column_tl { r } }
2024 { j }
2025 {
2026 \msg_error:nn { ducksay } { justify~unavailable }
2027 \tl_set:Nn \l_ducksay_msg_tabular_column_tl { l }
2028 }
2029 }
2030 }
2031 }
2032 {
2033 \ducksay_calculate_msg_width_from_int:
2034 \ducksay_evaluate_message_alignment_fixed_width_tabular:
2035 }
2036 { \ducksay_evaluate_message_alignment_fixed_width_tabular: }
2037 \ducksay_eat_argument_tabular:w
2038 }
2039 }
2040 % \end{macrocode}
2041 % \end{macro}^^A=<<
2042 %
2043 % \begin{macro}[internal]{\ducksay_set_bubble_top_kern:}^^A>>=
2044 % \begin{macrocode}
2045 \cs_new:Npn \ducksay_set_bubble_top_kern:
2046 {
2047 \group_begin:
2048 \l_ducksay_bubble_fount_tl
2049 \exp_args:NNNx
2050 \group_end:
2051 \dim_set:Nn \l_ducksay_bubble_top_kern_dim
2052 { \dim_eval:n { \l_ducksay_bubble_top_kern_tl } }
2053 }
2054 % \end{macrocode}
2055 % \end{macro}^^A=<<
2056 %
2057 % \begin{macro}[internal]{\ducksay_set_bubble_bottom_kern:}^^A>>=
2058 % \begin{macrocode}
2059 \cs_new:Npn \ducksay_set_bubble_bottom_kern:
2060 {
2061 \group_begin:
2062 \l_ducksay_bubble_fount_tl
2063 \exp_args:NNNx
2064 \group_end:
2065 \dim_set:Nn \l_ducksay_bubble_bottom_kern_dim
2066 { \dim_eval:n { \l_ducksay_bubble_bottom_kern_tl } }
2067 }
2068 % \end{macrocode}
2069 % \end{macro}^^A=<<
2070 %
2071 % \begin{macro}[internal]{\ducksay_make_body_bigger:}^^A>>=
2072 % \begin{macrocode}
2073 \cs_new:Npn \ducksay_make_body_bigger:
2074 { \prg_replicate:nn \l_ducksay_body_bigger_int \\ }
2075 % \end{macrocode}
2076 % \end{macro}^^A=<<
2077 %
2078 % \begin{macro}[internal]{\ducksay_baselineskip:}^^A>>=
2079 % This is an overly cautious way to get the current baselineskip. Inside of
2080 % \env{tabular} the baselineskip is 0pt, so we fall back to
2081 % \cs[no-index]{normalbaselineskip}, or issue an error and fall back to some
2082 % arbitrary value not producing an error if that one is also 0pt.
2083 % \begin{macrocode}
2084 \cs_new_protected_nopar:Npn \ducksay_baselineskip:
2085 {
2086 \the\dimexpr
2087 \ifdim \baselineskip = \c_zero_dim
2088 \ifdim \normalbaselineskip = \c_zero_dim
2089 \msg_expandable_error:nn { ducksay } { zero-baselineskip } { 12pt }
2090 12pt
2091 \else
2092 \normalbaselineskip
2093 \fi
2094 \else
2095 \baselineskip
2096 \fi
2097 \relax
2098 }
2099 % \end{macrocode}
2100 % \end{macro}^^A=<<
2101 %
2102 % \begin{macro}[internal]{\ducksay_measure_msg:}^^A>>=
2103 % \begin{macrocode}
2104 \cs_new_protected_nopar:Npn \ducksay_measure_msg:
2105 {
2106 \hbox_set:Nn \l_ducksay_tmpa_box
2107 { \l_ducksay_bubble_fount_tl \l_ducksay_bubble_delim_top_tl }
2108 \int_set:Nn \l_ducksay_msg_width_int
2109 {
2110 \fp_eval:n
2111 {
2112 ceil
2113 ( \box_wd:N \l_ducksay_msg_box / \box_wd:N \l_ducksay_tmpa_box )
2114 }
2115 }
2116 \group_begin:
2117 \l_ducksay_bubble_fount_tl
2118 \exp_args:NNNx
2119 \group_end:
2120 \int_set:Nn \l_ducksay_msg_height_int
2121 {
2122 \int_max:nn
2123 {
2124 \fp_eval:n
2125 {
2126 ceil
2127 (
2128 (
2129 \box_ht:N \l_ducksay_msg_box
2130 + \box_dp:N \l_ducksay_msg_box
2131 )
2132 / ( \arraystretch * \ducksay_baselineskip: )
2133 )
2134 }
2135 + \l_ducksay_vpad_int
2136 }
2137 { \l_ducksay_msg_height_int }
2138 }
2139 }
2140 % \end{macrocode}
2141 % \end{macro}^^A=<<
2142 %
2143 % \begin{macro}[internal]{\ducksay_set_bubble_coffins:}^^A>>=
2144 % \begin{macrocode}
2145 \cs_new_protected_nopar:Npn \ducksay_set_bubble_coffins:
2146 {
2147 \hcoffin_set:Nn \l_ducksay_bubble_open_coffin
2148 {
2149 \l_ducksay_bubble_fount_tl
2150 \begin{tabular}{@{}l@{}}
2151 \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int }
2152 {
2153 \l_ducksay_bubble_delim_left_a_tl
2154 }
2155 {
2156 \l_ducksay_bubble_delim_left_b_tl\\
2157 \int_step_inline:nnn
2158 { 3 } { \l_ducksay_msg_height_int }
2159 {
2160 \kern-\l_ducksay_bubble_side_kern_tl
2161 \l_ducksay_bubble_delim_left_c_tl
2162 \\
2163 }
2164 \l_ducksay_bubble_delim_left_d_tl
2165 }
2166 \end{tabular}
2167 }
2168 \hcoffin_set:Nn \l_ducksay_bubble_close_coffin
2169 {
2170 \l_ducksay_bubble_fount_tl
2171 \begin{tabular}{@{}r@{}}
2172 \int_compare:nNnTF { \l_ducksay_msg_height_int } = { \c_one_int }
2173 {
2174 \l_ducksay_bubble_delim_right_a_tl
2175 }
2176 {
2177 \l_ducksay_bubble_delim_right_b_tl \\
2178 \int_step_inline:nnn
2179 { 3 } { \l_ducksay_msg_height_int }
2180 {
2181 \l_ducksay_bubble_delim_right_c_tl
2182 \kern-\l_ducksay_bubble_side_kern_tl
2183 \\
2184 }
2185 \l_ducksay_bubble_delim_right_d_tl
2186 }
2187 \end{tabular}
2188 }
2189 \hcoffin_set:Nn \l_ducksay_bubble_top_coffin
2190 {
2191 \l_ducksay_bubble_fount_tl
2192 \int_step_inline:nn
2193 { \l_ducksay_msg_width_int + \l_ducksay_hpad_int }
2194 { \l_ducksay_bubble_delim_top_tl }
2195 }
2196 }
2197 % \end{macrocode}
2198 % \end{macro}^^A=<<
2199 %
2200 % \begin{macro}[internal]{\ducksay_join_bubble_to_msg_coffin:}^^A>>=
2201 % \begin{macrocode}
2202 \cs_new_protected_nopar:Npn \ducksay_join_bubble_to_msg_coffin:
2203 {
2204 \dim_set:Nn \l_ducksay_hpad_dim
2205 {
2206 (
2207 \coffin_wd:N \l_ducksay_bubble_top_coffin
2208 - \coffin_wd:N \l_ducksay_msg_coffin
2209 ) / 2
2210 }
2211 \coffin_join:NnnNnnnn
2212 \l_ducksay_msg_coffin { l } { vc }
2213 \l_ducksay_bubble_open_coffin { r } { vc }
2214 { - \l_ducksay_hpad_dim } { \c_zero_dim }
2215 \coffin_join:NnnNnnnn
2216 \l_ducksay_msg_coffin { r } { vc }
2217 \l_ducksay_bubble_close_coffin { l } { vc }
2218 { \l_ducksay_hpad_dim } { \c_zero_dim }
2219 \coffin_join:NnnNnnnn
2220 \l_ducksay_msg_coffin { hc } { t }
2221 \l_ducksay_bubble_top_coffin { hc } { b }
2222 { \c_zero_dim } { \l_ducksay_bubble_top_kern_dim }
2223 \coffin_join:NnnNnnnn
2224 \l_ducksay_msg_coffin { hc } { b }
2225 \l_ducksay_bubble_top_coffin { hc } { t }
2226 { \c_zero_dim } { \l_ducksay_bubble_bottom_kern_dim }
2227 }
2228 % \end{macrocode}
2229 % \end{macro}^^A=<<
2230 %
2231 % \begin{macro}[internal]{\ducksay_shipout:}^^A>>=
2232 % \begin{macrocode}
2233 \cs_new_protected:Npn \ducksay_shipout:
2234 {
2235 \hcoffin_set:Nn \l_ducksay_msg_coffin { \box_use:N \l_ducksay_msg_box }
2236 \bool_if:NF \l_ducksay_no_bubble_bool
2237 {
2238 \ducksay_measure_msg:
2239 \ducksay_set_bubble_coffins:
2240 \ducksay_set_bubble_top_kern:
2241 \ducksay_set_bubble_bottom_kern:
2242 \ducksay_join_bubble_to_msg_coffin:
2243 }
2244 \bool_if:NF \l_ducksay_no_body_bool
2245 {
2246 \bool_if:NT \l_ducksay_mirrored_body_bool
2247 {
2248 \coffin_scale:Nnn \l_ducksay_body_coffin
2249 { -\c_one_int } { \c_one_int }
2250 \str_case:Vn \l_ducksay_body_to_msg_align_body_tl
2251 {
2252 { l } { \tl_set:Nn \l_ducksay_body_to_msg_align_body_tl { r } }
2253 { r } { \tl_set:Nn \l_ducksay_body_to_msg_align_body_tl { l } }
2254 }
2255 }
2256 \bool_if:NTF \l_ducksay_ignored_body_bool
2257 { \coffin_attach:NVnNVnnn }
2258 { \coffin_join:NVnNVnnn }
2259 \l_ducksay_msg_coffin \l_ducksay_body_to_msg_align_msg_tl { b }
2260 \l_ducksay_body_coffin \l_ducksay_body_to_msg_align_body_tl { t }
2261 { \l_ducksay_body_x_offset_dim } { \l_ducksay_body_y_offset_dim }
2262 }
2263 \coffin_typeset:NVVnn \l_ducksay_msg_coffin
2264 \l_ducksay_output_h_pole_tl \l_ducksay_output_v_pole_tl
2265 { \l_ducksay_output_x_offset_dim } { \l_ducksay_output_y_offset_dim }
2266 \group_end:
2267 }
2268 % \end{macrocode}
2269 % \end{macro}^^A=<<
2270 %
2271 % ^^A\subparagraph{Questionable Syntax Introducing Functions (Hacks)}^^A>>=
2272 %
2273 %^^A=<<
2274 %
2275 % \subparagraph{Message Reading Functions}^^A>>=
2276 %
2277 % Version 2 has different ways of reading the message argument of \cs{ducksay}
2278 % and \cs{duckthink}. They all should allow almost arbitrary content and the
2279 % height and width are set based on the dimensions.
2280 %
2281 % \begin{macro}[internal]{\ducksay_eat_argument_tabular:w}^^A>>=
2282 % \begin{macrocode}
2283 \cs_new:Npn \ducksay_eat_argument_tabular:w
2284 {
2285 \bool_if:NTF \l_ducksay_eat_arg_tab_verb_bool
2286 { \ducksay_eat_argument_tabular_verb:w }
2287 { \ducksay_eat_argument_tabular_normal:w }
2288 }
2289 % \end{macrocode}
2290 % \end{macro}^^A=<<
2291 %
2292 % \begin{macro}[internal]{\ducksay_eat_argument_tabular_inner:w}^^A>>=
2293 % \begin{macrocode}
2294 \cs_new:Npn \ducksay_eat_argument_tabular_inner:w #1
2295 {
2296 \hbox_set:Nn \l_ducksay_msg_box
2297 {
2298 \l_ducksay_msg_fount_tl
2299 \ducksay_msg_tabular_begin:
2300 #1
2301 \ducksay_msg_tabular_end:
2302 }
2303 \ducksay_shipout:
2304 }
2305 % \end{macrocode}
2306 % \end{macro}^^A=<<
2307 %
2308 % \begin{macro}[internal]{\ducksay_eat_argument_tabular_verb:w}^^A>>=
2309 % \begin{macrocode}
2310 \NewDocumentCommand \ducksay_eat_argument_tabular_verb:w
2311 { >{ \ducksay_process_verb_newline:nnn { ~ } { ~ \par } } +v }
2312 {
2313 \ducksay_eat_argument_tabular_inner:w
2314 {
2315 \group_begin:
2316 \__ducksay_everyeof:w { \exp_not:N }
2317 \exp_after:wN
2318 \group_end:
2319 \__ducksay_scantokens:w { #1 }
2320 }
2321 }
2322 % \end{macrocode}
2323 % \end{macro}^^A=<<
2324 %
2325 % \begin{macro}[internal]{\ducksay_eat_argument_tabular_normal:w}^^A>>=
2326 % \begin{macrocode}
2327 \NewDocumentCommand \ducksay_eat_argument_tabular_normal:w { +m }
2328 { \ducksay_eat_argument_tabular_inner:w { #1 } }
2329 % \end{macrocode}
2330 % \end{macro}^^A=<<
2331 %
2332 % \begin{macro}[internal]{\ducksay_eat_argument_hbox:w}^^A>>=
2333 % \begin{macrocode}
2334 \cs_new_protected_nopar:Npn \ducksay_eat_argument_hbox:w
2335 {
2336 \bool_if:NTF \l_ducksay_msg_strip_spaces_bool
2337 { \@grabbox }
2338 { \@grabbox* }
2339 {} \l_ducksay_msg_box \l_ducksay_msg_fount_tl \hbox {} \ducksay_shipout:
2340 }
2341 % \end{macrocode}
2342 % \end{macro}^^A=<<
2343 %
2344 % \begin{macro}[internal]{\ducksay_eat_argument_vbox:w}^^A>>=
2345 % \begin{macrocode}
2346 \cs_new_protected_nopar:Npn \ducksay_eat_argument_vbox:w
2347 {
2348 \ducksay_evaluate_message_alignment_fixed_width_vbox:
2349 \bool_if:NTF \l_ducksay_msg_strip_spaces_bool
2350 { \@grabbox }
2351 { \@grabbox* }
2352 {
2353 \hsize \l_ducksay_msg_width_dim
2354 \linewidth \hsize
2355 \l_ducksay_msg_align_vbox_tl
2356 \@afterindentfalse
2357 \@afterheading
2358 }
2359 \l_ducksay_msg_box \l_ducksay_msg_fount_tl \vbox {} \ducksay_shipout:
2360 }
2361 % \end{macrocode}
2362 % \end{macro}^^A=<<
2363 %
2364 %^^A=<<
2365 %
2366 % \subparagraph{Generating Variants of External Functions}^^A>>=
2367 %
2368 % \begin{macrocode}
2369 \cs_generate_variant:Nn \coffin_join:NnnNnnnn { NVnNVnnn }
2370 \cs_generate_variant:Nn \coffin_attach:NnnNnnnn { NVnNVnnn }
2371 \cs_generate_variant:Nn \coffin_typeset:Nnnnn { NVVnn }
2372 \cs_generate_variant:Nn \str_case:nn { Vn }
2373 % \end{macrocode}
2374 %
2375 %^^A=<<
2376 %
2377 %^^A=<<
2378 %
2379 % \paragraph{Document level}^^A>>=
2380 %
2381 % \begin{macro}{\ducksay}^^A>>=
2382 % \begin{macrocode}
2383 \NewDocumentCommand \ducksay { O{} }
2384 {
2385 \ducksay_digest_options:n { #1 }
2386 }
2387 % \end{macrocode}
2388 % \end{macro}^^A=<<
2389 %
2390 % \begin{macro}{\duckthink}^^A>>=
2391 % \begin{macrocode}
2392 \NewDocumentCommand \duckthink { O{} }
2393 {
2394 \ducksay_digest_options:n { think, #1 }
2395 }
2396 % \end{macrocode}
2397 % \end{macro}^^A=<<
2398 %
2399 %^^A=<<
2400 %
2401 %^^A=<<
2402 %
2403 % \begin{macrocode}
2404 %</code.v2>
2405 % \end{macrocode}^^A=<<
2406 %
2407 % \SetVersion{}%
2408 % \subsection{Definition of the Animals}^^A>>=
2409 %
2410 % \begin{macrocode}
2411 %<*animals>
2412 \ProvidesFile{ducksay.animals.tex}
2413 [\ducksay@date\space v\ducksay@version\space ducksay animals]
2414 %^^A some of the below are from http://ascii.co.uk/art/
2415 \AddAnimal{duck}%>>=
2416 { \
2417 \ __
2418 >(' )
2419 )/
2420 /(
2421 / `----/
2422 \ ~=- /
2423 ~^~^~^~^~^~^~^}%=<<
2424 \AddAnimal{small-duck}%>>=
2425 { \
2426 \
2427 >()_
2428 (__)__ _}%=<<
2429 \AddAnimal{duck-family}%>>=
2430 { \
2431 \ __
2432 >(' )
2433 )/
2434 /(
2435 / `----/ -()_ >()_
2436 __\__~=-_/__ _(__)__(__)__ _}%=<<
2437 \AddAnimal{cow}%>>=
2438 { \ ^__^
2439 \ (oo)\_______
2440 (__)\ )\/\
2441 ||----w |
2442 || ||}%=<<
2443 \AddAnimal{head-in}%>>=
2444 { \
2445 \ ^__^ /
2446 (oo)\_______/ ________
2447 (__)\ )=( ___|_ \____
2448 ||----w | \ \ \____ |
2449 || || || ||}%=<<
2450 \AddAnimal{sodomized}%>>=
2451 { \ _
2452 \ (_)
2453 ^__^ / \
2454 (oo)\_____/_\ \
2455 (__)\ ) /
2456 ||----w ((
2457 || ||>>}%=<<
2458 \AddAnimal{tux}%>>=
2459 { \
2460 \ .--.
2461 |o_o |
2462 |\_/ |
2463 // \ \
2464 (| | )
2465 /'\_ _/`\
2466 \___)=(___/}%=<<
2467 \AddAnimal{pig}%>>=
2468 + \ _//| .-~~~-.
2469 \ _/oo } }-@
2470 ('')_ } |
2471 `--'| { }--{ }
2472 //_/ /_/+%=<<
2473 \AddAnimal{frog}%>>=
2474 { \
2475 \ (.)_(.)
2476 _ ( _ ) _
2477 / \/`-----'\/ \
2478 __\ ( ( ) ) /__
2479 ) /\ \._./ /\ (
2480 )_/ /|\ /|\ \_(}%=<<
2481 \AddAnimal{snowman}%>>=
2482 { \
2483 \_[_]_
2484 (")
2485 >-( : )-<
2486 (__:__)}%=<<
2487 \AddAnimal[tail-symbol=s]{hedgehog}%>>=
2488 { s .\|//||\||.
2489 s |/\/||/|//|/|
2490 /. `|/\\|/||/||
2491 o__,_|//|/||\||'}%=<<
2492 \AddAnimal{kangaroo}%>>=
2493 { \
2494 \ _,' ___
2495 <__\__/ \
2496 \_ / _\
2497 \,\ / \\
2498 // \\
2499 ,/' `\_,}%=<<
2500 %^^A http://chris.com/ascii/index.php?art=animals/rabbits
2501 \AddAnimal[tail-symbol=s,tail-count=3]{rabbit}%>>=
2502 { s
2503 s / \`\ __
2504 s | \ `\ /`/ \
2505 \_/`\ \-"-/` /\ \
2506 | | \ |
2507 (d b) \_/
2508 / \
2509 ,".|.'.\_/.'.|.",
2510 / /\' _|_ '/\ \
2511 | / '-`"`-' \ |
2512 | | | |
2513 | \ \ / / |
2514 \ \ \ / / /
2515 `"`\ : /'"`
2516 `""`""`}%=<<
2517 \AddAnimal{bunny}%>>=
2518 { \
2519 \ /
2520 /\ /
2521 ( )
2522 .( o ).}%=<<
2523 \AddAnimal{small-rabbit}%>>=
2524 { \
2525 \ _//
2526 (')---.
2527 _/-_( )o}%=<<
2528 \AddAnimal[tail-symbol=s,tail-count=3]{dragon}%>>=
2529 { s / \ //\
2530 s |\___/| / \// \\
2531 s /0 0 \__ / // | \ \
2532 / / \/_/ // | \ \
2533 @_^_@'/ \/_ // | \ \
2534 //_^_/ \/_ // | \ \
2535 ( //) | \/// | \ \
2536 ( / /) _|_ / ) // | \ _\
2537 ( // /) '/,_ _ _/ ( ; -. | _ _\.-~ .-~~~^-.
2538 (( / / )) ,-{ _ `-.|.-~-. .~ `.
2539 (( // / )) '/\ / ~-. _ .-~ .-~^-. \
2540 (( /// )) `. { } / \ \
2541 (( / )) .----~-.\ \-' .~ \ `. \^-.
2542 ///.----..> \ _ -~ `. ^-` ^-_
2543 ///-._ _ _ _ _ _ _}^ - - - - ~ ~-- ,.-~
2544 /.-~}%=<<
2545 %^^A http://www.ascii-art.de/ascii/def/dogs.txt
2546 \AddAnimal{dog}%>>=
2547 { \ __
2548 \ .-'\/\
2549 "\ '------.
2550 ___/ ( .'_____
2551 '-----'"""'------"""""'}%=<<
2552 %^^A http://ascii.co.uk/art/squirrel
2553 \AddAnimal{squirrel}%>>=
2554 { \ ,;:;;,
2555 \ , ;;;;;
2556 .=', ;:;;:,
2557 /_', "=. ';:;:;
2558 @=:__, \,;:;:'
2559 _(\.= ;:;;'
2560 `"_( _/="`
2561 `"'``}%=<<
2562 \AddAnimal{snail}%>>=
2563 { \
2564 \ .-""-.
2565 oo ; .-. :
2566 \\__..-: '.__.')._
2567 "-._.._'.__.-'_.."}%=<<
2568 %^^A http://www.ascii-art.de/ascii/uvw/unicorn.txt
2569 \AddAnimal{unicorn}%>>=
2570 { \
2571 \ /((((((\\\\
2572 ---====((((((((((\\\\\
2573 (( \\\\\\\
2574 ( (* _/ \\\\\\\
2575 \ / \ \\\\\\_ __,,__
2576 | | | </ "-----"" ((\\\\
2577 o_| / / \ \\\\ \\\\\\\
2578 | ._ ( \ \\\\\\\\\\\\\\\\
2579 | / / / \\\\\\\ \\
2580 .______/\/ / / / \\\
2581 / __.____/ _/ _( /\
2582 / / / ________/:_ ___,,--' \ / \_
2583 / / \ \ """"""" \ \ \_ \
2584 ( < \ \ > / \ \
2585 \/ \\_ / / > )
2586 \_| / / / /
2587 _// _//
2588 /_| /_|}%=<<
2589 %^^A https://asciiart.website//index.php?art=animals/other%20(water)
2590 \AddAnimal[tail-count=3,tail-symbol=s]{whale}%>>=
2591 { s |-.
2592 s .-""-._ \ \.--|
2593 s / `-..__) ,-'
2594 | . /
2595 \--.__, .__.,'
2596 `-.___'._\_.'}%=<<
2597 %^^A from http://www.ascii-art.de/ascii/s/starwars.txt :
2598 \AddAnimal[tail-count=3]{yoda}%>>=
2599 { \
2600 \ ____
2601 \ _.' : `._
2602 .-.'`. ; .'`.-.
2603 __ / : ___\ ; /___ ; \ __
2604 ,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
2605 :' `.t""--.. '<@.`;_ ',@>` ..--""j.' `;
2606 `:-.._J '-.-'L__ `-- ' L_..-;'
2607 "-.__ ; .-" "-. : __.-"
2608 L ' /.------.\ ' J
2609 "-. "--" .-"
2610 __.l"-:_JL_;-";.__
2611 .-j/'.; ;"""" / .'\"-.
2612 .' /:`. : : /.".''; `.
2613 .-" / ;`.". : ."." : "-.
2614 .+"-. : : ".".". ."." ;-._ \
2615 ; \ `.; ; . "."-"." : : "+. ;
2616 : ; ; ; . ."." ; : ; : \:
2617 ; : ; : / / / , ;: ; :
2618 : \ ; : ; ; / : , : ; / ::
2619 ; ; : ; : ; ; ; ; : ;:
2620 : : ; : ;. ; ' : : ; : ;
2621 ;\ : ; : . , ; ; ; ;
2622 : `."-; : ; . ; : ; / ;
2623 ; -: ; : , , ; : .-" :
2624 :\ \ : ; , : \.-" :
2625 ;`. \ ; : . , ;.'_..-- / ;
2626 : "-. "-: ; , :/." .' :
2627 \ \ : : ;/ __ :
2628 \ .-`.\ /t-"" ":-+. :
2629 `. .-" `l __/ /`. : ; ; \ ;
2630 \ .-" .-"-.-" .' .'j \ / ;/
2631 \ / .-" /. .'.' ;_:' ;
2632 :-""-.`./-.' / `.___.'
2633 \ `t ._ /
2634 "-.t-._:'}%=<<
2635 \AddAnimal[tail-count=3]{yoda-head}%>>=
2636 { \
2637 \ ____
2638 \ _.' : `._
2639 .-.'`. ; .'`.-.
2640 __ / : ___\ ; /___ ; \ __
2641 ,'_ ""--.:__;".-.";: :".-.":__;.--"" _`,
2642 :' `.t""--.. '<@.`;_ ',@>` ..--""j.' `;
2643 `:-.._J '-.-'L__ `-- ' L_..-;'
2644 "-.__ ; .-" "-. : __.-"
2645 L ' /.------.\ ' J
2646 "-. "--" .-"
2647 __.l"-:_JL_;-";.__
2648 .-j/'.; ;"""" / .'\"-.
2649 .' /:`. : : /.".''; `.
2650 .-" / ;`.". : ."." : "-.
2651 .+"-. : : ".".". ."." ;-._ \}%=<<
2652 %^^A from https://www.ascii-code.com/ascii-art/movies/star-wars.php
2653 \AddAnimal{small-yoda}%>>=
2654 { \
2655 \
2656 __.-._
2657 '-._"7'
2658 /'.-c
2659 | /T
2660 _)_/LI}%=<<
2661 \AddAnimal{r2d2}%>>=
2662 { \
2663 \ ,-----.
2664 ,'_/_|_\_`.
2665 /<<::8[O]::>\
2666 _|-----------|_
2667 | | ====-=- | |
2668 | | -=-==== | |
2669 \ | ::::|()|| /
2670 | | ....|()|| |
2671 | |_________| |
2672 | |\_______/| |
2673 / \ / \ / \
2674 `---' `---' `---'}%=<<
2675 \AddAnimal{vader}%>>=
2676 { \ _.-'~~~~~~`-._
2677 \ / || \
2678 / || \
2679 | || |
2680 | _______||_______ |
2681 |/ ----- \/ ----- \|
2682 / ( ) ( ) \
2683 / \ ----- () ----- / \
2684 / \ /||\ / \
2685 / \ /||||\ / \
2686 / \ /||||||\ / \
2687 /_ \O========O/ _\
2688 `--...__|`-._ _.-'|__...--'
2689 | `' |}%=<<
2690 \AddAnimal[tail-symbol=|,tail-count=1]{crusader}%>>=
2691 { |
2692 \[T]/}
2693 \csname bool_if:cT\endcsname {l_ducksay_version_one_bool}
2694 {\AnimalOptions{crusader}{tail-1=|,rel-align=c}}
2695 \csname bool_if:cT\endcsname {l_ducksay_version_two_bool}
2696 {\AnimalOptions{crusader}{tail-1=|,body-align=c}}%=<<
2697 %^^A http://ascii.co.uk/art/knights
2698 \AddAnimal[tail-count=3]{knight}%>>=
2699 { \
2700 \ ,-"""-.
2701 \ | === |
2702 ) | (
2703 .=='\" "/`==.
2704 .'\ (`:') /`.
2705 _/_ |_.-' : `-._|__\_
2706 <___>'\ : / `<___>
2707 / / >=======< / /
2708 _/ .' / ,-:-. \/=,'
2709 / _/ |__/v^v^v\__) \
2710 \(\) |V^V^V^V^V|\_/
2711 (\\ \`---|---'/
2712 \\ \-._|_,-/
2713 \\ |__|__|
2714 \\ <___X___>
2715 \\ \..|../
2716 \\ \ | /
2717 \\ /V|V\
2718 \|/ | \
2719 '--' `--`}%=<<
2720 %^^A https://www.asciiart.eu/mythology/ghosts
2721 \AddAnimal{ghost}%>>=
2722 { \
2723 \ .-.
2724 (o o)
2725 | O \
2726 \ \
2727 `~~~'}%=<<
2728 %^^Ahttps://asciiart.website/index.php?art=creatures/fairies
2729 \AddAnimal{fairy}%>>=
2730 { \
2731 \ .oOOb
2732 .. .oO O
2733 '::; d O
2734 ;;;;d ..oO
2735 * ::O;;;'OooO
2736 ~"\. dp'(O.o.
2737 \op 'oOb
2738 obU
2739 dop
2740 dop
2741 PO
2742 O 'b
2743 l P.
2744 / ;
2745 '}%=<<
2746 \AddAnimal[tail-symbol=s]{only-tail}%>>=
2747 { s
2748 s}%=<<
2749 \AddAnimal[tail-symbol=s,tail-count=3]{only-tail3}%>>=
2750 { s
2751 s
2752 s}%=<<
2753 %^^A head taken from https://www.asciiart.eu/animals/reptiles/snakes
2754 \AddAnimal[tail-symbol=s,tail-count=3]{snake}% >>=
2755 { s
2756 s /^\/^\
2757 s _|__| O |
2758 /' \_/ \
2759 \/ |_________/ \ \
2760 \_/ \_______ \ \
2761 `| | |\
2762 / / _---_ | |
2763 / / / __ "-_ ," |
2764 | "--" / "-_ "--" ,"
2765 "-_____-" "-___-"}% =<<
2766 %^^A http://www.ascii-art.de/ascii/c/cat.txt
2767 \AddAnimal{cat}% >>=
2768 + \
2769 \ _ ___ .--.
2770 \`.|\..----...-'` `-._.-' .-'
2771 / ' ` , __.-'
2772 )/' _/ \ `-_, /
2773 `-'" `"\_ ,_.-;_.-\_ ',
2774 _.-'_./ {_.' ; /
2775 {_.-``-' {_/+% =<<
2776 %^^A https://www.asciiart.eu/animals/cats
2777 \AddAnimal{sleepy-cat}% >>=
2778 { \
2779 \ |\ _,,,---,,_ _._
2780 /,`.-'`' -. )'._,'.-,)
2781 |,4- ) )-,_. ,\ ( `-.-'
2782 '---''(_/--' `-'\_)}% =<<
2783 \AddAnimal{schroedinger-dead}% >>=
2784 { \
2785 \ _.--"""--._
2786 | |
2787 | -|- |
2788 | | |
2789 | |
2790 | Felix |
2791 __|___________|__ _
2792 o . . .
2793 ~ . o o
2794 . ~ .}% =<<
2795 %^^A https://www.asciiart.eu/animals/cats
2796 \AddAnimal{schroedinger-alive}% >>=
2797 { \
2798 \ ,_ _
2799 |\\__,'/
2800 / _ _ | ,--.
2801 ( @ @ ) / ,-'
2802 \ _T_/-._( (
2803 / `. \
2804 | _ \ |
2805 \ \ , / |
2806 || |-_\__ /
2807 ((_/`(____,-'}% =<<
2808 %^^A provided by Plergux
2809 %^^A (https://chat.stackexchange.com/transcript/message/55986902#55986902)
2810 \AddAnimal{sheep}% >>=
2811 { \ _,_,_,_,_,
2812 \ .:( ,) ),
2813 (__, (, ),
2814 / o ( ,) ,) )>
2815 (___(, (, ,)
2816 (, ,) ,)
2817 `-_,---_,-'
2818 || ||}% =<<
2819 %^^A based on joe schmuck (http://www.ascii-art.de/ascii/pqr/platypus.txt)
2820 \AddAnimal[tail-symbol=s]{platypus}% >>=
2821 | s _.-^~~^^`~-,,,~~''```~-''``~'``~,
2822 s ______,' -o :. _ . ; ,'`, `.
2823 ( -\.._,.;;'._,( } _`_-_,, `, `,
2824 ``~~~~~~' ((/'(((____/~~'(,(,___> `~'|% =<<
2825 \AddAnimal[tail-symbol=s]{small-horse}% >>=
2826 { s _,_
2827 s /._ \\
2828 /_/ |_\\ _ __
2829 / \\ \\
2830 \ _ __ _ /||
2831 | | | | ||
2832 | | | |}% =<<
2833 \AddAnimal{ladybug}% >>=
2834 { \ o o
2835 \ _\_/_
2836 /__!__\
2837 '| o : o |'
2838 -|o : o|-
2839 ,| o : o |,
2840 \__:__/}% =<<
2841 %^^A based on art by Joan Stark (jgs)
2842 %^^A (https://www.asciiart.eu/animals/reptiles/turtles)
2843 \AddAnimal[tail-symbol=s]{turtle}
2844 { s
2845 s __
2846 /_'\ .,-;-;-,.
2847 \ (/_/_|_\_\_\_
2848 /\=<_><_><_><_>-'
2849 /_/'-\_\====\_\'
2850 "" "" ""}
2851 %</animals>
2852 % \end{macrocode}^^A=<<
2853 %^^A%^^A https://www.asciiart.eu/mythology/fairies
2854 %^^A\AddAnimal[tail-symbol=s,tail-count=3]{fairy}%>>=
2855 %^^A{ s ))
2856 %^^A s ((((--.
2857 %^^A s )))))) ;--.
2858 %^^A . ' . /(((((( .' \
2859 %^^A -= * =- (.-,))))) / |
2860 %^^A ' .\' )o ))/ .' _/\ /
2861 %^^A \_ \_ /( / \ /(
2862 %^^A /_\ .--' `-. // \
2863 %^^A ||\/ , , , '._// |
2864 %^^A ||/ /`\_,\_,;`-._/ /
2865 %^^A \_.' ) /`\ .'
2866 %^^A .' . \ ;.. /`
2867 %^^A / "\( `.(
2868 %^^A | |/ / ` `
2869 %^^A | | /
2870 %^^A | |. /
2871 %^^A __-' / /
2872 %^^A _ .' _.-` ,'
2873 %^^A _.` `.-'` , /
2874 %^^A /_.-'` ; /
2875 %^^A , /
2876 %^^A . /
2877 %^^A ( |
2878 %^^A \"}%=<<
2879 %
2880 %^^A=<<
2881 %
2882 % \end{implementation}^^A=<<
2883 %
2884 % \closingpage
2885 %
2886 \endinput
2887 %
2888 ^^A vim: ft=tex fdm=marker fmr=>>=,=<<