4

Is it possible to use/port tikzducks in Plain TeX or ConTeXt? As far as I know, tikzducks.sty has some LaTeX-isms as \begin .. \end environments, so it doesn't work outside LaTeX.

4
  • It crashes in ConTeXt.
    – user193767
    Apr 3, 2020 at 20:11
  • 7
    plain and context users should think themselves lucky that they are spared the duck plague. Apr 3, 2020 at 22:00
  • 4
    Create a separate document with standalone and include it as an image (and don't listen to @DavidCarlisle, he eats pineapple pizza)
    – CarLaTeX
    Apr 3, 2020 at 23:09
  • 2
    @CarLaTeX and ducks Apr 4, 2020 at 0:07

1 Answer 1

7

For ConTeXt users, my attempt to get TikZ ducks:

  1. I deleted LaTeX headers from tikzducks.sty and added the following ones:
\setupcolors[state=start]
\usecolors[xwi]
\usemodule[tikz]
\enabledirectives[colors.pgf]
\usetikzlibrary[patterns] % for the wizard hat
\usetikzlibrary[calc] % for the sports jerseys
  1. Delete @ from command names as it was sort of troublesome.
  2. Replace some commands by its ConTeXt counterparts, e.g. \starttikzpicture .. \stoptikzpicture for \begin{tikzpicture} .. \end{tikzpicture}.
  3. Redefined \duck according to ConTeXt syntax:
\def\duck{\dosingleempty\doduck}
\def\doduck[#1]{%
\iffirstargument
\startscope%
\tikzset{/duck/.cd,#1}%
\duckdraw%
\stopscope%
\else
\startscope%
\tikzset{/duck/.cd}%
\duckdraw%
\stopscope%
\fi 
}
  1. Some other minor changes.

Although the color palette is a bit messed up because of the ConTeXt color management (e.g. ConTeXt gray looks like LaTeX lightgray), the final result is quite acceptable.

The following code:

%\environment_tikzducks and your .tex file must be in the same folder
%unless you use subpath structure, e.g. subfolder/environment_tikzducks
\environment environment_tikzducks
\starttext 
Ducks in \CONTEXT\ go brrr
\startcolumns[n=3]
\dorecurse{20}{%
\starttikzpicture \randuck \stoptikzpicture%

}
\stopcolumns 
\stoptext

gives the output: enter image description here

For anyone interested, I'm sharing the edited code here

EDIT

Sam Carter, the maintainer of tikzducks accepted my pull request to add a ConTeXt wrapper, so finally tikzducks is available in TeXLive. Just do:

\usemodule[tikzducks]
\usecolors[xwi]

and now you can use \tikzducks and related inside ConTeXt's \starttikzpicture ... \stoptikzpicture. It should work fine in LuaMetaTeX, too. Feel free to do suggestions here. A Metapost counterpart would be nice btw.

5
  • 1
    If you would replace format-specific things like \start… by the generic form, I'm sure this would be a great pull request to the package.
    – TeXnician
    Apr 30, 2020 at 21:23
  • Where should I ask? I'd be happy to see ConTeXt users, including myself, using TikZ ducks and friends
    – user193767
    May 5, 2020 at 3:56
  • 1
    What do you mean by asking? If you need help transitioning to the generic forms of commands or testing for the format TeX.SX is the right place. If you are ready, a pull request can be opened at github.com/samcarter/tikzducks.
    – TeXnician
    May 5, 2020 at 5:59
  • @TeXnician My pull request has been accepted. I'm gonna edit my answer soon. Soon it will be only a matter of making \usemodule[tikzducks]\usecolors[xwi]. Thanks for the suggestion.
    – user193767
    Jun 30, 2020 at 12:52
  • That's great. Thanks for your effort :)
    – TeXnician
    Jun 30, 2020 at 13:19

You must log in to answer this question.