Skip to content

Commit c693ad6

Browse files
committed
example-image-duck-poortrait added; all option
1 parent 6f2b3fb commit c693ad6

File tree

2 files changed

+184
-68
lines changed

2 files changed

+184
-68
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88
*.toc
99
duckuments.sty
1010
example-image-duck.tex
11+
example-image-duck-portrait.tex
1112
test.tex

duckuments.dtx

Lines changed: 183 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ and the derived files duckuments.pdf,
4949
\endpostamble
5050
\generate{\file{duckuments.sty}{\from{duckuments.dtx}{pkg}}}
5151
\generate{\file{example-image-duck.tex}{\from{duckuments.dtx}{eid}}}
52+
\generate{\file{example-image-duck-portrait.tex}{\from{duckuments.dtx}{eidp}}}
5253
\ifx\fmtname\nameofplainTeX
5354
\expandafter\endbatchfile
5455
\else
@@ -84,6 +85,17 @@ and the derived files duckuments.pdf,
8485
\end{document}
8586
%</eid>
8687
%
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+
%
8799
%<*pkg>
88100
\def\duckuments@version{v0.3}
89101
\def\duckuments@date{2018/03/19}
@@ -113,12 +125,14 @@ and the derived files duckuments.pdf,
113125
% simple alternative to the \pkg{blindtext} package.
114126
%
115127
% 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
122136
% \href{https://github.com/Skillmon/ltx_duckuments}{github}.
123137
%
124138
% \textbf{The package does currently only work on \pdfTeX, \LuaTeX, and \XeTeX}.
@@ -180,19 +194,21 @@ and the derived files duckuments.pdf,
180194
%
181195
% \subsection{Other Macros}^^A>>>
182196
%
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.
186200
% \end{function}^^A<<<
187201
%
188202
% \begin{function}{\duckumentsDrawRandomDucks}^^A>>>
189203
% \begin{syntax}
190-
% \cs{duckumentsDrawRandomDucks}\oarg{count}
204+
% \cs{duckumentsDrawRandomDucks}\meta{*}\oarg{count}
191205
% \end{syntax}
192206
% Draws \meta{count} random \pkg{tikzducks} using
193207
% \pkg{Ti\textit{k}Z}. \meta{count} defaults to \cs{duckuments@randoms}.
194208
% 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.
196212
% \end{function}^^A<<<
197213
%^^A<<<
198214
%
@@ -219,7 +235,7 @@ and the derived files duckuments.pdf,
219235
% The package and commands which take a \oarg{key=value} accept the following
220236
% options. Some of which only make sense as package options. The
221237
% \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.
223239
% \begin{options}
224240
% \item[toc=\textbf{true}$\vert$\textit{false}]
225241
% If |true| the \cs{duckument} contains a ToC.
@@ -230,6 +246,8 @@ and the derived files duckuments.pdf,
230246
% \item[full]
231247
% This typesets the full range of \cs{blindduck}. Don't use this as a
232248
% package option.
249+
% \item[all]
250+
% synonym for |full|.
233251
% \item[immediate=\textbf{true}$\vert$\textit{false}]
234252
% If |true| \cs{includegraphics} is patched during package load time, else
235253
% the patching is done \cs{AtBeginDocument}.
@@ -285,7 +303,12 @@ and the derived files duckuments.pdf,
285303
LuaTeX,~and~XeTeX!
286304
}
287305
{
288-
Sorry~for~that.
306+
\ ~_____________________________\\
307+
\ (Quack!~Sorry~for~that.~Quack!)\\
308+
\ ~"""""""""""""""""""""""""""""\\
309+
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\string\ \\
310+
\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~>()_\\
311+
\ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~\ ~(__)__
289312
}
290313
\msg_error:nn { duckuments } { incompatible }
291314
\endinput
@@ -296,25 +319,53 @@ and the derived files duckuments.pdf,
296319
\file_if_exist:nF { example-image-duck.pdf }
297320
{%>>>
298321
% \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.
301324
% \begin{macrocode}
302325
\str_if_eq:VnF \c_sys_jobname_str { example-image-duck }
303326
{
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 }
311334
{ example-image-duck.pdf }
312335
{
313336
by~compiling~example-image-duck.tex~at~least~once
314337
}
315338
{
316339
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~
318369
in~the~current~working~directory.
319370
}
320371
}
@@ -395,7 +446,12 @@ and the derived files duckuments.pdf,
395446
% Regex against which the patch of \cs{includegraphics} is testing.
396447
% \begin{macrocode}
397448
\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+
}
399455
% \end{macrocode}
400456
% \end{variable}^^A<<<
401457
%
@@ -414,33 +470,39 @@ and the derived files duckuments.pdf,
414470
%
415471
% \begin{variable}{\c_duckuments_example_pages_int}^^A>>>
416472
% \begin{macrocode}
417-
\str_if_eq:VnF \c_sys_jobname_str { example-image-duck }
473+
\bool_if:nTF
418474
{
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 }
442477
}
443478
{ \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+
}
444506
% \end{macrocode}
445507
% \end{variable}^^A<<<
446508
%^^A<<<
@@ -502,8 +564,9 @@ and the derived files duckuments.pdf,
502564
{%>>>
503565
,immediate .bool_set:N = \l_duckuments_immediate_bool
504566
,immediate .default:n = true
505-
,full .code:n =
567+
,full .code:n =
506568
\duckuments_blindduck_range_test:n { 1-\c_duckuments_blindduck_pars_int }
569+
,all .meta:n = { full }
507570
,maths .choice:
508571
,maths / both .code:n =
509572
{
@@ -620,9 +683,10 @@ and the derived files duckuments.pdf,
620683
% \end{macrocode}
621684
% \end{macro}^^A<<<
622685
%
623-
% \begin{macro}{\duckumentsCreateExampleFile}^^A>>>
686+
% \begin{macro}{\duckumentsCreateExampleFiles}^^A>>>
687+
% Create example-image-duck.tex
624688
% \begin{macrocode}
625-
\newcommand*\duckumentsCreateExampleFile
689+
\newcommand*\duckumentsCreateExampleFiles
626690
{%>>>
627691
\iow_new:N \duckuments_example_file_iow
628692
\iow_open:Nn \duckuments_example_file_iow { example-image-duck.tex }
@@ -639,22 +703,34 @@ and the derived files duckuments.pdf,
639703
\iow_now:Nn \duckuments_example_file_iow
640704
{ \end{document} }
641705
\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
642724
}%<<<
643725
% \end{macrocode}
644726
% \end{macro}^^A<<<
645727
% \begin{macro}{\duckumentsDrawRandomDucks}^^A>>>
646728
% \begin{macrocode}
647-
\newcommand*\duckumentsDrawRandomDucks[1][\duckuments@randoms]
729+
\newcommand*\duckumentsDrawRandomDucks
648730
{%>>>
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}%
658734
}%<<<
659735
% \end{macrocode}
660736
% \end{macro}^^A<<<
@@ -733,6 +809,43 @@ and the derived files duckuments.pdf,
733809
% \end{macrocode}
734810
% \end{macro}^^A<<<
735811
%
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+
%
736849
% \begin{macro}{\duckuments_patch_includegraphics:}^^A>>>
737850
% \begin{macrocode}
738851
\cs_new_protected_nopar:Nn \duckuments_patch_includegraphics:
@@ -1046,14 +1159,17 @@ and the derived files duckuments.pdf,
10461159
}%<<<
10471160
\newcommand*\duckuments@blindduck@text@iv
10481161
{%>>>
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
10551168
shouldered, the boots were tied, the underduckling left.%
10561169
}%<<<
1170+
\newcommand*\duckuments@blindduck@text@v
1171+
{%>>>
1172+
}%<<<
10571173
% \end{macrocode}
10581174
% \end{macro}^^A<<<
10591175
%
@@ -1161,7 +1277,6 @@ and the derived files duckuments.pdf,
11611277
% {
11621278
% \group_begin:
11631279
% \driver_color_gray:n { 0.5 }
1164-
% \group_insert_after:N \driver_color_reset:
11651280
% \rlap
11661281
% {
11671282
% \smash

0 commit comments

Comments
 (0)