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.
1 Answer
For ConTeXt users, my attempt to get TikZ ducks:
- 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
- Delete @ from command names as it was sort of troublesome.
- Replace some commands by its ConTeXt counterparts, e.g.
\starttikzpicture .. \stoptikzpicture
for\begin{tikzpicture} .. \end{tikzpicture}
. - 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
}
- 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
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.
-
1If 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. 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– user193767May 5, 2020 at 3:56
-
1What 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. 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.– user193767Jun 30, 2020 at 12:52 -
standalone
and include it as an image (and don't listen to @DavidCarlisle, he eats pineapple pizza)