- `@` est un symbole spécial, il doit être entouré de `\makeatletter ... \makeatother`
- `\tkzPen[...]` doit être entouré de `\begin{tikzpicture}...\end{tikzpicture}`
---
\documentclass[12pt,a4paper]{article}
\usepackage[latin1,utf8]{inputenc}
\usepackage[french]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{lmodern}
\usepackage{fourier}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{xkeyval}
\begin{document}
\newcommand{\CrayonGris}
{
\draw (-0.3,0.6) -- (0,0) -- (0.3,0.6);
\draw[fill=black] (-0.1,0.2) -- (0.1,0.2) -- (0,0) -- cycle;%Pointe du crayon
\draw[fill=gray] (0.3,0.6) arc(90:180:0.1) arc(0:180:0.1) arc(0:180:0.1) arc(0:90:0.1) -- (-0.3,6) -- (0.3,6) -- cycle;%Corps du crayon
\draw (-0.2,6) -- (-0.2,0.55) (0,6) -- (0,0.55) (0.2,6) -- (0.2,0.55);%Traits verticaux
}
\begin{tikzpicture}
\CrayonGris
\end{tikzpicture}
\makeatletter
%-----------> \tkzPen <-------------------
\definecolor{wood}{cmyk}{0.00,0.12,0.35,0.05}
\define@cmdkey[PAS]{tkzPen}{angle}{} % première ligne référencée par l'erreur signalée
\define@cmdkey [PAS] {tkzPen} {angle}{}
\define@cmdkey [PAS] {tkzPen} {color}{}
\define@cmdkey [PAS] {tkzPen} {xscale}{}
\define@cmdkey [PAS] {tkzPen} {yscale}{}
\presetkeys [PAS] {tkzPen} {color = red, angle = 30, xscale=1, yscale=1}{}
%
\newcommand{\tkzPen}[2][]
{%
\newcommand{\tkzPen}[2][]{%
\setkeys[PAS]{tkzPen}{#1}
\begin{scope}[shift={(#2)},rotate=\cmdPAS@tkzPen@angle, xscale=\cmdPAS@tkzPen@xscale, yscale=\cmdPAS@tkzPen@yscale]
\fill[wood] (0,5) circle[x radius=5mm, y radius=2mm];
\fill[wood] (-0.5,1) to[bend right=30] (-0.25,1.2) arc (180:360:0.25cm) to[bend right=30] (0.5,1) -- (0,0) -- cycle;
\fill[fill=\cmdPAS@tkzPen@color] (116.565:2mm) -- (63.435:2mm) -- (0,0) -- cycle;
\fill[fill=\cmdPAS@tkzPen@color] (-0.5,5) -- (-0.5,1) to[bend right=30] (-0.25,1.2) arc (180:360:0.25cm) to[bend right=30] (0.5,1) -- (0.5,5) arc (0:-180:0.5cm and 0.2cm);
\fill[fill=\cmdPAS@tkzPen@color] (116.565:2mm) -- (63.435:2mm) -- (0,0) -- cycle;
\fill[\cmdPAS@tkzPen@color] (0,5) circle[x radius=1.5mm, y radius=0.5mm];
\draw (-0.5,5) -- (-0.5,1) -- (0,0) -- (0.5,1) -- (0.5,5) arc (0:-360:0.5cm and 0.2cm);
\draw (-0.25,4.82) -- (-0.25,1.2) arc(180:360:0.25cm and 0.25cm) -- (0.25,4.82);
\draw (-0.25,1.2) to[bend left=30] (-0.5,1);
\draw (0.25,1.2) to[bend right=30] (0.5,1);
\end{scope}
}
\makeatother
\newcommand{\CrayonGris}{%
\draw (-0.3,0.6) -- (0,0) -- (0.3,0.6);
\draw[fill=black] (-0.1,0.2) -- (0.1,0.2) -- (0,0) -- cycle;%Pointe du crayon
\draw[fill=gray] (0.3,0.6) arc(90:180:0.1) arc(0:180:0.1) arc(0:180:0.1) arc(0:90:0.1) -- (-0.3,6) -- (0.3,6) -- cycle;%Corps du crayon
\draw (-0.2,6) -- (-0.2,0.55) (0,6) -- (0,0.55) (0.2,6) -- (0.2,0.55);%Traits verticaux
}
\begin{document}
\begin{tikzpicture}
\CrayonGris
\end{tikzpicture}
\begin{tikzpicture}
\tkzPen[angle=90,color=blue,xscale=0.5,yscale=0.75]{0,0}
\end{tikzpicture}
\end{document}