| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: duckuments.dtx Copyright (C) 2018-2019 Jonathan P. Spratte |
| 4 |
% |
| 5 |
% It may be distributed and/or modified under the conditions of the LaTeX |
| 6 |
% Project Public License (LPPL), either version 1.3c of this license or (at your |
| 7 |
% option) any later version. The latest version of this license is in the file |
| 8 |
% |
| 9 |
% https://www.latex-project.org/lppl.txt |
| 10 |
% |
| 11 |
% ------------------------------------------------------------------------------ |
| 12 |
% |
| 13 |
%<*driver> |
| 14 |
\def\nameofplainTeX{plain} |
| 15 |
\ifx\fmtname\nameofplainTeX\else |
| 16 |
\expandafter\begingroup |
| 17 |
\fi |
| 18 |
\input l3docstrip.tex |
| 19 |
\askforoverwritefalse |
| 20 |
\preamble |
| 21 |
|
| 22 |
-------------------------------------------------------------- |
| 23 |
duckuments -- minimal working duckuments |
| 24 |
E-mail: [email protected] |
| 25 |
Released under the LaTeX Project Public License v1.3c or later |
| 26 |
See http://www.latex-project.org/lppl.txt |
| 27 |
-------------------------------------------------------------- |
| 28 |
|
| 29 |
Copyright (C) 2018-2019 Jonathan P. Spratte |
| 30 |
|
| 31 |
This work may be distributed and/or modified under the conditions of the |
| 32 |
LaTeX Project Public License (LPPL), either version 1.3c of this license or |
| 33 |
(at your option) any later version. The latest version of this license is in |
| 34 |
the file: |
| 35 |
|
| 36 |
http://www.latex-project.org/lppl.txt |
| 37 |
|
| 38 |
This work is "maintained" (as per LPPL maintenance status) by |
| 39 |
Jonathan P. Spratte. |
| 40 |
|
| 41 |
This work consists of the file duckuments.dtx |
| 42 |
and the derived files duckuments.pdf, |
| 43 |
duckuments.sty, |
| 44 |
example-image-duck.tex and |
| 45 |
example-image-duck-portrait.tex |
| 46 |
|
| 47 |
\endpreamble |
| 48 |
% stop docstrip adding \endinput |
| 49 |
\postamble |
| 50 |
\endpostamble |
| 51 |
\generate{\file{duckuments.sty}{\from{duckuments.dtx}{pkg}}} |
| 52 |
\generate{\file{example-image-duck.tex}{\from{duckuments.dtx}{eid}}} |
| 53 |
\generate{\file{example-image-duck-portrait.tex}{\from{duckuments.dtx}{eidp}}} |
| 54 |
\ifx\fmtname\nameofplainTeX |
| 55 |
\expandafter\endbatchfile |
| 56 |
\else |
| 57 |
\expandafter\endgroup |
| 58 |
\fi |
| 59 |
%</driver> |
| 60 |
% |
| 61 |
%<*driver|pkg> |
| 62 |
\RequirePackage{xparse}[2019-05-03] |
| 63 |
\RequirePackage{letltxmacro,l3keys2e} |
| 64 |
\def\duckuments@version{0.5} |
| 65 |
\def\duckuments@date{2019-10-03} |
| 66 |
%</driver|pkg> |
| 67 |
% |
| 68 |
%<*driver> |
| 69 |
\ProvidesFile{duckuments.dtx} |
| 70 |
[\csname duckuments@date\endcsname\space minimal working duckuments] |
| 71 |
\documentclass{l3doc} |
| 72 |
\usepackage{duckuments} |
| 73 |
\usepackage{enumitem} |
| 74 |
\usepackage{l3color} |
| 75 |
\newenvironment{options} |
| 76 |
{\begin{description}[style=nextline,font=\normalfont\ttfamily]} |
| 77 |
{\end{description}} |
| 78 |
\begin{document} |
| 79 |
\DocInput{duckuments.dtx} |
| 80 |
\end{document} |
| 81 |
%</driver> |
| 82 |
% |
| 83 |
%<*eid> |
| 84 |
\documentclass[tikz,multi]{standalone} |
| 85 |
|
| 86 |
\usepackage{tikzducks} |
| 87 |
\usepackage{duckuments} |
| 88 |
|
| 89 |
\begin{document} |
| 90 |
\duckumentsDrawRandomDucks |
| 91 |
\end{document} |
| 92 |
%</eid> |
| 93 |
% |
| 94 |
%<*eidp> |
| 95 |
\documentclass[tikz,multi]{standalone} |
| 96 |
|
| 97 |
\usepackage{tikzducks} |
| 98 |
\usepackage{duckuments} |
| 99 |
|
| 100 |
\begin{document} |
| 101 |
\duckumentsDrawRandomDucks* |
| 102 |
\end{document} |
| 103 |
%</eidp> |
| 104 |
% |
| 105 |
%<*pkg> |
| 106 |
\ProvidesExplPackage |
| 107 |
{duckuments} {\duckuments@date} |
| 108 |
{\duckuments@version} {minimal working duckuments} |
| 109 |
%</pkg> |
| 110 |
% \fi |
| 111 |
% |
| 112 |
% \title{The \pkg{duckuments} package} |
| 113 |
% \author{Jonathan P. Spratte\thanks{E-mail: [email protected]}} |
| 114 |
% \makeatletter |
| 115 |
% \date{version \duckuments@version, released \duckuments@date} |
| 116 |
% \makeatother |
| 117 |
% \maketitle |
| 118 |
% \tableofcontents |
| 119 |
% |
| 120 |
% \begin{documentation}^^A>>= |
| 121 |
% |
| 122 |
% \section{Introducktion}^^A>>= |
| 123 |
% |
| 124 |
% This package was inspired by the question |
| 125 |
% \href{https://tex.stackexchange.com/questions/419751} |
| 126 |
% {getting ducks in example images}. |
| 127 |
% It began on the idea to patch \cs{includegraphics} to automatically change its |
| 128 |
% behaviour if |example-image-duck| is used, but then it turned out to be a |
| 129 |
% simple alternative to the \pkg{blindtext} package. |
| 130 |
% |
| 131 |
% It is written as a docstrip file: executing |latex duckuments.dtx| generates |
| 132 |
% the \file{duckuments.sty}, \file{example-image-duck.tex}, and |
| 133 |
% \file{example-image-duck-portrait.tex} file and typesets this duckumentation; |
| 134 |
% execute |tex duckuments.dtx| to only generate the files \file{duckuments.sty}, |
| 135 |
% \file{example-image-duck.tex}, and \file{example-image-duck-portrait.tex}. |
| 136 |
% |
| 137 |
% For its functionality \file{example-image-duck.tex} and |
| 138 |
% \file{example-image-duck-portrait.tex} must be compiled at least once. The |
| 139 |
% sources are hosted on |
| 140 |
% \href{https://github.com/Skillmon/ltx_duckuments}{github}. |
| 141 |
% |
| 142 |
% \textbf{The package should support any engine.} However for engines other than |
| 143 |
% \pdfTeX, \LuaTeX, and \XeTeX\ it requires |extractbb| to be legal in a |
| 144 |
% shell-escape (which should normally be the case). |
| 145 |
%^^A=<< |
| 146 |
% |
| 147 |
% \section{Duckumentation}^^A>>= |
| 148 |
% |
| 149 |
% \subsection{Ducky content}^^A>>= |
| 150 |
% |
| 151 |
% \begin{function}{\duckument}^^A>>= |
| 152 |
% \begin{syntax} |
| 153 |
% \cs{duckument}\oarg{key=value} |
| 154 |
% \end{syntax} |
| 155 |
% Produces a duckument with one sectioning entry of each level starting at |
| 156 |
% \cs{chapter} (if available) and two variants of the list environment |
| 157 |
% \env{itemize}, \env{enumerate}, and \env{description}, one only at top |
| 158 |
% level and one with 4~environments nested. The \meta{key=value}s accept every |
| 159 |
% key as explained in \autoref{sec:keys}, but not every key has an effect. |
| 160 |
% \end{function}^^A=<< |
| 161 |
% |
| 162 |
% \begin{function}{\blindduck}^^A>>= |
| 163 |
% \begin{syntax} |
| 164 |
% \cs{blindduck}\oarg{key=value} |
| 165 |
% \end{syntax} |
| 166 |
% Produces one paragraph of dummy content. The \meta{key=value}s accept every |
| 167 |
% key as explained in \autoref{sec:keys}, but not every key has an effect. |
| 168 |
% \end{function}^^A=<< |
| 169 |
% |
| 170 |
% \begin{function}{\ducklist}^^A>>= |
| 171 |
% \begin{syntax} |
| 172 |
% \cs{ducklist}\meta{*}\marg{environment} |
| 173 |
% \end{syntax} |
| 174 |
% Sets a list of the specified \meta{environment}, if \meta{*} is given |
| 175 |
% \cs{item}\oarg{dummy} is used instead of only \cs{item}. For |description| |
| 176 |
% the starred version is used automatically. |
| 177 |
% \end{function}^^A=<< |
| 178 |
% |
| 179 |
% \begin{function}{\ducklistlist}^^A>>= |
| 180 |
% \begin{syntax} |
| 181 |
% \cs{ducklistlist}\meta{*}\marg{list} |
| 182 |
% \end{syntax} |
| 183 |
% Sets 4~levels of a nested list of the specified \meta{environment}, if |
| 184 |
% \meta{*} is given \cs{item}\oarg{dummy} is used instead of only \cs{item}. |
| 185 |
% For |description| the starred version is used automatically. |
| 186 |
% \end{function}^^A=<< |
| 187 |
% |
| 188 |
% \begin{function}{\duckitemize}^^A>>= |
| 189 |
% Abbreviation for \cs{ducklist}|{itemize}|. |
| 190 |
% \end{function}^^A=<< |
| 191 |
% |
| 192 |
% \begin{function}{\duckenumerate}^^A>>= |
| 193 |
% Abbreviation for \cs{ducklist}|{enumerate}|. |
| 194 |
% \end{function}^^A=<< |
| 195 |
% |
| 196 |
% \begin{function}{\duckdescription}^^A>>= |
| 197 |
% Abbreviation for \cs{ducklist}|{description}|. |
| 198 |
% \end{function}^^A=<< |
| 199 |
%^^A=<< |
| 200 |
% |
| 201 |
% \subsection{Other Macros}^^A>>= |
| 202 |
% |
| 203 |
% \begin{function}{\duckumentsCreateExampleFiles}^^A>>= |
| 204 |
% Creates the files \file{example-image-duck.tex} and |
| 205 |
% \file{example-image-duck-portrait.tex} in the current working directory. |
| 206 |
% \end{function}^^A=<< |
| 207 |
% |
| 208 |
% \begin{function}{\duckumentsDrawRandomDucks}^^A>>= |
| 209 |
% \begin{syntax} |
| 210 |
% \cs{duckumentsDrawRandomDucks}\meta{*}\oarg{count} |
| 211 |
% \end{syntax} |
| 212 |
% Draws \meta{count} random \pkg{tikzducks} using |
| 213 |
% \pkg{Ti\textit{k}Z}. \meta{count} defaults to \cs{duckuments@randoms}. |
| 214 |
% Note that \pkg{duckuments} doesn't load \pkg{Ti\textit{k}Z}, this macro is |
| 215 |
% for the use in \file{example-image-duck.tex} and |
| 216 |
% \file{example-image-duck-portrait.tex}. If the optional star is given, the |
| 217 |
% images will be drawn in portrait orientation else in landscape. |
| 218 |
% \end{function}^^A=<< |
| 219 |
%^^A=<< |
| 220 |
% |
| 221 |
% \subsection{Patches}^^A>>= |
| 222 |
% |
| 223 |
% The package patches \cs{includegraphics} if \pkg{graphicx} is loaded at the |
| 224 |
% time the patch is applied (see \autoref{sec:keys}, |immediate|). The patch |
| 225 |
% changes the behaviour if the used image file is \file{example-image-duck} or |
| 226 |
% \file{example-image-duck-portrait}. If that is the case, a random page of that |
| 227 |
% document is used. There shouldn't be any change in behaviour if other files |
| 228 |
% are used. |
| 229 |
% |
| 230 |
% The patch is done so that one can use \pkg{tikzducks} ducks without the need |
| 231 |
% of loading \pkg{tikz} in a minimal working duckument as example images. |
| 232 |
%^^A=<< |
| 233 |
% |
| 234 |
% \subsection{Options}\label{sec:keys}^^A>>= |
| 235 |
% |
| 236 |
% The package and commands which take a \oarg{key=value} accept the following |
| 237 |
% options. Some of which only make sense as package options. The |
| 238 |
% \textbf{\texttt{bold}} printed value is the one used if you don't specify a |
| 239 |
% value. The \textit{\texttt{italic}} printed value is the initial one. |
| 240 |
% \begin{options} |
| 241 |
% \item[toc=\textbf{true}$\vert$\textit{false}] |
| 242 |
% If |true| the \cs{duckument} contains a ToC. During package load time the |
| 243 |
% key doesn't throw errors but only warnings for values other than |true| |
| 244 |
% and |false|. This is done for compatibility reasons with classes which |
| 245 |
% take a non-boolean |toc| option (like those of KOMA-script). |
| 246 |
% \item[maths=\textbf{both}$\vert$inline$\vert$display$\vert$\textit{none}] |
| 247 |
% If |both| the \cs{blindduck} (which is also used by \cs{duckument}) |
| 248 |
% contains both inline and displayed math. With |inline| and |display| the |
| 249 |
% respective maths is activated. |none| disables both. |
| 250 |
% \item[full] |
| 251 |
% This typesets the full range of \cs{blindduck}. Don't use this as a |
| 252 |
% package option. |
| 253 |
% \item[all] |
| 254 |
% synonym for |full|. |
| 255 |
% \item[immediate=\textbf{true}$\vert$\textit{false}] |
| 256 |
% If |true| \cs{includegraphics} is patched during package load time, else |
| 257 |
% the patching is done \cs{AtBeginDocument}. |
| 258 |
% \end{options} |
| 259 |
% Additionally \cs{blindduck} and \cs{duckument} accept another key which must |
| 260 |
% match one of the following patterns and doesn't get any value. Patterns: |
| 261 |
% \bgroup |
| 262 |
% \def\num#1{\texttt{\meta{num#1}}}% |
| 263 |
% \begin{description}[style=nextline,font=\normalfont\ttfamily] |
| 264 |
% \item[\meta{num1}] The paragraph \num{1} is printed. |
| 265 |
% \item[\meta{num1-}] Like the above |
| 266 |
% \item[\meta{-num2}] The paragraphs up to \num{2} are printed. |
| 267 |
% \item[\meta{num1-num2}] The paragraphs from \num{1} up to \num{2} |
| 268 |
% are printed. |
| 269 |
% \item[\meta{-}] The next paragraph is printed. |
| 270 |
% \end{description} |
| 271 |
% If the used pattern includes a ``|-|'' a \cs{par} is used after each |
| 272 |
% paragraph. If any pattern is used the next pattern that doesn't include a |
| 273 |
% \num{1} starts with the paragraph after the last used paragraph, cycling back |
| 274 |
% to the first after the last available paragraph. |
| 275 |
% \egroup |
| 276 |
%^^A=<< |
| 277 |
%^^A=<< |
| 278 |
% |
| 279 |
% \end{documentation}^^A=<< |
| 280 |
% |
| 281 |
% \begin{implementation}^^A>>= |
| 282 |
% |
| 283 |
% \section{Implementation} |
| 284 |
% |
| 285 |
% \begin{macrocode} |
| 286 |
%<*pkg> |
| 287 |
% \end{macrocode} |
| 288 |
% |
| 289 |
% \begin{macrocode} |
| 290 |
%<@@=duckuments> |
| 291 |
% \end{macrocode} |
| 292 |
% |
| 293 |
% \subsection{Check for possible problems}^^A>>= |
| 294 |
% |
| 295 |
% Check whether \file{example-image-duck.pdf} exists. |
| 296 |
% \begin{macrocode}^^A>>= |
| 297 |
\file_if_exist:nF { example-image-duck.pdf } |
| 298 |
{%>>= |
| 299 |
% \end{macrocode} |
| 300 |
% If the current \cs{jobname} doesn't match \file{example-image-duck} throw an |
| 301 |
% error. |
| 302 |
% \begin{macrocode} |
| 303 |
\str_if_eq:VnF \c_sys_jobname_str { example-image-duck } |
| 304 |
{ |
| 305 |
\msg_new:nnnn { duckuments } { missing~file } |
| 306 |
{ |
| 307 |
The~file~`#1`~can't~be~found.~Make~sure~to~create~it |
| 308 |
\tl_if_empty:nF{#2}{~#2}. |
| 309 |
} |
| 310 |
{ Sorry~for~the~inconvenience.~#3 } |
| 311 |
\msg_error:nnnnn { duckuments } { missing~file } |
| 312 |
{ example-image-duck.pdf } |
| 313 |
{ |
| 314 |
by~compiling~example-image-duck.tex~at~least~once |
| 315 |
} |
| 316 |
{ |
| 317 |
If~you~don't~find~the~file~on~your~machine~you~can~use~ |
| 318 |
`\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~ |
| 319 |
in~the~current~working~directory. |
| 320 |
} |
| 321 |
} |
| 322 |
}%=<< |
| 323 |
% \end{macrocode}^^A=<< |
| 324 |
% And do the same for \file{example-image-duck-portrait.pdf}. |
| 325 |
% \begin{macrocode}^^A>>= |
| 326 |
\file_if_exist:nF { example-image-duck-portrait.pdf } |
| 327 |
{%>>= |
| 328 |
\str_if_eq:VnF \c_sys_jobname_str { example-image-duck-portrait } |
| 329 |
{ |
| 330 |
\msg_if_exist:nnF { duckuments } { missing~file } |
| 331 |
{ |
| 332 |
\msg_new:nnnn { duckuments } { missing~file } |
| 333 |
{ |
| 334 |
The~file~`#1`~can't~be~found.~Make~sure~to~create~it |
| 335 |
\tl_if_empty:nF{#2}{~#2}. |
| 336 |
} |
| 337 |
{ Sorry~for~the~inconvenience.~#3 } |
| 338 |
} |
| 339 |
\msg_error:nnnnn { duckuments } { missing~file } |
| 340 |
{ example-image-duck-portrait.pdf } |
| 341 |
{ |
| 342 |
by~compiling~example-image-duck-portrait.tex~at~least~once |
| 343 |
} |
| 344 |
{ |
| 345 |
If~you~don't~find~the~file~on~your~machine~you~can~use~ |
| 346 |
`\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~ |
| 347 |
in~the~current~working~directory. |
| 348 |
} |
| 349 |
} |
| 350 |
}%=<< |
| 351 |
% \end{macrocode}^^A=<< |
| 352 |
%^^A=<< |
| 353 |
% |
| 354 |
% \subsection{Variables}^^A>>= |
| 355 |
% |
| 356 |
% \begin{variable}{\duckuments@randoms}^^A>>= |
| 357 |
% Stores the number of random ducks in \file{example-image-duck.pdf}. |
| 358 |
% \begin{macrocode} |
| 359 |
\newcommand*\duckuments@randoms{128} |
| 360 |
% \end{macrocode} |
| 361 |
% \end{variable}^^A=<< |
| 362 |
% |
| 363 |
% \begin{variable}{\l_duckuments_immediate_bool}^^A>>= |
| 364 |
% Stores whether the patch is to be done during package load time. |
| 365 |
% \begin{macrocode} |
| 366 |
\bool_new:N \l_duckuments_immediate_bool |
| 367 |
% \end{macrocode} |
| 368 |
% \end{variable}^^A=<< |
| 369 |
% |
| 370 |
% \begin{variable}{\l_duckuments_toc_bool}^^A>>= |
| 371 |
% Stores whether to display a ToC in \cs{duckument}. |
| 372 |
% \begin{macrocode} |
| 373 |
\bool_new:N \l_duckuments_toc_bool |
| 374 |
% \end{macrocode} |
| 375 |
% \end{variable}^^A=<< |
| 376 |
% |
| 377 |
% \begin{variable}{\l_duckuments_math_inline_bool}^^A>>= |
| 378 |
% Stores whether to display inline math in \cs{blindduck}. |
| 379 |
% \begin{macrocode} |
| 380 |
\bool_new:N \l_duckuments_math_inline_bool |
| 381 |
% \end{macrocode} |
| 382 |
% \end{variable}^^A=<< |
| 383 |
% |
| 384 |
% \begin{variable}{\l_duckuments_math_display_bool}^^A>>= |
| 385 |
% Stores whether to display displayed math in \cs{blindduck}. |
| 386 |
% \begin{macrocode} |
| 387 |
\bool_new:N \l_duckuments_math_display_bool |
| 388 |
% \end{macrocode} |
| 389 |
% \end{variable}^^A=<< |
| 390 |
% |
| 391 |
% \begin{variable}{\l_duckuments_blindduck_pars_bool}^^A>>= |
| 392 |
% Stores whether each paragraph of \cs{blindduck} should end with a \cs{par}. |
| 393 |
% \begin{macrocode} |
| 394 |
\bool_new:N \l_duckuments_blindduck_pars_bool |
| 395 |
% \end{macrocode} |
| 396 |
% \end{variable}^^A=<< |
| 397 |
% |
| 398 |
% \begin{variable}{\l_duckuments_range_seq}^^A>>= |
| 399 |
% Stores the paragraphs range for \cs{blindduck}. |
| 400 |
% \begin{macrocode} |
| 401 |
\seq_new:N \l_duckuments_range_seq |
| 402 |
% \end{macrocode} |
| 403 |
% \end{variable}^^A=<< |
| 404 |
% |
| 405 |
% \begin{variable}{\g_duckuments_blindduck_start_int}^^A>>= |
| 406 |
% Stores the paragraph with which \cs{blindduck} should start. |
| 407 |
% \begin{macrocode} |
| 408 |
\int_new:N \g_duckuments_blindduck_start_int |
| 409 |
\int_gset:Nn \g_duckuments_blindduck_start_int { \c_one_int } |
| 410 |
% \end{macrocode} |
| 411 |
% \end{variable}^^A=<< |
| 412 |
% |
| 413 |
% \begin{variable}{\g_duckuments_blindduck_end_int}^^A>>= |
| 414 |
% Stores the paragraph with which \cs{blindduck} should end. |
| 415 |
% \begin{macrocode} |
| 416 |
\int_new:N \g_duckuments_blindduck_end_int |
| 417 |
% \end{macrocode} |
| 418 |
% \end{variable}^^A=<< |
| 419 |
%^^A=<< |
| 420 |
% |
| 421 |
% \subsection{Constants}^^A>>= |
| 422 |
% |
| 423 |
% \begin{variable}{\c_duckuments_example_regex}^^A>>= |
| 424 |
% Regex against which the patch of \cs{includegraphics} is testing. |
| 425 |
% \begin{macrocode} |
| 426 |
\regex_const:Nn \c_duckuments_example_regex |
| 427 |
{ |
| 428 |
example-image-duck |
| 429 |
|example-image-duck.pdf |
| 430 |
|example-image-duck-portrait |
| 431 |
|example-image-duck-portrait.pdf |
| 432 |
} |
| 433 |
% \end{macrocode} |
| 434 |
% \end{variable}^^A=<< |
| 435 |
% |
| 436 |
% \begin{variable}{\c_duckuments_range_regex}^^A>>= |
| 437 |
% Regex against which the optional range in \cs{blindduck} is checked. |
| 438 |
% \begin{macrocode} |
| 439 |
\regex_const:Nn \c_duckuments_range_regex { (\d+|\d+-|-\d+|\d+-\d+|-) } |
| 440 |
% \end{macrocode} |
| 441 |
% \end{variable}^^A=<< |
| 442 |
% |
| 443 |
% \begin{variable}{\c_duckuments_blindduck_pars_int}^^A>>= |
| 444 |
% \begin{macrocode} |
| 445 |
\int_const:Nn \c_duckuments_blindduck_pars_int { 5 } |
| 446 |
% \end{macrocode} |
| 447 |
% \end{variable}^^A=<< |
| 448 |
% |
| 449 |
% \begin{variable}{\c_duckuments_example_pages_int}^^A>>= |
| 450 |
% Define a macro that gets the page count of a PDF (this is engine dependent): |
| 451 |
% \begin{macrocode} |
| 452 |
\sys_if_engine_pdftex:T |
| 453 |
{ |
| 454 |
\cs_new_protected:Npn \duckuments_set_to_pdf_page_count:Nn #1 #2 |
| 455 |
{ |
| 456 |
\group_begin: |
| 457 |
\pdfximage { #2 } |
| 458 |
\exp_args:NNNo |
| 459 |
\group_end: |
| 460 |
\int_set:Nn #1 { \the \pdflastximagepages } |
| 461 |
} |
| 462 |
} |
| 463 |
\sys_if_engine_luatex:T |
| 464 |
{ |
| 465 |
\cs_new_protected:Npn \duckuments_set_to_pdf_page_count:Nn #1 #2 |
| 466 |
{ |
| 467 |
\group_begin: |
| 468 |
\saveimageresource { #2 } |
| 469 |
\exp_args:NNNo |
| 470 |
\group_end: |
| 471 |
\int_set:Nn #1 { \lastsavedimageresourcepages } |
| 472 |
} |
| 473 |
} |
| 474 |
\sys_if_engine_xetex:T |
| 475 |
{ |
| 476 |
\cs_new_protected:Npn \duckuments_set_to_pdf_page_count:Nn #1 #2 |
| 477 |
{ |
| 478 |
\int_set:Nn #1 { \XeTeXpdfpagecount " #2 " } |
| 479 |
} |
| 480 |
} |
| 481 |
\bool_lazy_any:nTF |
| 482 |
{ |
| 483 |
{ \sys_if_engine_luatex_p: } |
| 484 |
{ \sys_if_engine_pdftex_p: } |
| 485 |
{ \sys_if_engine_xetex_p: } |
| 486 |
} |
| 487 |
{ \if_false: } |
| 488 |
{ \if_true: } |
| 489 |
\group_begin: |
| 490 |
\char_set_catcode_other:N \% |
| 491 |
\cs_new_protected:Npn \duckuments_set_to_pdf_page_count:Nn #1 #2 |
| 492 |
{ |
| 493 |
\group_begin: |
| 494 |
\char_set_catcode_other:N \% |
| 495 |
\char_set_catcode_letter:N \: |
| 496 |
\char_set_catcode_ignore:n { 32 } |
| 497 |
\ior_shell_open:Nn \g_tmpa_ior { extractbb ~ -O ~ #2 } |
| 498 |
\ior_map_inline:Nn \g_tmpa_ior |
| 499 |
{ |
| 500 |
\__duckuments_set_to_pdf_page_count_aux_a:w ##1 %%Pages: \q_stop |
| 501 |
} |
| 502 |
\ior_close:N \g_tmpa_ior |
| 503 |
\exp_args:NNNo |
| 504 |
\group_end: |
| 505 |
\int_set:Nn #1 { \int_use:N \l_tmpa_int } |
| 506 |
} |
| 507 |
\cs_new_protected:Npn \__duckuments_set_to_pdf_page_count_aux_a:w |
| 508 |
#1 %%Pages: #2 \q_stop |
| 509 |
{ |
| 510 |
\tl_if_empty:nT { #1 } |
| 511 |
{ \__duckuments_set_to_pdf_page_count_aux_b:w #2 \q_stop } |
| 512 |
} |
| 513 |
\cs_new_protected:Npn \__duckuments_set_to_pdf_page_count_aux_b:w |
| 514 |
#1 %%Pages: \q_stop |
| 515 |
{ |
| 516 |
\int_set:Nn \l_tmpa_int { #1 } |
| 517 |
\ior_map_break: |
| 518 |
} |
| 519 |
\group_end: |
| 520 |
\fi: |
| 521 |
% \end{macrocode} |
| 522 |
% Setting the constant: |
| 523 |
% \begin{macrocode} |
| 524 |
\bool_if:nTF |
| 525 |
{ |
| 526 |
\str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck } |
| 527 |
|| \str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck-portrait } |
| 528 |
} |
| 529 |
{ \int_const:Nn \c_duckuments_example_pages_int { \c_one_int } } |
| 530 |
{ |
| 531 |
\group_begin: |
| 532 |
\duckuments_set_to_pdf_page_count:Nn \l_tmpa_int |
| 533 |
{ example-image-duck.pdf } |
| 534 |
\duckuments_set_to_pdf_page_count:Nn \l_tmpb_int |
| 535 |
{ example-image-duck-portrait.pdf } |
| 536 |
\int_const:Nn \c_duckuments_example_pages_int |
| 537 |
{ \int_min:nn { \l_tmpa_int } { \l_tmpb_int } } |
| 538 |
\group_end: |
| 539 |
} |
| 540 |
% \end{macrocode} |
| 541 |
% \end{variable}^^A=<< |
| 542 |
%^^A=<< |
| 543 |
% |
| 544 |
% \subsection{Messages}^^A>>= |
| 545 |
% |
| 546 |
% \begin{macrocode}^^A duckuments option~unknown >>= |
| 547 |
\msg_new:nnnn { duckuments } { option~unknown } |
| 548 |
{ |
| 549 |
Unknown~option~'#1'~for~package~duckuments. |
| 550 |
} |
| 551 |
{ |
| 552 |
\ ~__________________________________\\ |
| 553 |
\ (Quack!~Nothing~here,~sorry.~Quack!)\\ |
| 554 |
\ ~""""""""""""""""""""""""""""""""""\\ |
| 555 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\ |
| 556 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\ |
| 557 |
\ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__ |
| 558 |
} |
| 559 |
% \end{macrocode}^^A=<< |
| 560 |
% \begin{macrocode}^^A duckuments non-boolean~toc >>= |
| 561 |
\msg_new:nnnn { duckuments } { non-boolean~toc } |
| 562 |
{ |
| 563 |
A~non-boolean~value~`#1`~was~received~for~the~`toc`~option~during~package~ |
| 564 |
load~time.~It~is~assumed~this~was~given~to~\string\documentclass\ and~ |
| 565 |
therefore~ignored. |
| 566 |
} |
| 567 |
{ |
| 568 |
\ ~__________________________________\\ |
| 569 |
\ (Quack!~Nothing~here,~sorry.~Quack!)\\ |
| 570 |
\ ~""""""""""""""""""""""""""""""""""\\ |
| 571 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\ |
| 572 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\ |
| 573 |
\ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__ |
| 574 |
} |
| 575 |
% \end{macrocode}^^A=<< |
| 576 |
% \begin{macrocode}^^A duckuments out~of~range >>= |
| 577 |
\msg_new:nnnn { duckuments } { out~of~range } |
| 578 |
{ |
| 579 |
You~requested~element~#3~out~of~the~range~#1~to~#2~of~array~'#4'.\\ |
| 580 |
I'll~just~use~element~#1~for~you. |
| 581 |
} |
| 582 |
{ |
| 583 |
\ ~__________________________________\\ |
| 584 |
\ (Quack!~Nothing~here,~sorry.~Quack!)\\ |
| 585 |
\ ~""""""""""""""""""""""""""""""""""\\ |
| 586 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\ |
| 587 |
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\ |
| 588 |
\ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__ |
| 589 |
} |
| 590 |
% \end{macrocode}^^A=<< |
| 591 |
% |
| 592 |
% \begin{macro}{\duckuments_patch_see_duckumentation:}^^A>>= |
| 593 |
% \begin{macrocode} |
| 594 |
\cs_new:Npn \duckuments_patch_see_duckumentation: |
| 595 |
{%>>= |
| 596 |
\cs_set:Nn \msg_see_documentation_text:n |
| 597 |
{ |
| 598 |
\\\\ |
| 599 |
See~the~\str_if_eq:nnTF { ##1 } { duckuments } { duckumentation } |
| 600 |
{ |
| 601 |
\str_if_eq:nnTF { ##1 } { LaTeX } { LaTeX3~ } { ##1~ } |
| 602 |
documentation |
| 603 |
}~for~further~information. |
| 604 |
} |
| 605 |
}%=<< |
| 606 |
\duckuments_patch_see_duckumentation: |
| 607 |
% \end{macrocode} |
| 608 |
% \end{macro}^^A=<< |
| 609 |
%^^A=<< |
| 610 |
% |
| 611 |
% \subsection{Options and Configurations}^^A>>= |
| 612 |
% \begin{macrocode} |
| 613 |
\keys_define:nn { duckuments } |
| 614 |
{%>>= |
| 615 |
,immediate .bool_set:N = \l_duckuments_immediate_bool |
| 616 |
,immediate .default:n = true |
| 617 |
,full .code:n = |
| 618 |
\duckuments_blindduck_range_test:n { 1-\c_duckuments_blindduck_pars_int } |
| 619 |
,all .meta:n = { full } |
| 620 |
,maths .choice: |
| 621 |
,maths / both .code:n = |
| 622 |
{ |
| 623 |
\bool_set_true:N \l_duckuments_math_inline_bool |
| 624 |
\bool_set_true:N \l_duckuments_math_display_bool |
| 625 |
} |
| 626 |
,maths / display .code:n = \bool_set_true:N \l_duckuments_math_display_bool |
| 627 |
,maths / inline .code:n = \bool_set_true:N \l_duckuments_math_inline_bool |
| 628 |
,maths / none .code:n = |
| 629 |
{ |
| 630 |
\bool_set_false:N \l_duckuments_math_inline_bool |
| 631 |
\bool_set_false:N \l_duckuments_math_display_bool |
| 632 |
} |
| 633 |
,maths .default:n = both |
| 634 |
,toc .code:n = |
| 635 |
{ |
| 636 |
\str_case:nnF { #1 } |
| 637 |
{ |
| 638 |
{ true } { \bool_set_true:N \l_duckuments_toc_bool } |
| 639 |
{ false } { \bool_set_false:N \l_duckuments_toc_bool } |
| 640 |
} |
| 641 |
{ |
| 642 |
\msg_warning:nnn { duckuments } { non-boolean~toc } { #1 } |
| 643 |
} |
| 644 |
} |
| 645 |
,toc .default:n = true |
| 646 |
,unknown .code:n = |
| 647 |
{ \msg_error:nnx { duckuments } { option~unknown } { \l_keys_key_tl } } |
| 648 |
}%=<< |
| 649 |
\ProcessKeysOptions { duckuments } |
| 650 |
\keys_define:nn { duckuments } |
| 651 |
{%>>= |
| 652 |
,toc .undefine: |
| 653 |
,toc .bool_set:N = \l_duckuments_toc_bool |
| 654 |
,toc .default:n = true |
| 655 |
,unknown .code:n = \duckuments_blindduck_range_test:V \l_keys_key_tl |
| 656 |
}%=<< |
| 657 |
\bool_if:NTF \l_duckuments_immediate_bool |
| 658 |
{ \AtEndOfPackage { \duckuments_patch_includegraphics: } } |
| 659 |
{ \AtBeginDocument { \duckuments_patch_includegraphics: } } |
| 660 |
% \end{macrocode} |
| 661 |
%^^A=<< |
| 662 |
% |
| 663 |
% \subsection{Functions}^^A>>= |
| 664 |
% |
| 665 |
% \subsubsection{Duckument Level}^^A>>= |
| 666 |
% |
| 667 |
% \begin{macro}{\duckument}^^A>>= |
| 668 |
% \begin{macrocode} |
| 669 |
\NewDocumentCommand \duckument { O{} } |
| 670 |
{%>>= |
| 671 |
\group_begin: |
| 672 |
\keys_set:nn { duckuments } { #1 } |
| 673 |
\bool_if:NT \l_duckuments_toc_bool { \tableofcontents } |
| 674 |
\cs_if_exist_use:NT \chapter |
| 675 |
{ {\duckuments@headings@text{0}} \blindduck } |
| 676 |
\duckuments@headings{1} \blindduck |
| 677 |
\duckuments@headings{2} \blindduck |
| 678 |
\duckuments@headings{3} \blindduck |
| 679 |
\duckuments@headings{4} \blindduck |
| 680 |
\section {Lists} |
| 681 |
\duckuments_list_example:n { itemize } |
| 682 |
\duckuments_list_example:n { enumerate } |
| 683 |
\duckuments_list_example:n { description } |
| 684 |
\group_end: |
| 685 |
}%=<< |
| 686 |
% \end{macrocode} |
| 687 |
% \end{macro}^^A=<< |
| 688 |
% |
| 689 |
% \begin{macro}{\blindduck}^^A>>= |
| 690 |
% \begin{macrocode} |
| 691 |
\NewDocumentCommand \blindduck { O{} } |
| 692 |
{%>>= |
| 693 |
\group_begin: |
| 694 |
\keys_set:nn { duckuments } { #1 } |
| 695 |
\duckuments@blindduck@text |
| 696 |
\bool_if:NT \l_duckuments_blindduck_pars_bool { \par } |
| 697 |
\group_end: |
| 698 |
}%=<< |
| 699 |
% \end{macrocode} |
| 700 |
% \end{macro}^^A=<< |
| 701 |
% |
| 702 |
% \begin{macro}{\ducklist}^^A>>= |
| 703 |
% \begin{macrocode} |
| 704 |
\NewDocumentCommand \ducklist {s m} |
| 705 |
{%>>= |
| 706 |
\begin{#2} |
| 707 |
\IfBooleanTF { #1 } |
| 708 |
{\ducklists@content@starred} |
| 709 |
{ |
| 710 |
\str_if_eq:nnTF { #2 } { description } |
| 711 |
\ducklists@content@starred |
| 712 |
\ducklists@content |
| 713 |
} |
| 714 |
\end{#2} |
| 715 |
}%=<< |
| 716 |
% \end{macrocode} |
| 717 |
% \end{macro}^^A=<< |
| 718 |
% \begin{macro}{\ducklistlist}^^A>>= |
| 719 |
% \begin{macrocode} |
| 720 |
\NewDocumentCommand \ducklistlist { s m } |
| 721 |
{%>>= |
| 722 |
\IfBooleanTF { #1 } |
| 723 |
{ \duckuments@listlist@starred { #2 } } |
| 724 |
{ |
| 725 |
\str_if_eq:nnTF { #2 } { description } |
| 726 |
{ \duckuments@listlist@starred { description } } |
| 727 |
{ \duckuments@listlist{#2} } |
| 728 |
} |
| 729 |
}%=<< |
| 730 |
% \end{macrocode} |
| 731 |
% \end{macro}^^A=<< |
| 732 |
% |
| 733 |
% \begin{macro}{\duckenumerate}^^A>>= |
| 734 |
% \begin{macrocode} |
| 735 |
\newcommand*\duckenumerate{\ducklist{enumerate}} |
| 736 |
% \end{macrocode} |
| 737 |
% \end{macro}^^A=<< |
| 738 |
% \begin{macro}{\duckitemize}^^A>>= |
| 739 |
% \begin{macrocode} |
| 740 |
\newcommand*\duckitemize{\ducklist{itemize}} |
| 741 |
% \end{macrocode} |
| 742 |
% \end{macro}^^A=<< |
| 743 |
% \begin{macro}{\duckdescription}^^A>>= |
| 744 |
% \begin{macrocode} |
| 745 |
\newcommand*\duckdescription{\ducklist{description}} |
| 746 |
% \end{macrocode} |
| 747 |
% \end{macro}^^A=<< |
| 748 |
% |
| 749 |
% \begin{macro}{\duckumentsCreateExampleFiles}^^A>>= |
| 750 |
% Create example-image-duck.tex |
| 751 |
% \begin{macrocode} |
| 752 |
\newcommand*\duckumentsCreateExampleFiles |
| 753 |
{%>>= |
| 754 |
\iow_new:N \duckuments_example_file_iow |
| 755 |
\iow_open:Nn \duckuments_example_file_iow { example-image-duck.tex } |
| 756 |
\iow_now:Nn \duckuments_example_file_iow |
| 757 |
{ \documentclass[tikz,multi]{standalone} } |
| 758 |
\iow_now:Nn \duckuments_example_file_iow |
| 759 |
{ \usepackage{tikzducks} } |
| 760 |
\iow_now:Nn \duckuments_example_file_iow |
| 761 |
{ \usepackage{duckuments} } |
| 762 |
\iow_now:Nn \duckuments_example_file_iow |
| 763 |
{ \begin{document} } |
| 764 |
\iow_now:Nn \duckuments_example_file_iow |
| 765 |
{ \duckumentsDrawRandomDucks } |
| 766 |
\iow_now:Nn \duckuments_example_file_iow |
| 767 |
{ \end{document} } |
| 768 |
\iow_close:N \duckuments_example_file_iow |
| 769 |
% \end{macrocode} |
| 770 |
% Create example-image-duck-portrait.tex |
| 771 |
% \begin{macrocode} |
| 772 |
\iow_open:Nn \duckuments_example_file_iow |
| 773 |
{ example-image-duck-portrait.tex } |
| 774 |
\iow_now:Nn \duckuments_example_file_iow |
| 775 |
{ \documentclass[tikz,multi]{standalone} } |
| 776 |
\iow_now:Nn \duckuments_example_file_iow |
| 777 |
{ \usepackage{tikzducks} } |
| 778 |
\iow_now:Nn \duckuments_example_file_iow |
| 779 |
{ \usepackage{duckuments} } |
| 780 |
\iow_now:Nn \duckuments_example_file_iow |
| 781 |
{ \begin{document} } |
| 782 |
\iow_now:Nn \duckuments_example_file_iow |
| 783 |
{ \duckumentsDrawRandomDucks* } |
| 784 |
\iow_now:Nn \duckuments_example_file_iow |
| 785 |
{ \end{document} } |
| 786 |
\iow_close:N \duckuments_example_file_iow |
| 787 |
}%=<< |
| 788 |
% \end{macrocode} |
| 789 |
% \end{macro}^^A=<< |
| 790 |
% \begin{macro}{\duckumentsDrawRandomDucks}^^A>>= |
| 791 |
% \begin{macrocode} |
| 792 |
\newcommand*\duckumentsDrawRandomDucks |
| 793 |
{%>>= |
| 794 |
\@ifstar |
| 795 |
{\duckumentsDrawRandomDucks@portrait} |
| 796 |
{\duckumentsDrawRandomDucks@landscape}% |
| 797 |
}%=<< |
| 798 |
% \end{macrocode} |
| 799 |
% \end{macro}^^A=<< |
| 800 |
%^^A=<< |
| 801 |
% |
| 802 |
% \subsubsection{Intern}^^A>>= |
| 803 |
% |
| 804 |
% \begin{macro}{\duckuments@headings}^^A>>= |
| 805 |
% \begin{macrocode} |
| 806 |
\newcommand*\duckuments@headings[1] |
| 807 |
{%>>= |
| 808 |
\ifcase#1\relax |
| 809 |
\expandafter\chapter |
| 810 |
\or \expandafter\section |
| 811 |
\or \expandafter\subsection |
| 812 |
\or \expandafter\subsubsection |
| 813 |
\or \expandafter\paragraph |
| 814 |
\else \expandafter\@gobble |
| 815 |
\fi |
| 816 |
{\duckuments@headings@text{#1}} |
| 817 |
}%=<< |
| 818 |
% \end{macrocode} |
| 819 |
% \end{macro}^^A=<< |
| 820 |
% |
| 821 |
% \begin{macro}{\duckuments@headings@level}^^A>>= |
| 822 |
% \begin{macrocode} |
| 823 |
\newcommand*\duckuments@headings@level[1] |
| 824 |
{%>>= |
| 825 |
( |
| 826 |
\ifcase#1 |
| 827 |
chapter |
| 828 |
\or section |
| 829 |
\or subsection |
| 830 |
\or subsubsection |
| 831 |
\or paragraph |
| 832 |
\fi |
| 833 |
) |
| 834 |
}%=<< |
| 835 |
% \end{macrocode} |
| 836 |
% \end{macro}^^A=<< |
| 837 |
% |
| 838 |
% \begin{macro}{\duckuments@ifinline}^^A>>= |
| 839 |
% \begin{macrocode} |
| 840 |
\newcommand*\duckuments@ifinline[2][] |
| 841 |
{ \bool_if:NTF \l_duckuments_math_inline_bool { #2 } { #1 } } |
| 842 |
% \end{macrocode} |
| 843 |
% \end{macro}^^A=<< |
| 844 |
% |
| 845 |
% \begin{macro}{\duckuments@ifdisplay}^^A>>= |
| 846 |
% \begin{macrocode} |
| 847 |
\newcommand*\duckuments@ifdisplay[2][] |
| 848 |
{ \bool_if:NTF \l_duckuments_math_display_bool { #2 } { #1 } } |
| 849 |
% \end{macrocode} |
| 850 |
% \end{macro}^^A=<< |
| 851 |
% |
| 852 |
% \begin{macro}{\duckuments_list_example:n}^^A>>= |
| 853 |
% \begin{macrocode} |
| 854 |
\cs_new_protected_nopar:Npn \duckuments_list_example:n #1 |
| 855 |
{%>>= |
| 856 |
\subsection{Example\ for\ ducks\ (#1)} |
| 857 |
\ducklist { #1 } |
| 858 |
\subsubsection{Nested\ ducks} |
| 859 |
\ducklistlist { #1 } |
| 860 |
}%=<< |
| 861 |
% \end{macrocode} |
| 862 |
% \end{macro}^^A=<< |
| 863 |
% |
| 864 |
% \begin{macro}{\duckuments@enquote}^^A>>= |
| 865 |
% \begin{macrocode} |
| 866 |
\NewDocumentCommand \duckuments@enquote { s +m } |
| 867 |
{%>>= |
| 868 |
\IfBooleanTF { #1 } |
| 869 |
{ |
| 870 |
\cs_if_exist_use:NTF |
| 871 |
\enquote { * { #2 } } |
| 872 |
{ `#2' } |
| 873 |
} |
| 874 |
{ |
| 875 |
\cs_if_exist_use:NTF |
| 876 |
\enquote { { #2 } } |
| 877 |
{``#2''} |
| 878 |
} |
| 879 |
}%=<< |
| 880 |
% \end{macrocode} |
| 881 |
% \end{macro}^^A=<< |
| 882 |
% |
| 883 |
% \begin{macro}{\duckumentsDrawRandomDucks@landscape}^^A>>= |
| 884 |
% \begin{macrocode} |
| 885 |
\newcommand*\duckumentsDrawRandomDucks@landscape[1][\duckuments@randoms] |
| 886 |
{%>>= |
| 887 |
\foreach\x in {1,2,...,#1} |
| 888 |
{\duckumentsDrawRandomDucks@draw{6.47214}{4}{3.23607}{2}} |
| 889 |
}%=<< |
| 890 |
% \end{macrocode} |
| 891 |
% \end{macro}^^A=<< |
| 892 |
% |
| 893 |
% \begin{macro}{\duckumentsDrawRandomDucks@portrait}^^A>>= |
| 894 |
% \begin{macrocode} |
| 895 |
\newcommand*\duckumentsDrawRandomDucks@portrait[1][\duckuments@randoms] |
| 896 |
{%>>= |
| 897 |
\foreach\x in {1,2,...,#1} |
| 898 |
{\duckumentsDrawRandomDucks@draw{1.8541}{3}{.92705}{1.5}} |
| 899 |
}%=<< |
| 900 |
% \end{macrocode} |
| 901 |
% \end{macro}^^A=<< |
| 902 |
% |
| 903 |
% \begin{macro}{\duckumentsDrawRandomDucks@draw}^^A>>= |
| 904 |
% \begin{macrocode} |
| 905 |
\newcommand*\duckumentsDrawRandomDucks@draw[4] |
| 906 |
{%>>= |
| 907 |
\begin{tikzpicture} |
| 908 |
\draw[fill=gray!50,use~as~bounding~box] (0,0) rectangle (#1,#2); |
| 909 |
\draw[gray,thin] (0,0) -- (#1,#2); |
| 910 |
\draw[gray,thin] (0,#2) -- (#1,0); |
| 911 |
\draw[gray,thin] (#3,0) -- (#3,#2); |
| 912 |
\draw[gray,thin] (0,#4) -- (#1,#4); |
| 913 |
\node at (#3,#4) {\tikz\randuck;}; |
| 914 |
\draw[black] (0,0) rectangle (#1,#2); |
| 915 |
\end{tikzpicture} |
| 916 |
}%=<< |
| 917 |
% \end{macrocode} |
| 918 |
% \end{macro}^^A=<< |
| 919 |
% |
| 920 |
% \begin{macro}{\duckuments_patch_includegraphics:}^^A>>= |
| 921 |
% \begin{macrocode} |
| 922 |
\cs_new_protected_nopar:Npn \duckuments_patch_includegraphics: |
| 923 |
{%>>= |
| 924 |
\@ifpackageloaded { graphicx } |
| 925 |
{ |
| 926 |
\LetLtxMacro\duckuments@includegraphicsBAK\includegraphics |
| 927 |
\RenewDocumentCommand \includegraphics |
| 928 |
{ >{\duckuments_starred:n}s O{} o m } |
| 929 |
{ |
| 930 |
\IfValueTF { ##3 } |
| 931 |
{ \duckuments@includegraphicsBAK##1[{##2}][{##3}]{##4} } |
| 932 |
{ |
| 933 |
\regex_match:NnTF \c_duckuments_example_regex { ##4 } |
| 934 |
{ |
| 935 |
\duckuments@includegraphicsBAK##1 |
| 936 |
[{page=\duckuments_random_page:,##2}] |
| 937 |
{ ##4 } |
| 938 |
} |
| 939 |
{ |
| 940 |
\duckuments@includegraphicsBAK##1[{##2}]{##4} |
| 941 |
} |
| 942 |
} |
| 943 |
} |
| 944 |
} |
| 945 |
{} |
| 946 |
}%=<< |
| 947 |
% \end{macrocode} |
| 948 |
% \end{macro}^^A=<< |
| 949 |
% |
| 950 |
% \begin{macro}{\duckuments_blindduck_range_test:n}^^A>>= |
| 951 |
% \begin{macrocode} |
| 952 |
\cs_new_protected:Npn \duckuments_blindduck_range_test:n #1 |
| 953 |
{%>>= |
| 954 |
\regex_match:NnTF \c_duckuments_range_regex { #1 } |
| 955 |
{ |
| 956 |
\seq_set_split:Nnn \l_duckuments_range_seq { - } { #1 } |
| 957 |
\int_compare:nNnTF |
| 958 |
{ \c_one_int } = { \seq_count:N \l_duckuments_range_seq } |
| 959 |
{ |
| 960 |
\cs_set:Npn \duckuments@blindduck@text |
| 961 |
{ |
| 962 |
\duckuments_blindduck_single_par:n { #1 } |
| 963 |
\duckuments_blindduck_set_next_start:n { #1 } |
| 964 |
} |
| 965 |
} |
| 966 |
{ |
| 967 |
\bool_set_true:N \l_duckuments_blindduck_pars_bool |
| 968 |
\exp_args:Nx |
| 969 |
\tl_if_empty:nF |
| 970 |
{ \seq_item:Nn \l_duckuments_range_seq { \c_one_int } } |
| 971 |
{ |
| 972 |
\int_gset:Nn \g_duckuments_blindduck_start_int |
| 973 |
{ \seq_item:Nn \l_duckuments_range_seq { \c_one_int } } |
| 974 |
} |
| 975 |
\exp_args:Nx |
| 976 |
\tl_if_empty:nTF { \seq_item:Nn \l_duckuments_range_seq { 2 } } |
| 977 |
{ |
| 978 |
\int_gset_eq:NN |
| 979 |
\g_duckuments_blindduck_end_int |
| 980 |
\g_duckuments_blindduck_start_int |
| 981 |
} |
| 982 |
{ |
| 983 |
\int_set:Nn \g_duckuments_blindduck_end_int |
| 984 |
{ \seq_item:Nn \l_duckuments_range_seq { 2 } } |
| 985 |
} |
| 986 |
\duckuments_blindduck_set_text:xx |
| 987 |
{ \int_use:N \g_duckuments_blindduck_start_int } |
| 988 |
{ \int_use:N \g_duckuments_blindduck_end_int } |
| 989 |
} |
| 990 |
} |
| 991 |
{ |
| 992 |
\exp_args:NnnV |
| 993 |
\msg_error:nnn { duckuments } { option~unknown } \l_keys_key_tl |
| 994 |
} |
| 995 |
}%=<< |
| 996 |
\cs_generate_variant:Nn \duckuments_blindduck_range_test:n { V } |
| 997 |
% \end{macrocode} |
| 998 |
% \end{macro}^^A=<< |
| 999 |
% |
| 1000 |
% \begin{macro}{\duckuments_blindduck_set_text:nn}^^A>>= |
| 1001 |
% \begin{macrocode} |
| 1002 |
\cs_new:Npn \duckuments_blindduck_set_text:nn #1 #2 |
| 1003 |
{%>>= |
| 1004 |
\def \duckuments@blindduck@text |
| 1005 |
{ |
| 1006 |
\int_step_function:nnnN { #1 } { \c_one_int } { #2 } |
| 1007 |
\duckuments_blindduck_par_loop:n |
| 1008 |
\duckuments_blindduck_set_next_start:n { #2 } |
| 1009 |
} |
| 1010 |
}%=<< |
| 1011 |
\cs_generate_variant:Nn \duckuments_blindduck_set_text:nn { xx } |
| 1012 |
% \end{macrocode} |
| 1013 |
% \end{macro}^^A=<< |
| 1014 |
% |
| 1015 |
% \begin{macro}{\duckuments_blindduck_set_next_start:n}^^A>>= |
| 1016 |
% \begin{macrocode} |
| 1017 |
\cs_new:Npn \duckuments_blindduck_set_next_start:n #1 |
| 1018 |
{%>>= |
| 1019 |
\int_gset:Nn \g_duckuments_blindduck_start_int |
| 1020 |
{ \int_mod:nn { #1 } { \c_duckuments_blindduck_pars_int } + \c_one_int } |
| 1021 |
}%=<< |
| 1022 |
% \end{macrocode} |
| 1023 |
% \end{macro}^^A=<< |
| 1024 |
% |
| 1025 |
% \begin{macro}{\duckuments_blindduck_single_par:n}^^A>>= |
| 1026 |
% \begin{macrocode} |
| 1027 |
\cs_new:Npn \duckuments_blindduck_single_par:n #1 |
| 1028 |
{%>>= |
| 1029 |
\bool_if:nTF |
| 1030 |
{ |
| 1031 |
\int_compare_p:nNn { #1 } > { \c_duckuments_blindduck_pars_int } |
| 1032 |
|| \int_compare_p:nNn { #1 } < { \c_one_int } |
| 1033 |
} |
| 1034 |
{ |
| 1035 |
\msg_error:nnxxxx { duckuments } { out~of~range } |
| 1036 |
{ 1 } { \int_use:N \c_duckuments_blindduck_pars_int } { #1 } |
| 1037 |
{ blindduck~paragraphs } |
| 1038 |
\duckuments@blindduck@text@i |
| 1039 |
} |
| 1040 |
{ |
| 1041 |
\use:c { duckuments@blindduck@text@ \int_to_roman:n { #1 } } |
| 1042 |
} |
| 1043 |
}%=<< |
| 1044 |
% \end{macrocode} |
| 1045 |
% \end{macro}^^A=<< |
| 1046 |
% |
| 1047 |
% \begin{macro}{\duckuments_blindduck_par_loop:n}^^A>>= |
| 1048 |
% \begin{macrocode} |
| 1049 |
\cs_new:Npn \duckuments_blindduck_par_loop:n #1 |
| 1050 |
{%>>= |
| 1051 |
\duckuments_blindduck_single_par:n { #1 } |
| 1052 |
\par |
| 1053 |
}%=<< |
| 1054 |
% \end{macrocode} |
| 1055 |
% \end{macro}^^A=<< |
| 1056 |
% |
| 1057 |
% \begin{macro}{\duckuments_starred:n}^^A>>= |
| 1058 |
% \begin{macrocode} |
| 1059 |
\cs_new_protected:Npn \duckuments_starred:n #1 |
| 1060 |
{%>>= |
| 1061 |
\IfBooleanTF { #1 } |
| 1062 |
{ \def\ProcessedArgument{*} } |
| 1063 |
{ \def\ProcessedArgument{} } |
| 1064 |
}%=<< |
| 1065 |
% \end{macrocode} |
| 1066 |
% \end{macro}^^A=<< |
| 1067 |
% |
| 1068 |
% \begin{macro}{\duckuments_random_page:}^^A>>= |
| 1069 |
% \begin{macrocode} |
| 1070 |
\cs_new:Npn \duckuments_random_page: |
| 1071 |
{ \int_rand:n { \c_duckuments_example_pages_int } } |
| 1072 |
% \end{macrocode} |
| 1073 |
% \end{macro}^^A=<< |
| 1074 |
% |
| 1075 |
% \begin{macrocode} |
| 1076 |
\ExplSyntaxOff |
| 1077 |
% \end{macrocode} |
| 1078 |
% |
| 1079 |
% \begin{macro}{\duckuments@blindduck@text}^^A>>= |
| 1080 |
% \begin{macrocode} |
| 1081 |
\newcommand*\duckuments@blindduck@text{\duckuments@blindduck@text@i} |
| 1082 |
\newcommand*\duckuments@blindduck@text@i |
| 1083 |
{%>>= |
| 1084 |
There once was a very smart but sadly blind duck. When it was still a small |
| 1085 |
duckling it was renowned for its good vision. But sadly as the duck grew |
| 1086 |
older it caught a sickness which caused its eyesight to worsen. It became so |
| 1087 |
bad, that the duck couldn't read the notes it once took containing much of |
| 1088 |
inline math\duckuments@ifinline{ just like its favoured equation: $d = u_c |
| 1089 |
\cdot k$}. Only displayed equations remained legible% |
| 1090 |
\duckuments@ifdisplay[.]{ so it could still read \begin{equation}d = r a^k |
| 1091 |
e\hbox{.}\end{equation}} That annoyed the smart duck, as it wasn't able to |
| 1092 |
do its research any longer. It called for its underduckling and said: |
| 1093 |
\duckuments@enquote{Go, find me the best eye ducktor there is. He shall |
| 1094 |
heal me from my disease!}% |
| 1095 |
}%=<< |
| 1096 |
\newcommand*\duckuments@blindduck@text@ii |
| 1097 |
{%>>= |
| 1098 |
\duckuments@enquote{But my duck, how are you supposed to manage your daily |
| 1099 |
routines without my visual guidance}, replied the underduckling. The smart |
| 1100 |
duck's face turned grim in anger. \duckuments@enquote{You dare to talk |
| 1101 |
back?} The underduckling blushed ashamed. How could he have objections |
| 1102 |
after his duck gave strict orders? The underduckling was so embarrassed |
| 1103 |
about his own behaviour he had to solve an equation.% |
| 1104 |
}%=<< |
| 1105 |
\newcommand*\duckuments@blindduck@text@iii |
| 1106 |
{%>>= |
| 1107 |
After the equation was solved and the underduckling prepared his leave for |
| 1108 |
the next day it fell asleep in a shaky mood. It did not know what the |
| 1109 |
journey had prepared for him and if he was prepared enough for it. His sleep |
| 1110 |
was restless. The dreams he had that night were not calm and bright as they |
| 1111 |
used to be for an innocent underduckling.% |
| 1112 |
}%=<< |
| 1113 |
\newcommand*\duckuments@blindduck@text@iv |
| 1114 |
{%>>= |
| 1115 |
Before dawn the underduckling woke. He didn't have the feeling of being well |
| 1116 |
rested. But nonetheless he knew that this was the day he should leave. |
| 1117 |
Except saying goodbye to his beloved ones there was nothing holding him |
| 1118 |
back. His duck had sent him on the most important mission a five weeks old |
| 1119 |
inexperienced underduckling was ever sent on. He bid farewell to his mother, |
| 1120 |
all his brothers and sisters, and finally from his duck. The bag was |
| 1121 |
shouldered, the boots were tied, the underduckling left.% |
| 1122 |
}%=<< |
| 1123 |
\newcommand*\duckuments@blindduck@text@v |
| 1124 |
{%>>= |
| 1125 |
As the underduckling went along he saw a tree. It was so tall he couldn't |
| 1126 |
even approximate its height. Oh, how small he felt. What should he, a small |
| 1127 |
duckling whose plumage was still fluffy, achieve in this vast, gigantic |
| 1128 |
world? He stuck his trembling wings under the straps of his backpack to calm |
| 1129 |
his shaking limbs. Where should he start his search? How should he survive |
| 1130 |
in the hostile nature surrounding the sheltered pond of his community? |
| 1131 |
}%=<< |
| 1132 |
% \end{macrocode} |
| 1133 |
% \end{macro}^^A=<< |
| 1134 |
% |
| 1135 |
% \begin{macro}{\duckuments@headings@text}^^A>>= |
| 1136 |
% \begin{macrocode} |
| 1137 |
\newcommand*\duckuments@headings@text[1] |
| 1138 |
{A friendly duck at level #1 \duckuments@headings@level{#1}} |
| 1139 |
% \end{macrocode} |
| 1140 |
% \end{macro}^^A=<< |
| 1141 |
% |
| 1142 |
% \begin{macro}{\ducklists@content}^^A>>= |
| 1143 |
% \begin{macrocode} |
| 1144 |
\newcommand*\ducklists@content |
| 1145 |
{%>>= |
| 1146 |
\item First swims father drake |
| 1147 |
\item Then floats mother duck |
| 1148 |
\item After her paddles baby duckling |
| 1149 |
\item And over there bathes uncle canard |
| 1150 |
}%=<< |
| 1151 |
% \end{macrocode} |
| 1152 |
% \end{macro}^^A=<< |
| 1153 |
% |
| 1154 |
% \begin{macro}{\ducklists@content@starred}^^A>>= |
| 1155 |
% \begin{macrocode} |
| 1156 |
\newcommand*\ducklists@content@starred |
| 1157 |
{%>>= |
| 1158 |
\item[drake] is the swimming father |
| 1159 |
\item[duck] is the floating mother |
| 1160 |
\item[duckling] is the paddling baby |
| 1161 |
\item[canard] is the bathing uncle |
| 1162 |
}%=<< |
| 1163 |
% \end{macrocode} |
| 1164 |
% \end{macro}^^A=<< |
| 1165 |
% |
| 1166 |
% \begin{macro}{\duckuments@listlist}^^A>>= |
| 1167 |
% \begin{macrocode} |
| 1168 |
\newcommand*\duckuments@listlist[1] |
| 1169 |
{%>>= |
| 1170 |
\begin{#1} |
| 1171 |
\item swimming father drake |
| 1172 |
\begin{#1} |
| 1173 |
\item swimming father drake |
| 1174 |
\begin{#1} |
| 1175 |
\item swimming father drake |
| 1176 |
\begin{#1} |
| 1177 |
\item swimming father drake |
| 1178 |
\item floating mother duck |
| 1179 |
\end{#1} |
| 1180 |
\item floating mother duck |
| 1181 |
\end{#1} |
| 1182 |
\item floating mother duck |
| 1183 |
\end{#1} |
| 1184 |
\item floating mother duck |
| 1185 |
\end{#1}% |
| 1186 |
}%=<< |
| 1187 |
% \end{macrocode} |
| 1188 |
% \end{macro}^^A=<< |
| 1189 |
% |
| 1190 |
% \begin{macro}{\duckuments@listlist@starred}^^A>>= |
| 1191 |
% \begin{macrocode} |
| 1192 |
\newcommand*\duckuments@listlist@starred[1] |
| 1193 |
{%>>= |
| 1194 |
\begin{#1} |
| 1195 |
\item[drake] is the swimming father |
| 1196 |
\begin{#1} |
| 1197 |
\item[drake] is the swimming father |
| 1198 |
\begin{#1} |
| 1199 |
\item[drake] is the swimming father |
| 1200 |
\begin{#1} |
| 1201 |
\item[drake] is the swimming father |
| 1202 |
\item[duck] is the floating mother |
| 1203 |
\end{#1} |
| 1204 |
\item[duck] is the floating mother |
| 1205 |
\end{#1} |
| 1206 |
\item[duck] is the floating mother |
| 1207 |
\end{#1} |
| 1208 |
\item[duck] is the floating mother |
| 1209 |
\end{#1}% |
| 1210 |
}%=<< |
| 1211 |
% \end{macrocode} |
| 1212 |
% \end{macro}^^A=<< |
| 1213 |
%^^A=<< |
| 1214 |
%^^A=<< |
| 1215 |
% |
| 1216 |
% \begin{macrocode} |
| 1217 |
\endinput |
| 1218 |
% \end{macrocode} |
| 1219 |
% |
| 1220 |
% \end{implementation}^^A=<< |
| 1221 |
% |
| 1222 |
% \begin{macrocode} |
| 1223 |
%</pkg> |
| 1224 |
% \end{macrocode} |
| 1225 |
% |
| 1226 |
% \clearpage |
| 1227 |
% \section{The story of the duck}^^A>>= |
| 1228 |
% |
| 1229 |
% \bgroup |
| 1230 |
% \ExplSyntaxOn |
| 1231 |
% \newcount\duckuments_count_for_duckumentation_only |
| 1232 |
% \cs_set:Nn \duckuments_blindduck_par_loop:n |
| 1233 |
% {^^A>>= |
| 1234 |
% \advance\duckuments_count_for_duckumentation_only1 |
| 1235 |
% \llap |
| 1236 |
% { |
| 1237 |
% \group_begin: |
| 1238 |
% \color_select:nn { gray } { 0.5 } |
| 1239 |
% \rlap |
| 1240 |
% { |
| 1241 |
% \smash |
| 1242 |
% { |
| 1243 |
% \parbox[t]{2cm} |
| 1244 |
% { |
| 1245 |
% \scriptsize\raggedright |
| 1246 |
% paragraph~\the\duckuments_count_for_duckumentation_only |
| 1247 |
% } |
| 1248 |
% } |
| 1249 |
% } |
| 1250 |
% \hspace{\dimexpr\marginparsep+2cm\relax} |
| 1251 |
% \group_end: |
| 1252 |
% } |
| 1253 |
% \vspace{-\baselineskip} |
| 1254 |
% \duckuments_blindduck_single_par:n { #1 } |
| 1255 |
% \par |
| 1256 |
% }^^A=<< |
| 1257 |
% \ExplSyntaxOff |
| 1258 |
% \blindduck[full] |
| 1259 |
% \egroup^^A=<< |
| 1260 |
% |
| 1261 |
% |
| 1262 |
^^A vim: fdm=marker foldmarker=>>=,=<< |