diff options
author | Karl Berry <karl@freefriends.org> | 2018-09-02 21:13:49 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-09-02 21:13:49 +0000 |
commit | 0408228e9212442a9241e4427a013da20c45cd9e (patch) | |
tree | 10bef0f6796c2c6085f24013852ed486c4e7e2e7 /Master/texmf-dist/tex/latex/duckuments | |
parent | 9b59ccd545a6d71509d515139b5e9344756cacd0 (diff) |
duckuments (2sep18)
git-svn-id: svn://tug.org/texlive/trunk@48545 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/duckuments')
-rw-r--r-- | Master/texmf-dist/tex/latex/duckuments/duckuments.sty | 290 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/duckuments/example-image-duck-portrait.pdf | bin | 0 -> 274866 bytes | |||
-rw-r--r-- | Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf | bin | 270243 -> 283770 bytes |
3 files changed, 208 insertions, 82 deletions
diff --git a/Master/texmf-dist/tex/latex/duckuments/duckuments.sty b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty index 1e3d18eed81..e72964e480b 100644 --- a/Master/texmf-dist/tex/latex/duckuments/duckuments.sty +++ b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty @@ -27,12 +27,13 @@ %% %% This work consists of the file duckuments.dtx %% and the derived files duckuments.pdf, -%% duckuments.sty and -%% example-image-duck.tex +%% duckuments.sty, +%% example-image-duck.tex and +%% example-image-duck-portrait.tex %% \RequirePackage{xparse,letltxmacro,l3keys2e} -\def\duckuments@version{v0.3} -\def\duckuments@date{2018/03/19} +\def\duckuments@version{v0.4} +\def\duckuments@date{2018/09/02} \ProvidesExplPackage {duckuments} {\duckuments@date} {\duckuments@version} {minimal working duckuments} @@ -49,7 +50,12 @@ LuaTeX,~and~XeTeX! } { - Sorry~for~that. + \ ~_____________________________\\ + \ (Quack!~Sorry~for~that.~Quack!)\\ + \ ~"""""""""""""""""""""""""""""\\ + \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\string\ \\ + \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~>()_\\ + \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~\ ~(__)__ } \msg_error:nn { duckuments } { incompatible } \endinput @@ -58,20 +64,45 @@ {%>>> \str_if_eq:VnF \c_sys_jobname_str { example-image-duck } { - \msg_new:nnnn { duckuments } { missing-file } - { - The~file~`#1`~can't~be~found.~Make~sure~to~create~it - \tl_if_empty:nF{#2}{~#2}. - } - { Sorry~for~the~inconvenience.~#3 } - \msg_error:nnnnn { duckuments } { missing-file } + \msg_new:nnnn { duckuments } { missing~file } + { + The~file~`#1`~can't~be~found.~Make~sure~to~create~it + \tl_if_empty:nF{#2}{~#2}. + } + { Sorry~for~the~inconvenience.~#3 } + \msg_error:nnnnn { duckuments } { missing~file } { example-image-duck.pdf } { by~compiling~example-image-duck.tex~at~least~once } { If~you~don't~find~the~file~on~your~machine~you~can~use~ - `\duckumentsCreateExampleFile`~in~your~document~to~produce~a~copy~ + `\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~ + in~the~current~working~directory. + } + } + }%<<< +\file_if_exist:nF { example-image-duck-portrait.pdf } + {%>>> + \str_if_eq:VnF \c_sys_jobname_str { example-image-duck-portrait } + { + \msg_if_exist:nnF { duckuments } { missing~file } + { + \msg_new:nnnn { duckuments } { missing~file } + { + The~file~`#1`~can't~be~found.~Make~sure~to~create~it + \tl_if_empty:nF{#2}{~#2}. + } + { Sorry~for~the~inconvenience.~#3 } + } + \msg_error:nnnnn { duckuments } { missing~file } + { example-image-duck-portrait.pdf } + { + by~compiling~example-image-duck-portrait.tex~at~least~once + } + { + If~you~don't~find~the~file~on~your~machine~you~can~use~ + `\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~ in~the~current~working~directory. } } @@ -87,36 +118,47 @@ \int_gset:Nn \g_duckuments_blindduck_start_int { \c_one } \int_new:N \g_duckuments_blindduck_end_int \regex_const:Nn \c_duckuments_example_regex - { example-image-duck|example-image-duck.pdf } + { + example-image-duck + |example-image-duck.pdf + |example-image-duck-portrait + |example-image-duck-portrait.pdf + } \regex_const:Nn \c_duckuments_range_regex { (\d+|\d+-|-\d+|\d+-\d+|-) } \int_const:Nn \c_duckuments_blindduck_pars_int { \c_five } -\str_if_eq:VnF \c_sys_jobname_str { example-image-duck } +\bool_if:nTF { - \file_if_exist:nTF { example-image-duck.pdf } - { - \sys_if_engine_pdftex:T - { - \pdfximage{example-image-duck.pdf} - \int_const:Nn \c_duckuments_example_pages_int - { \the\pdflastximagepages } - } - \sys_if_engine_luatex:T - { - \saveimageresource{example-image-duck.pdf} - \int_const:Nn \c_duckuments_example_pages_int - { \lastsavedimageresourcepages } - } - \sys_if_engine_xetex:T - { - \group_begin: - \int_gset:Nn \l_tmpa_int - { \XeTeXpdfpagecount "example-image-duck.pdf" } - \int_const:Nn \c_duckuments_example_pages_int { \l_tmpa_int } - \group_end: - } - } + \str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck } + || \str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck-portrait } } { \int_const:Nn \c_duckuments_example_pages_int { 1 } } + { + \group_begin: + \sys_if_engine_pdftex:T + { + \pdfximage{example-image-duck.pdf} + \int_set:Nn \l_tmpa_int { \the\pdflastximagepages } + \pdfximage{example-image-duck-portrait.pdf} + \int_set:Nn \l_tmpb_int { \the\pdflastximagepages } + } + \sys_if_engine_luatex:T + { + \saveimageresource{example-image-duck.pdf} + \int_set:Nn \l_tmpa_int { \lastsavedimageresourcepages } + \saveimageresource{example-image-duck-portrait.pdf} + \int_set:Nn \l_tmpb_int { \lastsavedimageresourcepages } + } + \sys_if_engine_xetex:T + { + \int_set:Nn \l_tmpa_int + { \XeTeXpdfpagecount "example-image-duck.pdf" } + \int_set:Nn \l_tmpb_int + { \XeTeXpdfpagecount "example-image-duck-portrait.pdf" } + } + \int_const:Nn \c_duckuments_example_pages_int + { \int_min:nn { \l_tmpa_int } { \l_tmpb_int } } + \group_end: + } \msg_new:nnnn { duckuments } { option~unknown } { Unknown~option~'#1'~for~package~duckuments. @@ -129,6 +171,20 @@ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\ \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__ } +\msg_new:nnnn { duckuments } { non-boolean~toc } + { + A~non-boolean~value~`#1`~was~received~for~the~`toc`~option~during~package~ + load~time.~It~is~assumed~this~was~given~to~\string\documentclass\ and~ + therefore~ignored. + } + { + \ ~__________________________________\\ + \ (Quack!~Nothing~here,~sorry.~Quack!)\\ + \ ~""""""""""""""""""""""""""""""""""\\ + \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\ + \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\ + \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__ + } \msg_new:nnnn { duckuments } { out~of~range } { You~requested~element~#3~out~of~the~range~#1~to~#2~of~array~'#4'.\\ @@ -147,10 +203,10 @@ \cs_set:Nn \msg_see_documentation_text:n { \\\\ - See~the~\str_if_eq:nnTF { ##1 } { LaTeX } { LaTeX3~documentation } + See~the~\str_if_eq:nnTF { ##1 } { duckuments } { duckumentation } { - \str_if_eq:nnTF { ##1 } { duckuments } { duckumentation } - { ##1~documentation } + \str_if_eq:nnTF { ##1 } { LaTeX } { LaTeX3~ } { ##1~ } + documentation }~for~further~information. } }%<<< @@ -159,8 +215,9 @@ {%>>> ,immediate .bool_set:N = \l_duckuments_immediate_bool ,immediate .default:n = true - ,full .code:n = + ,full .code:n = \duckuments_blindduck_range_test:n { 1-\c_duckuments_blindduck_pars_int } + ,all .meta:n = { full } ,maths .choice: ,maths / both .code:n = { @@ -175,15 +232,28 @@ \bool_set_false:N \l_duckuments_math_display_bool } ,maths .default:n = both - ,toc .bool_set:N = \l_duckuments_toc_bool - ,toc .default:n = true + ,toc .code:n = + { + \str_case:nnF { #1 } + { + { true } { \bool_set_true:N \l_duckuments_toc_bool } + { false } { \bool_set_false:N \l_duckuments_toc_bool } + } + { + \msg_warning:nnn { duckuments } { non-boolean~toc } { #1 } + } + } + ,toc .default:n = true ,unknown .code:n = { \msg_error:nnx { duckuments } { option~unknown } { \l_keys_key_tl } } }%<<< \ProcessKeysOptions { duckuments } \keys_define:nn { duckuments } {%>>> - unknown .code:n = \duckuments_blindduck_range_test:V \l_keys_key_tl + ,toc .undefine: + ,toc .bool_set:N = \l_duckuments_toc_bool + ,toc .default:n = true + ,unknown .code:n = \duckuments_blindduck_range_test:V \l_keys_key_tl }%<<< \bool_if:NTF \l_duckuments_immediate_bool { \AtEndOfPackage { \duckuments_patch_includegraphics: } } @@ -238,7 +308,7 @@ \newcommand*\duckenumerate{\ducklist{enumerate}} \newcommand*\duckitemize{\ducklist{itemize}} \newcommand*\duckdescription{\ducklist{description}} -\newcommand*\duckumentsCreateExampleFile +\newcommand*\duckumentsCreateExampleFiles {%>>> \iow_new:N \duckuments_example_file_iow \iow_open:Nn \duckuments_example_file_iow { example-image-duck.tex } @@ -255,18 +325,27 @@ \iow_now:Nn \duckuments_example_file_iow { \end{document} } \iow_close:N \duckuments_example_file_iow + \iow_open:Nn \duckuments_example_file_iow + { example-image-duck-portrait.tex } + \iow_now:Nn \duckuments_example_file_iow + { \documentclass[tikz,multi]{standalone} } + \iow_now:Nn \duckuments_example_file_iow + { \usepackage{tikzducks} } + \iow_now:Nn \duckuments_example_file_iow + { \usepackage{duckuments} } + \iow_now:Nn \duckuments_example_file_iow + { \begin{document} } + \iow_now:Nn \duckuments_example_file_iow + { \duckumentsDrawRandomDucks* } + \iow_now:Nn \duckuments_example_file_iow + { \end{document} } + \iow_close:N \duckuments_example_file_iow }%<<< -\newcommand*\duckumentsDrawRandomDucks[1][\duckuments@randoms] +\newcommand*\duckumentsDrawRandomDucks {%>>> - \foreach\x in {1,2,...,#1} - {\begin{tikzpicture} - \draw[black,fill=gray!50] (0,0) rectangle (6,4); - \draw[gray,thin] (0,0) -- (6,4); - \draw[gray,thin] (0,4) -- (6,0); - \draw[gray,thin] (3,0) -- (3,4); - \draw[gray,thin] (0,2) -- (6,2); - \node at (3,2) {\tikz\randuck;}; - \end{tikzpicture}} + \@ifstar + {\duckumentsDrawRandomDucks@portrait} + {\duckumentsDrawRandomDucks@landscape}% }%<<< \newcommand*\duckuments@headings[1] {%>>> @@ -303,32 +382,67 @@ \subsubsection{Nested\ ducks} \ducklistlist { #1 } }%<<< -\newcommand*\duckuments@enquote [1] +\NewDocumentCommand \duckuments@enquote { s +m } {%>>> - \cs_if_exist_use:NTF - \enquote { #1 } - {``#1''} + \IfBooleanTF { #1 } + { + \cs_if_exist_use:NTF + \enquote { * { #2 } } + { `#2' } + } + { + \cs_if_exist_use:NTF + \enquote { { #1 } } + {``#1''} + } + }%<<< +\newcommand*\duckumentsDrawRandomDucks@landscape[1][\duckuments@randoms] + {%>>> + \foreach\x in {1,2,...,#1} + {\duckumentsDrawRandomDucks@draw{6.47214}{4}{3.23607}{2}} + }%<<< +\newcommand*\duckumentsDrawRandomDucks@portrait[1][\duckuments@randoms] + {%>>> + \foreach\x in {1,2,...,#1} + {\duckumentsDrawRandomDucks@draw{1.8541}{3}{.92705}{1.5}} + }%<<< +\newcommand*\duckumentsDrawRandomDucks@draw[4] + {%>>> + \begin{tikzpicture} + \draw[fill=gray!50,use~as~bounding~box] (0,0) rectangle (#1,#2); + \draw[gray,thin] (0,0) -- (#1,#2); + \draw[gray,thin] (0,#2) -- (#1,0); + \draw[gray,thin] (#3,0) -- (#3,#2); + \draw[gray,thin] (0,#4) -- (#1,#4); + \node at (#3,#4) {\tikz\randuck;}; + \draw[black] (0,0) rectangle (#1,#2); + \end{tikzpicture} }%<<< \cs_new_protected_nopar:Nn \duckuments_patch_includegraphics: {%>>> - \cs_if_exist:NT \includegraphics + \@ifpackageloaded { graphicx } { \LetLtxMacro\duckuments@includegraphicsBAK\includegraphics \RenewDocumentCommand \includegraphics - { >{\duckuments_starred:n}s O{} m } + { >{\duckuments_starred:n}s O{} o m } { - \regex_match:NnTF \c_duckuments_example_regex { ##3 } - { - \duckuments_get_random_page: - \duckuments@includegraphicsBAK##1 - [page=\duckuments_random_page:,##2] - { ##3 } - } + \IfValueTF { ##3 } + { \duckuments@includegraphicsBAK##1[##2][##3]{##4} } { - \duckuments@includegraphicsBAK##1[##2]{##3} + \regex_match:NnTF \c_duckuments_example_regex { ##4 } + { + \duckuments_get_random_page: + \duckuments@includegraphicsBAK##1 + [page=\duckuments_random_page:,##2] + { ##4 } + } + { + \duckuments@includegraphicsBAK##1[##2]{##4} + } } } } + {} }%<<< \cs_new_protected:Nn \duckuments_blindduck_range_test:n {%>>> @@ -340,7 +454,7 @@ \cs_set:Npn \duckuments@blindduck@text { \duckuments_blindduck_single_par:n { #1 } - \int_gset:Nn \g_duckuments_blindduck_start_int { #1 + \c_one } + \duckuments_blindduck_set_next_start:n { #1 } } } { @@ -368,10 +482,8 @@ } } { - \group_begin: - \exp_args:NnnV - \msg_error:nnn { duckuments } { option~unknown } \l_keys_key_tl - \group_end: + \exp_args:NnnV + \msg_error:nnn { duckuments } { option~unknown } \l_keys_key_tl } }%<<< \cs_generate_variant:Nn \duckuments_blindduck_range_test:n { V } @@ -381,10 +493,15 @@ { \int_step_function:nnnN { #1 } { \c_one } { #2 } \duckuments_blindduck_par_loop:n - \int_gset:Nn \g_duckuments_blindduck_start_int { #2 + \c_one } + \duckuments_blindduck_set_next_start:n { #2 } } }%<<< \cs_generate_variant:Nn \duckuments_blindduck_set_text:nn { xx } +\cs_new:Nn \duckuments_blindduck_set_next_start:n + {%>>> + \int_gset:Nn \g_duckuments_blindduck_start_int + { \int_mod:nn { #1 } { \c_duckuments_blindduck_pars_int } + \c_one } + }%<<< \cs_new:Nn \duckuments_blindduck_single_par:n {%>>> \bool_if:nTF @@ -554,14 +671,23 @@ }%<<< \newcommand*\duckuments@blindduck@text@iv {%>>> - Before the first sunlight the underduckling woke. He didn't have the feeling - of being well rested. But nonetheless he knew that this was the day he - should leave. Except saying goodbye to his beloved ones there was nothing - holding him back. His duck had sent him on the most important mission a five - weeks old inexperienced underduckling was ever sent. He bid farewell to his - mother, all his brothers and sisters, and finally from his duck. The bag was + Before dawn the underduckling woke. He didn't have the feeling of being well + rested. But nonetheless he knew that this was the day he should leave. + Except saying goodbye to his beloved ones there was nothing holding him + back. His duck had sent him on the most important mission a five weeks old + inexperienced underduckling was ever sent on. He bid farewell to his mother, + all his brothers and sisters, and finally from his duck. The bag was shouldered, the boots were tied, the underduckling left.% }%<<< +\newcommand*\duckuments@blindduck@text@v + {%>>> + As the underduckling went along he saw a tree. It was so tall he couldn't + even approximate its height. Oh, how small he felt. What should he, a small + duckling whose plumage was still fluffy, achieve in this vast, gigantic + world? He stuck his trembling wings under the straps of his backpack to calm + his shaking limbs. Where should he start his search? How should he survive + in the hostile nature surrounding the sheltered pond of his community? + }%<<< \newcommand*\duckuments@headings@text[1] {A friendly duck at level #1 \duckuments@headings@level{#1}} \newcommand*\ducklists@content diff --git a/Master/texmf-dist/tex/latex/duckuments/example-image-duck-portrait.pdf b/Master/texmf-dist/tex/latex/duckuments/example-image-duck-portrait.pdf Binary files differnew file mode 100644 index 00000000000..ce7bc8262e7 --- /dev/null +++ b/Master/texmf-dist/tex/latex/duckuments/example-image-duck-portrait.pdf diff --git a/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf b/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf Binary files differindex 8b3fa4d07a7..c9ee8019d10 100644 --- a/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf +++ b/Master/texmf-dist/tex/latex/duckuments/example-image-duck.pdf |