@@ -49,6 +49,7 @@ and the derived files duckuments.pdf,
49
49
\endpostamble
50
50
\generate {\file {duckuments.sty}{\from {duckuments.dtx}{pkg}}}
51
51
\generate {\file {example-image-duck.tex}{\from {duckuments.dtx}{eid}}}
52
+ \generate {\file {example-image-duck-portrait.tex}{\from {duckuments.dtx}{eidp}}}
52
53
\ifx \fmtname\nameofplainTeX
53
54
\expandafter\endbatchfile
54
55
\else
@@ -84,6 +85,17 @@ and the derived files duckuments.pdf,
84
85
\end {document }
85
86
% </eid>
86
87
%
88
+ % <*eidp>
89
+ \documentclass [tikz,multi ]{standalone }
90
+
91
+ \usepackage {tikzducks }
92
+ \usepackage {duckuments }
93
+
94
+ \begin {document }
95
+ \duckumentsDrawRandomDucks *
96
+ \end {document }
97
+ % </eidp>
98
+ %
87
99
% <*pkg>
88
100
\def\duckuments@version {v0.3}
89
101
\def\duckuments@date {2018/03/19}
@@ -113,12 +125,14 @@ and the derived files duckuments.pdf,
113
125
% simple alternative to the \pkg{blindtext} package.
114
126
%
115
127
% It is written as a docstrip file: executing |latex duckuments.dtx| generates
116
- % the \file{duckuments.sty} and \file{example-image-duck.tex} file and typesets
117
- % this duckumentation; execute |tex duckuments.dtx| to only generate the files
118
- % \file{duckuments.sty} and \file{example-image-duck.tex}.
119
- %
120
- % For its functionality \file{example-image-duck.tex} must be compiled at least
121
- % once. The sources are hosted on
128
+ % the \file{duckuments.sty}, \file{example-image-duck.tex}, and
129
+ % \file{example-image-duck-portrait.tex} file and typesets this duckumentation;
130
+ % execute |tex duckuments.dtx| to only generate the files \file{duckuments.sty},
131
+ % \file{example-image-duck.tex}, and \file{example-image-duck-portrait.tex}.
132
+ %
133
+ % For its functionality \file{example-image-duck.tex} and
134
+ % \file{example-image-duck-portrait.tex} must be compiled at least once. The
135
+ % sources are hosted on
122
136
% \href{https://github.com/Skillmon/ltx_duckuments}{github}.
123
137
%
124
138
% \textbf{The package does currently only work on \pdfTeX, \LuaTeX, and \XeTeX}.
@@ -180,19 +194,21 @@ and the derived files duckuments.pdf,
180
194
%
181
195
% \subsection{Other Macros}^^A>>>
182
196
%
183
- % \begin{function}{\duckumentsCreateExampleFile }^^A>>>
184
- % Creates the file \file{example-image-duck.tex} in the current working
185
- % directory.
197
+ % \begin{function}{\duckumentsCreateExampleFiles }^^A>>>
198
+ % Creates the files \file{example-image-duck.tex} and
199
+ % \file{example-image-duck-portrait.tex} in the current working directory.
186
200
% \end{function}^^A<<<
187
201
%
188
202
% \begin{function}{\duckumentsDrawRandomDucks}^^A>>>
189
203
% \begin{syntax}
190
- % \cs{duckumentsDrawRandomDucks}\oarg{count}
204
+ % \cs{duckumentsDrawRandomDucks}\meta{*}\ oarg{count}
191
205
% \end{syntax}
192
206
% Draws \meta{count} random \pkg{tikzducks} using
193
207
% \pkg{Ti\textit{k}Z}. \meta{count} defaults to \cs{duckuments@randoms}.
194
208
% Note that \pkg{duckuments} doesn't load \pkg{Ti\textit{k}Z}, this macro is
195
- % for the use in \file{example-image-duck.tex}.
209
+ % for the use in \file{example-image-duck.tex} and
210
+ % \file{example-image-duck-portrait.tex}. If the optional star is given, the
211
+ % images will be drawn in portrait orientation else in landscape.
196
212
% \end{function}^^A<<<
197
213
% ^^A<<<
198
214
%
@@ -219,7 +235,7 @@ and the derived files duckuments.pdf,
219
235
% The package and commands which take a \oarg{key=value} accept the following
220
236
% options. Some of which only make sense as package options. The
221
237
% \textbf{\texttt{bold}} printed value is the one used if you don't specify a
222
- % value. The \textit{\texttt{italic}} printed value is the default .
238
+ % value. The \textit{\texttt{italic}} printed value is the initial one .
223
239
% \begin{options}
224
240
% \item[toc=\textbf{true}$\vert$\textit{false}]
225
241
% If |true| the \cs{duckument} contains a ToC.
@@ -230,6 +246,8 @@ and the derived files duckuments.pdf,
230
246
% \item[full]
231
247
% This typesets the full range of \cs{blindduck}. Don't use this as a
232
248
% package option.
249
+ % \item[all]
250
+ % synonym for |full|.
233
251
% \item[immediate=\textbf{true}$\vert$\textit{false}]
234
252
% If |true| \cs{includegraphics} is patched during package load time, else
235
253
% the patching is done \cs{AtBeginDocument}.
@@ -285,7 +303,12 @@ and the derived files duckuments.pdf,
285
303
LuaTeX,~and~XeTeX!
286
304
}
287
305
{
288
- Sorry~for~that.
306
+ \ ~_____________________________\\
307
+ \ (Quack!~Sorry~for~that.~Quack!)\\
308
+ \ ~"""""""""""""""""""""""""""""\\
309
+ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\string \ \\
310
+ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~>()_\\
311
+ \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~\ ~(__)__
289
312
}
290
313
\msg _error:nn { duckuments } { incompatible }
291
314
\endinput
@@ -296,25 +319,53 @@ and the derived files duckuments.pdf,
296
319
\file _if_exist:nF { example-image-duck.pdf }
297
320
{% >>>
298
321
% \end{macrocode}
299
- % If the current \cs{jobname} doesn't match \file{example-image-duck} throw a
300
- % warning .
322
+ % If the current \cs{jobname} doesn't match \file{example-image-duck} throw an
323
+ % error .
301
324
% \begin{macrocode}
302
325
\str _if_eq:VnF \c _sys_jobname_str { example-image-duck }
303
326
{
304
- \msg _new:nnnn { duckuments } { missing- file }
305
- {
306
- The~file~`#1`~can't~be~found.~Make~sure~to~create~it
307
- \tl _if_empty:nF{#2}{~#2}.
308
- }
309
- { Sorry~for~the~inconvenience.~#3 }
310
- \msg _error:nnnnn { duckuments } { missing- file }
327
+ \msg _new:nnnn { duckuments } { missing~ file }
328
+ {
329
+ The~file~`#1`~can't~be~found.~Make~sure~to~create~it
330
+ \tl _if_empty:nF{#2}{~#2}.
331
+ }
332
+ { Sorry~for~the~inconvenience.~#3 }
333
+ \msg _error:nnnnn { duckuments } { missing~ file }
311
334
{ example-image-duck.pdf }
312
335
{
313
336
by~compiling~example-image-duck.tex~at~least~once
314
337
}
315
338
{
316
339
If~you~don't~find~the~file~on~your~machine~you~can~use~
317
- `\duckumentsCreateExampleFile `~in~your~document~to~produce~a~copy~
340
+ `\duckumentsCreateExampleFiles `~in~your~document~to~produce~a~copy~
341
+ in~the~current~working~directory.
342
+ }
343
+ }
344
+ }% <<<
345
+ % \end{macrocode}^^A<<<
346
+ % And do the same for \file{example-image-duck-portrait.pdf}.
347
+ % \begin{macrocode}^^A>>>
348
+ \file _if_exist:nF { example-image-duck-portrait.pdf }
349
+ {% >>>
350
+ \str _if_eq:VnF \c _sys_jobname_str { example-image-duck-portrait }
351
+ {
352
+ \msg _if_exist:nnF { duckuments } { missing~file }
353
+ {
354
+ \msg _new:nnnn { duckuments } { missing~file }
355
+ {
356
+ The~file~`#1`~can't~be~found.~Make~sure~to~create~it
357
+ \tl _if_empty:nF{#2}{~#2}.
358
+ }
359
+ { Sorry~for~the~inconvenience.~#3 }
360
+ }
361
+ \msg _error:nnnnn { duckuments } { missing~file }
362
+ { example-image-duck-portrait.pdf }
363
+ {
364
+ by~compiling~example-image-duck-portrait.tex~at~least~once
365
+ }
366
+ {
367
+ If~you~don't~find~the~file~on~your~machine~you~can~use~
368
+ `\duckumentsCreateExampleFiles `~in~your~document~to~produce~a~copy~
318
369
in~the~current~working~directory.
319
370
}
320
371
}
@@ -395,7 +446,12 @@ and the derived files duckuments.pdf,
395
446
% Regex against which the patch of \cs{includegraphics} is testing.
396
447
% \begin{macrocode}
397
448
\regex _const:Nn \c _duckuments_example_regex
398
- { example-image-duck|example-image-duck.pdf }
449
+ {
450
+ example-image-duck
451
+ |example-image-duck.pdf
452
+ |example-image-duck-portrait
453
+ |example-image-duck-portrait.pdf
454
+ }
399
455
% \end{macrocode}
400
456
% \end{variable}^^A<<<
401
457
%
@@ -414,33 +470,39 @@ and the derived files duckuments.pdf,
414
470
%
415
471
% \begin{variable}{\c_duckuments_example_pages_int}^^A>>>
416
472
% \begin{macrocode}
417
- \str _if_eq:VnF \c _sys_jobname_str { example-image-duck }
473
+ \bool _if:nTF
418
474
{
419
- \file _if_exist:nTF { example-image-duck.pdf }
420
- {
421
- \sys _if_engine_pdftex:T
422
- {
423
- \pdfximage {example-image-duck.pdf}
424
- \int _const:Nn \c _duckuments_example_pages_int
425
- { \the\pdflastximagepages }
426
- }
427
- \sys _if_engine_luatex:T
428
- {
429
- \saveimageresource {example-image-duck.pdf}
430
- \int _const:Nn \c _duckuments_example_pages_int
431
- { \lastsavedimageresourcepages }
432
- }
433
- \sys _if_engine_xetex:T
434
- {
435
- \group _begin:
436
- \int _gset:Nn \l _tmpa_int
437
- { \XeTeXpdfpagecount "example-image-duck.pdf" }
438
- \int _const:Nn \c _duckuments_example_pages_int { \l _tmpa_int }
439
- \group _end:
440
- }
441
- }
475
+ \str _if_eq_p:Vn \c _sys_jobname_str { example-image-duck }
476
+ || \str _if_eq_p:Vn \c _sys_jobname_str { example-image-duck-portrait }
442
477
}
443
478
{ \int _const:Nn \c _duckuments_example_pages_int { 1 } }
479
+ {
480
+ \group _begin:
481
+ \sys _if_engine_pdftex:T
482
+ {
483
+ \pdfximage {example-image-duck.pdf}
484
+ \int _set:Nn \l _tmpa_int { \the\pdflastximagepages }
485
+ \pdfximage {example-image-duck-portrait.pdf}
486
+ \int _set:Nn \l _tmpb_int { \the\pdflastximagepages }
487
+ }
488
+ \sys _if_engine_luatex:T
489
+ {
490
+ \saveimageresource {example-image-duck.pdf}
491
+ \int _set:Nn \l _tmpa_int { \lastsavedimageresourcepages }
492
+ \saveimageresource {example-image-duck-portrait.pdf}
493
+ \int _set:Nn \l _tmpb_int { \lastsavedimageresourcepages }
494
+ }
495
+ \sys _if_engine_xetex:T
496
+ {
497
+ \int _set:Nn \l _tmpa_int
498
+ { \XeTeXpdfpagecount "example-image-duck.pdf" }
499
+ \int _set:Nn \l _tmpb_int
500
+ { \XeTeXpdfpagecount "example-image-duck-portrait.pdf" }
501
+ }
502
+ \int _const:Nn \c _duckuments_example_pages_int
503
+ { \int _min:nn { \l _tmpa_int } { \l _tmpb_int } }
504
+ \group _end:
505
+ }
444
506
% \end{macrocode}
445
507
% \end{variable}^^A<<<
446
508
% ^^A<<<
@@ -502,8 +564,9 @@ and the derived files duckuments.pdf,
502
564
{% >>>
503
565
,immediate .bool_set:N = \l _duckuments_immediate_bool
504
566
,immediate .default:n = true
505
- ,full .code:n =
567
+ ,full .code:n =
506
568
\duckuments _blindduck_range_test:n { 1-\c _duckuments_blindduck_pars_int }
569
+ ,all .meta:n = { full }
507
570
,maths .choice:
508
571
,maths / both .code:n =
509
572
{
@@ -620,9 +683,10 @@ and the derived files duckuments.pdf,
620
683
% \end{macrocode}
621
684
% \end{macro}^^A<<<
622
685
%
623
- % \begin{macro}{\duckumentsCreateExampleFile}^^A>>>
686
+ % \begin{macro}{\duckumentsCreateExampleFiles}^^A>>>
687
+ % Create example-image-duck.tex
624
688
% \begin{macrocode}
625
- \newcommand *\duckumentsCreateExampleFile
689
+ \newcommand *\duckumentsCreateExampleFiles
626
690
{% >>>
627
691
\iow _new:N \duckuments _example_file_iow
628
692
\iow _open:Nn \duckuments _example_file_iow { example-image-duck.tex }
@@ -639,22 +703,34 @@ and the derived files duckuments.pdf,
639
703
\iow _now:Nn \duckuments _example_file_iow
640
704
{ \end {document } }
641
705
\iow _close:N \duckuments _example_file_iow
706
+ % \end{macrocode}
707
+ % Create example-image-duck-portrait.tex
708
+ % \begin{macrocode}
709
+ \iow _open:Nn \duckuments _example_file_iow
710
+ { example-image-duck-portrait.tex }
711
+ \iow _now:Nn \duckuments _example_file_iow
712
+ { \documentclass [tikz,multi ]{standalone } }
713
+ \iow _now:Nn \duckuments _example_file_iow
714
+ { \usepackage {tikzducks } }
715
+ \iow _now:Nn \duckuments _example_file_iow
716
+ { \usepackage {duckuments } }
717
+ \iow _now:Nn \duckuments _example_file_iow
718
+ { \begin {document } }
719
+ \iow _now:Nn \duckuments _example_file_iow
720
+ { \duckumentsDrawRandomDucks * }
721
+ \iow _now:Nn \duckuments _example_file_iow
722
+ { \end {document } }
723
+ \iow _close:N \duckuments _example_file_iow
642
724
}% <<<
643
725
% \end{macrocode}
644
726
% \end{macro}^^A<<<
645
727
% \begin{macro}{\duckumentsDrawRandomDucks}^^A>>>
646
728
% \begin{macrocode}
647
- \newcommand *\duckumentsDrawRandomDucks [1][ \duckuments@randoms ]
729
+ \newcommand *\duckumentsDrawRandomDucks
648
730
{% >>>
649
- \foreach\x in {1,2,...,#1}
650
- {\begin {tikzpicture }
651
- \draw [black,fill=gray!50] (0,0) rectangle (6,4);
652
- \draw [gray,thin] (0,0) -- (6,4);
653
- \draw [gray,thin] (0,4) -- (6,0);
654
- \draw [gray,thin] (3,0) -- (3,4);
655
- \draw [gray,thin] (0,2) -- (6,2);
656
- \node at (3,2) {\tikz\randuck ;};
657
- \end {tikzpicture }}
731
+ \@ifstar
732
+ {\duckumentsDrawRandomDucks@portrait }
733
+ {\duckumentsDrawRandomDucks@landscape }%
658
734
}% <<<
659
735
% \end{macrocode}
660
736
% \end{macro}^^A<<<
@@ -733,6 +809,43 @@ and the derived files duckuments.pdf,
733
809
% \end{macrocode}
734
810
% \end{macro}^^A<<<
735
811
%
812
+ % \begin{macro}{\duckumentsDrawRandomDucks@landscape}^^A>>>
813
+ % \begin{macrocode}
814
+ \newcommand *\duckumentsDrawRandomDucks@landscape [1][\duckuments@randoms ]
815
+ {% >>>
816
+ \foreach\x in {1,2,...,#1}
817
+ {\duckumentsDrawRandomDucks@draw {6.47214}{4}{3.23607}{2}}
818
+ }% <<<
819
+ % \end{macrocode}
820
+ % \end{macro}^^A<<<
821
+ %
822
+ % \begin{macro}{\duckumentsDrawRandomDucks@portrait}^^A>>>
823
+ % \begin{macrocode}
824
+ \newcommand *\duckumentsDrawRandomDucks@portrait [1][\duckuments@randoms ]
825
+ {% >>>
826
+ \foreach\x in {1,2,...,#1}
827
+ {\duckumentsDrawRandomDucks@draw {1.8541}{3}{.92705}{1.5}}
828
+ }% <<<
829
+ % \end{macrocode}
830
+ % \end{macro}^^A<<<
831
+ %
832
+ % \begin{macro}{\duckumentsDrawRandomDucks@draw}^^A>>>
833
+ % \begin{macrocode}
834
+ \newcommand *\duckumentsDrawRandomDucks@draw [4]
835
+ {% >>>
836
+ \begin {tikzpicture }
837
+ \draw [fill=gray!50,use~as~bounding~box] (0,0) rectangle (#1,#2);
838
+ \draw [gray,thin] (0,0) -- (#1,#2);
839
+ \draw [gray,thin] (0,#2) -- (#1,0);
840
+ \draw [gray,thin] (#3,0) -- (#3,#2);
841
+ \draw [gray,thin] (0,#4) -- (#1,#4);
842
+ \node at (#3,#4) {\tikz\randuck ;};
843
+ \draw [black] (0,0) rectangle (#1,#2);
844
+ \end {tikzpicture }
845
+ }% <<<
846
+ % \end{macrocode}
847
+ % \end{macro}^^A<<<
848
+ %
736
849
% \begin{macro}{\duckuments_patch_includegraphics:}^^A>>>
737
850
% \begin{macrocode}
738
851
\cs _new_protected_nopar:Nn \duckuments _patch_includegraphics:
@@ -1046,14 +1159,17 @@ and the derived files duckuments.pdf,
1046
1159
}% <<<
1047
1160
\newcommand *\duckuments@blindduck@text@iv
1048
1161
{% >>>
1049
- Before the first sunlight the underduckling woke. He didn't have the feeling
1050
- of being well rested. But nonetheless he knew that this was the day he
1051
- should leave. Except saying goodbye to his beloved ones there was nothing
1052
- holding him back. His duck had sent him on the most important mission a five
1053
- weeks old inexperienced underduckling was ever sent. He bid farewell to his
1054
- mother, all his brothers and sisters, and finally from his duck. The bag was
1162
+ Before dawn the underduckling woke. He didn't have the feeling of being well
1163
+ rested. But nonetheless he knew that this was the day he should leave.
1164
+ Except saying goodbye to his beloved ones there was nothing holding him
1165
+ back. His duck had sent him on the most important mission a five weeks old
1166
+ inexperienced underduckling was ever sent. He bid farewell to his mother,
1167
+ all his brothers and sisters, and finally from his duck. The bag was
1055
1168
shouldered, the boots were tied, the underduckling left.%
1056
1169
}% <<<
1170
+ \newcommand *\duckuments@blindduck@text@v
1171
+ {% >>>
1172
+ }% <<<
1057
1173
% \end{macrocode}
1058
1174
% \end{macro}^^A<<<
1059
1175
%
@@ -1161,7 +1277,6 @@ and the derived files duckuments.pdf,
1161
1277
% {
1162
1278
% \group_begin:
1163
1279
% \driver_color_gray:n { 0.5 }
1164
- % \group_insert_after:N \driver_color_reset:
1165
1280
% \rlap
1166
1281
% {
1167
1282
% \smash
0 commit comments