diff options
author | Karl Berry <karl@freefriends.org> | 2018-03-13 22:00:35 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-03-13 22:00:35 +0000 |
commit | ffded645119011854c6137bcb09d049d66c058f5 (patch) | |
tree | dd1aff3b187085695e8165ba1ffa97a67ed484a6 /Master/texmf-dist/tex/latex/duckuments | |
parent | 086b1547b4ca9345835a2417ad40e5ec9fee3842 (diff) |
duckuments (13mar18)
git-svn-id: svn://tug.org/texlive/trunk@46950 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 | 322 |
1 files changed, 322 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/duckuments/duckuments.sty b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty new file mode 100644 index 00000000000..a18d45c81a1 --- /dev/null +++ b/Master/texmf-dist/tex/latex/duckuments/duckuments.sty @@ -0,0 +1,322 @@ +%% +%% This is file `duckuments.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% duckuments.dtx (with options: `pkg') +%% +%% -------------------------------------------------------------- +%% duckuments -- minimal working duckuments +%% E-mail: jspratte@yahoo.de +%% Released under the LaTeX Project Public License v1.3c or later +%% See http://www.latex-project.org/lppl.txt +%% -------------------------------------------------------------- +%% +%% Copyright (C) 2018 Jonathan P. Spratte +%% +%% This work may be distributed and/or modified under the conditions of the +%% LaTeX Project Public License (LPPL), either version 1.3c of this license or +%% (at your option) any later version. The latest version of this license is in +%% the file: +%% +%% http://www.latex-project.org/lppl.txt +%% +%% This work is "maintained" (as per LPPL maintenance status) by +%% Jonathan P. Spratte. +%% +%% This work consists of the file duckuments.dtx +%% and the derived files duckuments.pdf, +%% duckuments.sty and +%% example-image-duck.tex +%% +\RequirePackage{xparse,letltxmacro,l3keys2e} +\def\duckuments@version{v0.1} +\def\duckuments@date{2018/03/13} +\ProvidesExplPackage + {duckuments} {\duckuments@date} + {\duckuments@version} {minimal working duckuments} +\bool_if:nF { \sys_if_engine_luatex_p: || \sys_if_engine_pdftex_p: } + { %>>> + \msg_new:nnnn { duckuments } { incompatible } + { + The~duckuments~package~is~currently~only~compatible~with~pdfTeX~and~ + LuaTeX! + } + { + Sorry~for~that. + } + \msg_error:nn { duckuments } { incompatible } + \endinput + }%<<< +\file_if_exist:nF { example-image-duck.pdf } + {%>>> + \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 } + { 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~ + in~the~current~working~directory. + } + } + }%<<< +\newcommand*\duckuments@randoms{100} +\bool_new:N \l_duckuments_immediate_bool +\bool_new:N \l_duckuments_toc_bool +\bool_new:N \l_duckuments_math_inline_bool +\bool_new:N \l_duckuments_math_display_bool +\regex_const:Nn \c_duckuments_regex + { example-image-duck|example-image-duck.pdf } +\keys_define:nn { duckuments } + {%>>> + ,toc .bool_set:N = \l_duckuments_toc_bool + ,toc .default:n = true + ,maths .choice: + ,maths / both .code:n = + { + \bool_set_true:N \l_duckuments_math_inline_bool + \bool_set_true:N \l_duckuments_math_display_bool + } + ,maths / none .code:n = + { + \bool_set_false:N \l_duckuments_math_inline_bool + \bool_set_false:N \l_duckuments_math_display_bool + } + ,maths / inline .code:n = \bool_set_true:N \l_duckuments_math_inline_bool + ,maths / display .code:n = \bool_set_true:N \l_duckuments_math_display_bool + ,maths .default:n = both + ,immediate .bool_set:N = \l_duckuments_immediate_bool + ,immediate .default:n = true + }%<<< +\ProcessKeysOptions { duckuments } +\bool_if:NTF \l_duckuments_immediate_bool + { \AtEndOfPackage { \duckuments_patch_includegraphics: } } + { \AtBeginDocument { \duckuments_patch_includegraphics: } } +\NewDocumentCommand \duckument { O{} } + {%>>> + \group_begin: + \keys_set:nn { duckuments } { #1 } + \bool_if:NT \l_duckuments_toc_bool { \tableofcontents } + \cs_if_exist_use:NT \chapter + { {\duckuments@headings@text{0}} \blindduck } + \duckuments@headings{1} \blindduck + \duckuments@headings{2} \blindduck + \duckuments@headings{3} \blindduck + \duckuments@headings{4} \blindduck + \section {Lists} + \duckuments_list_example:n { itemize } + \duckuments_list_example:n { enumerate } + \duckuments_list_example:n { description } + \group_end: + }%<<< +\NewDocumentCommand \blindduck { O{} } + {%>>> + \group_begin: + \keys_set:nn { duckuments } { #1 } + \duckuments@blindduck@text + \group_end: + }%<<< +\NewDocumentCommand \ducklist {s m} + {%>>> + \begin{#2} + \IfBooleanTF { #1 } + {\ducklists@content@starred} + { + \str_if_eq:nnTF { #2 } { description } + \ducklists@content@starred + \ducklists@content + } + \end{#2} + }%<<< +\NewDocumentCommand \ducklistlist { s m } + {%>>> + \IfBooleanTF { #1 } + { \duckuments@listlist@starred { #2 } } + { + \str_if_eq:nnTF { #2 } { description } + { \duckuments@listlist@starred { description } } + { \duckuments@listlist{#2} } + } + }%<<< +\newcommand*\duckenumerate{\ducklist{enumerate}} +\newcommand*\duckitemize{\ducklist{itemize}} +\newcommand*\duckdescription{\ducklist{description}} +\newcommand*\duckumentsCreateExampleFile + {%>>> + \iow_new:N \duckuments_example_file_iow + \iow_open:Nn \duckuments_example_file_iow { example-image-duck.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 + {%>>> + \foreach\x in {1,2,...,\duckuments@randoms} + {\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}} + }%<<< +\newcommand*\duckuments@headings[1] + {%>>> + \ifcase#1\relax + \expandafter\chapter + \or \expandafter\section + \or \expandafter\subsection + \or \expandafter\subsubsection + \or \expandafter\paragraph + \else \expandafter\@gobble + \fi + {\duckuments@headings@text{#1}} + }%<<< +\newcommand*\duckuments@headings@level[1] + {%>>> + ( + \ifcase#1 + chapter + \or section + \or subsection + \or subsubsection + \or paragraph + \fi + ) + }%<<< +\newcommand*\duckuments@ifinline[2][] + { \bool_if:NTF \l_duckuments_math_inline_bool { #2 } { #1 } } +\newcommand*\duckuments@ifdisplay[2][] + { \bool_if:NTF \l_duckuments_math_display_bool { #2 } { #1 } } +\cs_new_protected_nopar:Nn \duckuments_list_example:n + {%>>> + \subsection{Example\ for\ ducks\ (#1)} + \ducklist { #1 } + \subsubsection{Nested\ ducks} + \ducklistlist { #1 } + }%<<< +\newcommand*\duckuments@enquote [1] + {%>>> + \cs_if_exist_use:NTF + \enquote { #1 } + {``#1''} + }%<<< +\cs_new_protected_nopar:Nn \duckuments_patch_includegraphics: + {%>>> + \cs_if_exist:NT \includegraphics + { + \LetLtxMacro\duckuments@includegraphicsBAK\includegraphics + \RenewDocumentCommand \includegraphics + { >{\duckuments_starred:n}s O{} m } + { + \regex_match:NnTF \c_duckuments_regex { ##3 } + { + \duckuments@includegraphicsBAK##1 + [page=\int_rand:nn{1}{\duckuments@randoms},##2] { ##3 } + } + { + \duckuments@includegraphicsBAK##1[##2]{##3} + } + } + } + }%<<< +\cs_new_protected:Nn \duckuments_starred:n + {%>>> + \IfBooleanTF { #1 } + { \def\ProcessedArgument{*} } + { \def\ProcessedArgument{} } + }%<<< +\ExplSyntaxOff +\newcommand*\duckuments@blindduck@text + {%>>> + There once was a very smart but sadly blind duck. When it was still a small + duckling it was renowned for its good vision. But sadly as the duck grew + older it caught a sickness which caused its eyesight to worsen. It became so + bad, that the duck couldn't read the notes it once took containing much of + inline math\duckuments@ifinline{ just like its favoured equation: $d = u_c + \cdot k$}. Only displayed equations remained legible% + \duckuments@ifdisplay[.]{ so it could still read \begin{equation}d = r a^k + e\hbox{.}\end{equation}} That annoyed the smart duck, as it wasn't able to + do its research any longer. It called for its underduckling and said: + \duckuments@enquote{Go, find me the best eye ducktor there is. He shall + heal me from my disease!}% + }%<<< +\newcommand*\duckuments@headings@text[1] + {A friendly duck at level #1 \duckuments@headings@level{#1}} +\newcommand*\ducklists@content + {%>>> + \item First swims father drake + \item Then floats mother duck + \item After her paddles baby duckling + \item And over there bathes uncle canard + }%<<< +\newcommand*\ducklists@content@starred + {%>>> + \item[drake] is the swimming father + \item[duck] is the floating mother + \item[duckling] is the paddling baby + \item[canard] is the bathing uncle + }%<<< +\newcommand*\duckuments@listlist[1] + {%>>> + \begin{#1} + \item swimming father drake + \begin{#1} + \item swimming father drake + \begin{#1} + \item swimming father drake + \begin{#1} + \item swimming father drake + \item floating mother duck + \end{#1} + \item floating mother duck + \end{#1} + \item floating mother duck + \end{#1} + \item floating mother duck + \end{#1}% + }%<<< +\newcommand*\duckuments@listlist@starred[1] + {%>>> + \begin{#1} + \item[drake] is the swimming father + \begin{#1} + \item[drake] is the swimming father + \begin{#1} + \item[drake] is the swimming father + \begin{#1} + \item[drake] is the swimming father + \item[duck] is the floating mother + \end{#1} + \item[duck] is the floating mother + \end{#1} + \item[duck] is the floating mother + \end{#1} + \item[duck] is the floating mother + \end{#1}% + }%<<< +%% +%% +%% End of file `duckuments.sty'. |