Graphics, Figures & Tablestikzlings from 'LaTeX Graphics with TikZ'

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
wupppanther
Posts: 2
Joined: Sat Oct 21, 2023 4:04 pm

tikzlings from 'LaTeX Graphics with TikZ'

Post by wupppanther »

I'm working through S.Kottwitz' book 'LaTeX Graphics with TikZ' and I'm running into a problem with the code attached. tikzlings are not displayed with the code snippet I copied from the book. What do I miss or what am I doing wrong?
Please see the attached file.

Code: Select all

\documentclass
[]
{scrartcl}

\usepackage{tikz}              			%% TikZ/pgf zum Schreiben von Grafiken
\usetikzlibrary{positioning}				%% Positionierung in nodes

\usepackage{tikzlings}

\begin{document}

\tikzset{mygrid/.pic = {
\draw[thin, dotted] (-3,-3) grid (3,3);
\draw[->] (-3,0) -- (3,0);
\draw[->] (0,-3) -- (0,3);}}

\begin{tikzpicture}
\draw pic {mygrid};			%% ok
\sloth[					%% ok
  speech={I see \dots},
  crystalball=cyan,
]
\penguin[rotate=30,scale=0.5]
\draw pic {mygrid}			%% From here to the next ';' the code delivers errors
	(-1,0) pic {chicken}
	(1,0) pic {pig}
	(-2,-2) pic {bear}
	(0,-2) pic {penguin}
	(2,-2) pic {owl};
\pic {owl};					%% Owl not displayed, error
\chicken;					%% ok
\end{tikzpicture}

\end{document}
Attachments
tikzlings-Versuch1.tex
(741 Bytes) Downloaded 498 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

tikzlings from 'LaTeX Graphics with TikZ'

Post by Stefan Kottwitz »

Hi,

welcome to the forum!

The newest version of the tikzlings package provides pic versions, with older versions, you can use this:

Code: Select all

\tikzset{
 bear/.pic={\bear},
 owl/.pic={\owl},
 pig/.pic={\pig},
 penguin/.pic={\penguin},
 chicken/.pic={\chicken}}
Stefam
LaTeX.org admin
rais
Posts: 419
Joined: Sun Nov 16, 2014 8:51 pm

tikzlings from 'LaTeX Graphics with TikZ'

Post by rais »

According to tikzlings (see page 3), all you need to do is turn

Code: Select all

\usepackage{tikzlings}
into

Code: Select all

\usetikzlibrary{tikzlings}
KR
Rainer
wupppanther
Posts: 2
Joined: Sat Oct 21, 2023 4:04 pm

tikzlings from 'LaTeX Graphics with TikZ'

Post by wupppanther »

Thank you both for the prompt reply. And both solutions work well, I tested vice-versa with identical result.

Working through Stefan's book shall enable me to change from writing copy-and-paste code grabbed from forums and from the web to a basic understanding of TikZ. The TikZ manual is excellent, sure, but overwhelmingly complex for a beginner like me.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

tikzlings from 'LaTeX Graphics with TikZ'

Post by Stefan Kottwitz »

I knew that samcarter added the pic feature, but I wonder why she did it only in the library. I hope that will be moved to the package version.

@wupppanther you can also use/run/edit the code examples at TikZ.org: tikz.org/examples. Further excellent resources are TikZ.net and TeXample.net.

Stefan
LaTeX.org admin
Post Reply