<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[a4paper,11pt]{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{lastpage}
\usepackage{verbatim}
\usepackage[francais,english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{amsfonts,amsmath,amssymb,mathrsfs,amsthm} 
\usepackage{fancyhdr}
\usepackage{lmodern}
\usepackage{ScratchX}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%----------------------------------- SI ALORS TOUTE BLANCHE-----------------------------------------------------------
\newcommand{\whitesailors}[2]{%loop with as many blocks as we want
	%	CrÃ©er un compteur Ã&nbsp; chaque passage dans cette boucle.	%	l'incrÃ©menter du nombre de fois oÃ¹ ce dÃ©calage s'opÃ¨re
	%	dÃ©caler en abscisse : ajouter 0,4 Ã&nbsp; x	%	mettre le compteur NbreComptr Ã&nbsp; NbreComptr+1
\ifthenelse{\value{NbrCptrLoupeDuplicate}=0}%aucun compteurs loupe crÃ©Ã©s
		{
		\ifthenelse{\value{CompteurMax}=0}
		{\loope{\theNbrCptrLoupe}{#2}}
		{
			\ifthenelse{\value{NbrCptrLoupe}&lt;\value{CompteurMax}}%\or\value{NbrCptrLoupe}=\value{CompteurMax}}
				{\looope{\theNbrCptrLoupe}{#2}}
				{\loope{\theNbrCptrLoupe}{#2}}%pour ne pas recrÃ©er des compteurs dÃ©jÃ&nbsp; crÃ©Ã©s
		}
		}
		{\looope{\theNbrCptrLoupe}{#2}}

\ifthenelse{\value{NbrCptrAlorsDuplicate}=0}%aucun compteurs aloors crÃ©Ã©s
		{\sialoors{#1}}
		{\sialooors{#1}}%pour ne pas recrÃ©er des compteurs dÃ©jÃ&nbsp; crÃ©Ã©s
\settowidth{\malongueuR}{\pgfinterruptpicture #1 \endpgfinterruptpicture}

	\FPeval{X}{\x+(0.4)*\thedecalageX}	
	\FPeval{Y}{\y+(neg 0.66)*(\thedecalageY)}
	
	%\StrLen{#1}[\valeur]% pour ajuster la longueur de la boÃ®te en fonction de la longueur du text
	\FPeval{b}{neg 0.1+Y}\FPeval{c}{0.36+Y}\FPeval{d}{0.1+X}
	\FPeval{e}{0.46+Y}\FPeval{f}{0.4+X}\FPeval{g}{0.5+X}\FPeval{h}{0.7+X}\FPeval{i}{0.8+X}\FPeval{j}{0.7+(X)}
	\FPeval{ii}{1.2+X}\FPeval{iii}{1.1+X}\FPeval{iiii}{0.9+X}\FPeval{gg}{0.6+X}
	\FPeval{l}{neg 0.2+(Y)}\FPeval{m}{neg 0.3+(Y)}\FPeval{o}{0.1+(Y)}
	%top
	%bottom#1
	\FPeval{mm}{neg 0.1+(neg 0.66)*(#2)+(Y)}
	\FPeval{mmm}{neg 0.2+(neg 0.66)*(#2)+(Y)}\FPeval{mmmm}{neg 0.3+(neg 0.66)*(#2)+(Y)}\FPeval{M}{neg 0.75+(neg 0.66)*(#2)+(Y)}\FPeval{MM}{neg 0.85+(neg 0.66)*(#2)+(Y)}\FPeval{MN}{neg 0.95+(neg 0.66)*(#2)+(Y)}\FPeval{MMM}{neg 0.55+(neg 0.66)*(#2)+(Y)}\FPeval{MMMM}{MMM-0.02}\FPeval{JJ}{j+0.02}%adjusting the height of the bottom
	\coordinate (A) at ($(\d,\e) ! \malongueuR ! (\f,\e)$);
	\coordinate (AA) at ($(\X,\c) ! \malongueuR+0.2cm ! (\g,\c)$);
	\coordinate (BB) at ($(\X,\M) ! \malongueuR+0.2cm ! (\f,\M)$);
	\coordinate (B) at ($(\g,\mmm) ! \malongueuR-0.4cm ! (\i,\mmm)$);	

\multido{\i=1+1}{\value{NbrCptrLoupe}}{%Fait dÃ©filer tous les compteurs jusqu'au nombre de compteurs : si compteur diffÃ©rent de -1 :
	%		si diffÃ©rent de 0, leur enlever 1. / si Ã©gal Ã&nbsp; 0 : enlever 1 Ã&nbsp; dÃ©calageX et mettre le compteur correspondant Ã&nbsp; -1.
	\ifthenelse{\value{loupe\i}&gt;-1}{
			\ifthenelse{\value{loupe\i}=0}
			{\addtocounter{decalageX}{-1}\addtocounter{decalageY}{1}\setcounter{loupe\i}{-1}}
			{\addtocounter{loupe\i}{-1}}
			}{}
	}
\addtocounter{decalageX}{1}
\addtocounter{decalageY}{1}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\selectlanguage{english}
\pagestyle{fancy}
\fancyhead{}
		\fancyhead[LE,LO]{\em \LaTeX}
		\fancyhead[CE,CO]{\Large \textsc{The \texttt{ScratchX.sty} package}}
		\fancyhead[RE,RO]{\em 2016--2017}
		\fancyfoot[CE,CO]{\thepage /\pageref{LastPage}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section*{
\centering{
	\begin{Scratch}
	\beginbox{User guide: package \cb[ope]{ScratchX.sty\ }}
	\end{Scratch}
		}
}
\begin{center}
\begin{Scratch}
\scbox{Thibault Ralet}{ctrl}
\scbox{March \rb{2017}}{data}
\end{Scratch}
\end{center}

\noindent\rule{\linewidth}{.5pt}


\parbox{1ex}{\Scratchy[0.1][0.1]}\\

\hspace{1cm}\parbox{1ex}{\Scratchy[0.2][0.2]}\\

\hspace{2cm}\parbox{1ex}{\Scratchy[0.5][1]}\\

\hspace{5cm}\parbox{1ex}{\Scratchy[0.75][1.5]}\\

%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{Introduction}
The \texttt{ScratchX.sty} package allows you to write any kind of Scratch program in \LaTeX.

The \texttt{ScratchX.sty} package has to be put at least in the same file where the document \texttt{.tex} is created, or in the dedicated place in your computer.

The \texttt{ScratchX.sty} package must be called in the preamble of the document \texttt{.tex} with:

\begin{verbatim} \usepackage{ScratchX} \end{verbatim}

The \texttt{ScratchX.sty} package uses the following packages:
\begin{verbatim}
\usepackage[nomessages]{fp}
\usepackage{calc}
\usepackage{xstring}
\usepackage[alpine]{ifsym}%pour avoir VarFlag comme
%drapeau de dÃ©part de Scratch
\usepackage{ifthen}
\usepackage{multido}
\usepackage{xargs}
\end{verbatim}

In the document \texttt{.tex} that you want to create, you need to load:
\begin{verbatim}
\usepackage{tikz}
\usetikzlibrary{calc}
\end{verbatim}
and also:
\begin{verbatim}
\usepackage{amssymb}
\end{verbatim}

You can compile with XeLaTeX or pdfLaTeX.

\newpage
%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{General description}

We write a program (or simply a command) Scratch with the environment:

\begin{verbatim}
\begin{Scratch}
%\LaTeX commands in order to create the Scratch commands
\end{Scratch}
\end{verbatim}

The command \texttt{\textbackslash begin\{Scratch\}} has the scale in option (1 by default).

Thus,\texttt{\textbackslash begin\{Scratch\}[2]} doubles the program size, whereas  \texttt{\textbackslash begin\{Scratch\}[0.7]} reduces by 70\% the size of the created program.

\begin{center}
\begin{tabular}{cc}

\begin{Scratch}[1]
\scbox{default size}{app}
\end{Scratch}
&amp;
\begin{Scratch}[2]
\scbox{bigger}{app}
\end{Scratch}\\
&amp;
\begin{Scratch}[0.7]
\scbox{smaller}{app}
\end{Scratch}
\end{tabular}
\end{center}

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection*{The colors}
The ten specific Scratch colors are defined like this:
\begin{center}
\begin{tabular}{c@{:\quad}cp{1cm}c@{:\quad }c}\hline
mvt&amp;\textcolor{mvt}{Motion}&amp;&amp;evt&amp;\textcolor{evt}{Events}\\
app&amp;\textcolor{app}{Looks}&amp;&amp;ctrl&amp;\textcolor{ctrl}{Control}\\
son&amp;\textcolor{son}{Sound}&amp;&amp;capt&amp;\textcolor{capt}{Sensing}\\
stylo&amp;\textcolor{stylo}{Pen}&amp;&amp;ope&amp;\textcolor{ope}{Operators}\\
data&amp;\textcolor{data}{Data}&amp;&amp;bloc&amp;\textcolor{bloc}{More blocks}\\\hline
\end{tabular}
\end{center}

\newpage
%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{Command list}

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Simples}
Obtained with \texttt{\textbackslash scbox\{&lt;text&gt;\}\{&lt;color&gt;\}}.

Typing:
\begin{verbatim}
\begin{Scratch}
\scbox{if on edge, bounce}{mvt}
\scbox{hide}{app}
\scbox{stop all sounds}{son}
\scbox{pen down}{stylo}
\scbox{reset timer}{capt}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\scbox{if on edge, bounce}{mvt}
\scbox{hide}{app}
\scbox{stop all sounds}{son}
\scbox{pen down}{stylo}
\scbox{reset timer}{capt}
\end{Scratch}

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Specials}

\subsubsection{Events}%%%%%%%%%%%%%%%%%%%%%%%%
Obtained with \texttt{\textbackslash beginbox\{&lt;text&gt;\}}.

\texttt{\textbackslash beginbox\{\}} gives \parbox{1ex}{\begin{Scratch}\beginbox{}\end{Scratch}}

\texttt{\textbackslash beginbox\{clone\}} gives \parbox{1ex}{\begin{Scratch}\beginbox{clone}\end{Scratch}}

\texttt{\textbackslash beginbox\{when this sprite clicked\}} gives

\hfill\parbox{6cm}{\begin{Scratch}\beginbox{when this sprite clicked}\end{Scratch}}

\subsubsection{Turn}%%%%%%%%%%%%%%%%%%%%%%%%
Obtained with \texttt{\textbackslash turnbox\{&lt;orientation&gt;\}\{&lt;angle&gt;\}}.\\

\texttt{\textbackslash turnbox\{\}\{-145\}} gives \raisebox{-3mm}{\begin{Scratch}\turnbox{}{-145}\end{Scratch}}

\texttt{\textbackslash turnbox\{gauche\}\{30\}} gives \raisebox{-3mm}{\begin{Scratch}\turnbox{gauche}{30}\end{Scratch}}

You can also write \texttt{\textbackslash turnbox\{g\}\{30\}} or \texttt{\textbackslash turnbox\{G\}\{30\}}.

\subsubsection{Loops}%%%%%%%%%%%%%%%%%%%%%%%%
Obtained with

\texttt{\textbackslash boucle\{&lt;text&gt;\}\{&lt;number of blocks inside&gt;\}\{&lt;type&gt;\}},

where &lt;type&gt; is an integer which can be equal to 1 (\emph{repeat $x$ times} or \emph{repeat until}) or -1 (\emph{forever loop}).\\

\parbox{0.53\linewidth}{\texttt{\textbackslash boucle\{repeat \$x\$ times\}\{2\}\{1\}}
\par
\texttt{\textbackslash scbox\{two blocks\}\{red\}}
\par
\texttt{\textbackslash scbox\{in the loop\}\{gray\}}
}
\parbox{0.12\linewidth}{makes}
\parbox{0.2\linewidth}{\raisebox{-3mm}{
\begin{Scratch}[0.9]
\boucle{repeat $x$ times}{2}{1}
\scbox{two blocks}{red}
\scbox{in the loop}{gray}
\end{Scratch}}}

\begin{center}
\begin{tabular}{lcr}
\texttt{\textbackslash boucle\{forever loop\}\{3\}\{-1\}}&amp;&amp;\multirow{3}{*}{\begin{Scratch}[0.9]
\boucle{forever loop}{3}{-1}
\scbox{this time}{pink}
\scbox{three blocks}{blue}
\scbox{in the loop}{purple}
\end{Scratch}}\\
\texttt{\textbackslash scbox\{this time\}\{pink\}}&amp;&amp;\\
\texttt{\textbackslash scbox\{three blocks\}\{blue\}}&amp;&amp;\\
\texttt{\textbackslash scbox\{in the loop\}\{purple\}}&amp;&amp;\\
&amp;&amp;\\
&amp;&amp;\\
\end{tabular}\end{center}

\emph{Notice that if you want to put a loop into another loop, you have to count the correct number of blocks inside the main loop. Actually, a loop counts for two blocks (without the inside blocks).}

\subsubsection{If \dots\ Then}%%%%%%%%%%%%%%%%%%%%%%%%

\emph{Notice that you get this command with the same syntax seen above. Actually:}

\texttt{\textbackslash boucle\{&lt;text&gt;\}\{&lt;number of blocks inside&gt;\}\{2\}}.\\

\parbox{0.53\linewidth}{\texttt{\textbackslash boucle\{if 4 &gt; 5 then\}\{1\}\{2\}}
\par
\texttt{\textbackslash scbox\{problem!\}\{app\}}
}
\parbox{0.12\linewidth}{produit}
\parbox{0.2\linewidth}{\raisebox{-3mm}{
\begin{Scratch}[0.9]
\boucle{if 4 &gt; 5 then}{1}{2}
\scbox{problem!}{app}
\end{Scratch}}}

Remark: in order to properly type the \emph{if\dots then} test, see \emph{the small boxes} in section 3.3.

\subsubsection{If \dots\ Then \dots\ Else}%%%%%%%%%%%%%%%%%%%%%%%%
Obtained with

\texttt{\textbackslash sailors\{&lt;text&gt;\}\{&lt;number of blocks inside&gt;\}}

et

\texttt{\textbackslash simenon\{&lt;number of blocks inside&gt;\}}.\\

Typing:
\begin{verbatim}
\begin{Scratch}
\sailors{if it's an understandable example}{1}
\scbox{then it's all right}{app}
\simenon{2}
\scbox{don't panick}{stylo}
\scbox{see the section \emph{Examples}}{capt}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\sailors{if it's an understandable example}{1}
\scbox{then it's all right}{app}
\simenon{2}
\scbox{don't panick}{stylo}
\scbox{see the section \emph{Examples}}{capt}
\end{Scratch}

\subsubsection{More blocks}%%%%%%%%%%%%%%%%%%%%%%%%

You get them with \texttt{\textbackslash blocbox\{&lt;text&gt;\}}.\\

\texttt{\textbackslash blocbox\{triangle\}} gives \raisebox{-3mm}{\begin{Scratch}\blocbox{triangle}\end{Scratch}}

\subsubsection{SpÃ©cial control}%%%%%%%%%%%%%%%%%%%%%%%%
It's for \raisebox{-3mm}{\begin{Scratch}\kbox{stop \rb{all}}\end{Scratch}}\hspace{-1cm} and \raisebox{-2mm}{\begin{Scratch}\kbox{delete this clone}\end{Scratch}}\hspace{-1cm}.

These commands are obtained with \texttt{\textbackslash kbox\{&lt;text&gt;\}}.

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Inside the Scratch commands: the little boxes}
How to get some specific commands, like: \raisebox{-3mm}{\begin{Scratch}\kbox{stop \rb{all}}\end{Scratch}}\hspace{-1cm}?

How to type \raisebox{-3mm}{\begin{Scratch}\scbox{wait until \hb[capt]{color \sqb{orange} is touching \sqb{green}?}\ }{ctrl}\end{Scratch}}\hspace{-1cm}?

or \raisebox{-3mm}{\begin{Scratch}\scbox{point towards \rb{mouse-pointer}}{mvt}\end{Scratch}}\hspace{-1cm}? or even

\raisebox{-3mm}{\begin{Scratch}
\scbox{change volume by \cb[ope]{pick random \cb[w]{1} to \cb[w]{10}} }{son}\end{Scratch}}\hspace{-1cm} ?

\subsubsection{The little rectangular boxes}%%%%%%%%%%%%%%%%%%%%%%%%
\begin{itemize}
\item In the \texttt{\textbackslash scbox}:

obtained with

\texttt{\textbackslash rb[&lt;color&gt;]\{&lt;text&gt;\}}\\

\item dans les \texttt{\textbackslash beginbox} :

you get them with

\texttt{\textbackslash rbb[&lt;color&gt;]\{&lt;text&gt;\}}\\
\end{itemize}

In both cases, &lt;color&gt; has by default the color of the box it is inside. In order to get a white rectangular box, you just have to put &lt;color&gt; at white or w.\\

Typing:
\begin{verbatim}
\begin{Scratch}
\scbox{play sound \rb{meow}}{son}
\scbox{think \rb[white]{Hmm\dots}}{app}
\scbox{ask \rb[w]{What's your name?} and wait}{capt}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\scbox{play sound \rb{meow}}{son}
\scbox{think \rb[white]{Hmm\dots}}{app}
\scbox{ask \rb[w]{What's your name?} and wait}{capt}
\end{Scratch}

\subsubsection{The small round boxes}%%%%%%%%%%%%%%%%%%%%%%%%

They are hollowed or embossed.

You get them with

\texttt{\textbackslash cb[&lt;color&gt;]\{&lt;text&gt;\}}\\

By default, &lt;color&gt; has the same color of the circular box it is inside. If &lt;color&gt; is white or w, the circular box is hollowed.\\

Typing:
\begin{verbatim}
\begin{Scratch}
\scbox{set video transparency to \cb{answer} \%}{capt}
\scbox{go to x:\cb[w]{x} y:\cb[white]{y}}{mvt}
\scbox{change tempo by \cb[data]{variable} }{son}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\scbox{set video transparency to \cb{answer} \%}{capt}
\scbox{go to x:\cb[w]{x} y:\cb[white]{y}}{mvt}
\scbox{change tempo by \cb[data]{variable} }{son}
\end{Scratch}


\subsubsection{The small hexagonal boxes}%%%%%%%%%%%%%%%%%%%%%%%%
Only for \emph{Sensing} et \emph{Operators} commands.

You get them with

\texttt{\textbackslash hb[&lt;color&gt;]\{&lt;text&gt;\}}\\

By default, &lt;color&gt; is ope.

Typing:
\begin{verbatim}
\begin{Scratch}
\boucle{if \hb{\cb[data]{variable}=\rb[w]{10}} then}{1}{1}
\scbox{wait until \hb[capt]{mouse down?}}{ctrl}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\boucle{if \hb{\cb[data]{variable}=\rb[w]{10}} then}{1}{1}
\scbox{wait until \hb[capt]{mouse down?}}{ctrl}
\end{Scratch}


\subsubsection{The small squared boxes}%%%%%%%%%%%%%%%%%%%%%%%%
Only for the colored squares.

You get them with

\texttt{\textbackslash sqb\{&lt;color&gt;\}}\\

Typing:
\begin{verbatim}
\begin{Scratch}
\scbox{set pen color to \sqb{brown}}{stylo}
\end{Scratch}
\end{verbatim}

you get: \raisebox{-3mm}{\begin{Scratch}
\scbox{set pen color to \sqb{brown}}{stylo}
\end{Scratch}}

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Intricate commands}

\begin{Scratch}%%%%%%%%%%%%%%%%%%%%%%%% 1
\beginbox{clone}
\boucle{repeat until \hb[capt]{color \sqb{black}
 is touching \sqb{yellow} ? }}{1}{1}
\scbox{go to x: \cb[ope]{\cb[data]{x}+\cb[w]{10}} y: \cb[data]{y}}{mvt}
\boucle{if \hb{\cb[data]{y}&lt;\cb[capt]{answer}} then}{3}{1}
\scbox{set \rb{y} to \cb[son]{volume}}{data}
\scbox{say \rb[w]{Hello!} for \cb[capt]{distance to
\rb{mouse-pointer} } secs}{app}
\kbox{stop \rb{all}}
\turnbox{2}{-146}
\end{Scratch}

Got with:

\begin{verbatim}
\begin{Scratch}
\beginbox{clone}
\boucle{repeat until \hb[capt]{color \sqb{black}
 is touching \sqb{yellow} ? }}{1}{1}
\scbox{go to x: \cb[ope]{\cb[data]{x}+\cb[w]{10}} y: \cb[data]{y}}{mvt}
\boucle{if \hb{\cb[data]{y}&lt;\cb[capt]{answer}} then}{3}{1}
\scbox{set \rb{y} to \cb[son]{volume}}{data}
\scbox{say \rb[w]{Hello!} for \cb[capt]{distance to
\rb{mouse-pointer} } secs}{app}
\kbox{stop \rb{all}}
\turnbox{2}{-146}
\end{Scratch}
\end{verbatim}

%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Other sort of commands}

\subsubsection{In the loops}%%%%%%%%%%%%%%%%%%%%%%

You need to use the command \texttt{\textbackslash blank} when in the Scratch program, two loops ends at the same time.\\

Typing:
\begin{verbatim}
\begin{Scratch}
\boucle{repeat \cb[w]{3}}{4}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\scbox{this block is not ok}{data}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\boucle{repeat \cb[w]{3}}{4}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\scbox{this block is not ok}{data}
\end{Scratch}

\vspace{0.5cm}

Whereas typing:
\begin{verbatim}
\begin{Scratch}
\boucle{repeat \cb[w]{3}}{4}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\blank
\scbox{this block is \emph{now} ok}{data}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\boucle{repeat \cb[w]{3}}{4}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\blank
\scbox{this block is \emph{now} ok}{data}
\end{Scratch}

\vspace{0.5cm}

If you type:
\begin{verbatim}
\begin{Scratch}
\boucle{repeat \cb[w]{3}}{5}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\scbox{this block is in another position}{data}
\end{Scratch}
\end{verbatim}

you get:\\

\begin{Scratch}
\boucle{repeat \cb[w]{3}}{5}{1}
\scbox{move \cb[w]{10} steps}{mvt}
\boucle{repeat \cb[w]{5}}{1}{1}
\scbox{change x by \cb[w]{10}}{mvt}
\scbox{this block is in another position}{data}
\end{Scratch}

\subsubsection{How to draw the cat}

You can get the cover cat with:

\texttt{\small\textbackslash Scratchy[&lt;scale&gt;][&lt;lines width&gt;]}

By default, the scale is 0.25 and the lines width is set at 0.25 pt.\\

Here is the code for the cover:
\begin{verbatim}
\parbox{1ex}{\Scratchy[0.1][0.1]}\\

\hspace{1cm}\parbox{1ex}{\Scratchy[0.2][0.2]}\\

\hspace{2cm}\parbox{1ex}{\Scratchy[0.5][1]}\\

\hspace{5cm}\parbox{1ex}{\Scratchy[0.75][1.5]}\\
\end{verbatim}

\newpage
%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{Known problems and solutions}
\begin{enumerate}
\item
The black little triangle doesn't exist in the command \emph{point in direction} (motion). You have to write it down.
\begin{verbatim}
\scbox{point in direction \cb[w]{90 \scriptsize$\blacktriangledown$}}{mvt}
\end{verbatim}
\raisebox{-3mm}{\begin{Scratch}\scbox{point in direction \cb[w]{90 \scriptsize$\blacktriangledown$}}{mvt}\end{Scratch}}\\

\item The height of the boxes is set. Therefor, you cannot put a lot of under-commands in a Scratch command.\\

\item When you need to put only one Scratch command into some text, it is not vertically centered. You can use a: \texttt{\textbackslash raisebox\{-3mm\}}.\\

\item There is also a tiny horizontal gap. When a Scratch environment is over, you often need to add a \texttt{\textbackslash hspace\{-1cm\}}.\\

\item The compile time is sometimes long!
\end{enumerate}

%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{Commands summary}

\begin{tabular}{m{5cm}l}%%%%%%%%%%
\texttt{\small\textbackslash beginbox\{\}}

&amp;\begin{Scratch}[0.75]
\beginbox{}
\end{Scratch}
\\%%%%%%%%%%
\texttt{\small\textbackslash beginbox\{&lt;text&gt;\}}

\tiny(when this sprite clicked)
&amp;\begin{Scratch}[0.75]
\beginbox{quand ce lutin est cliquÃ©}
\end{Scratch}\\%%%%%%%%%%
\texttt{\small\textbackslash beginbox\{clone\}}

&amp;\begin{Scratch}[0.75]
\beginbox{clone}
\end{Scratch}
\\%%%%%%%%%%
\texttt{\small\textbackslash blocbox\{&lt;text&gt;\}}

&amp;\begin{Scratch}[0.75]
\blocbox{function}
\end{Scratch}
\\%%%%%%%%%%
\texttt{\small\textbackslash turnbox\{\}\{90\}}

&amp;\begin{Scratch}[0.75]
\turnbox{}{90}
\end{Scratch}\\%%%%%%%%%%
\texttt{\small\textbackslash turnbox\{g\}\{-270\}}

\tiny(or &lt;gauche&gt; or &lt;G&gt; or &lt;g&gt;)
&amp;\begin{Scratch}[0.75]
\turnbox{g}{-270}
\end{Scratch}
\\%%%%%%%%%%
\texttt{\small\textbackslash scbox\{&lt;text&gt;\}\{&lt;color&gt;\}}

&amp;\begin{Scratch}[0.75]
\scbox{any color, any text}{purple}
\end{Scratch}\\%%%%%%%%%%
\texttt{\small\textbackslash boucle\{repeat\}\{2\}\{1\}}
\tiny(\{&lt;text&gt;\}\{&lt;nbr blocks&gt;\}\{&lt;type&gt;\})
\vspace{3cm}
&amp;\begin{Scratch}[0.75]
\boucle{repeat}{2}{1}
\end{Scratch}\vspace{-1.5cm}
\\%%%%%%%%%%
\texttt{\small\textbackslash boucle\{forever\}\{1\}\{-1\}}

\tiny(\{&lt;text&gt;\}\{&lt;nbr blocks&gt;\}\{&lt;type&gt;\})
\vspace{2cm}
&amp;\begin{Scratch}[0.75]
\boucle{forever}{1}{-1}
\end{Scratch}\vspace{-1.2cm}
\\%%%%%%%%%%
\texttt{\small\textbackslash boucle\{if \dots then\}\{1\}\{2\}}

\tiny(\{&lt;text&gt;\}\{&lt;nbr blocks&gt;\}\{&lt;type&gt;\})
\vspace{2cm}
&amp;\begin{Scratch}[0.75]
\boucle{if \dots then}{1}{2}
\end{Scratch}\vspace{-1.2cm}
\\%%%%%%%%%%

\texttt{\small\textbackslash sailors\{if\dots then\dots\}\{2\}}

\tiny(\{&lt;text&gt;\}\{&lt;nbr blocks&gt;\})
\vspace{2cm}
&amp;\begin{Scratch}[0.75]
\sailors{fi\dots then\dots}{2}
\end{Scratch}\vspace{-1cm}
\\%%%%%%%%%%
\texttt{\small\textbackslash simenon\{&lt;nbre blocks&gt;\}}

\tiny(ici, \textbackslash simenon\{1\})
\vspace{2.2cm}
&amp;\begin{Scratch}[0.75]
\whitesailors{il faut que ce }{1}
\simenon{1}
\end{Scratch}\vspace{-1.2cm}
\\%%%%%%%%%%
\texttt{\small\textbackslash kbox\{&lt;text&gt;\}}

&amp;\begin{Scratch}[0.75]
\kbox{delete this clone}
\end{Scratch}
\\%%%%%%%%%%
\end{tabular}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{tabular}{m{5cm}l}
\texttt{\small\textbackslash rb\{&lt;text&gt;\}}

\tiny (\texttt{\textbackslash rb\{variable\}})
&amp;\begin{Scratch}[0.75]
\scbox{\phantom{tex} \rb{variable} \phantom{tex}}{data}
\end{Scratch}
\\
\texttt{\small\textbackslash rb[w]\{&lt;text&gt;\}}

\tiny(ou \texttt{\textbackslash rb[white]\{&lt;text&gt;\}})
&amp;\begin{Scratch}[0.75]
\scbox{\phantom{tex} \rb[w]{text} }{data}
\end{Scratch}
\\
\texttt{\small\textbackslash rbb\{&lt;text&gt;\}}

\tiny(only for \texttt{\textbackslash beginbox})

\texttt{\textbackslash beginbox\{when I receive \textbackslash rbb\{message1\}\}}
&amp;\begin{Scratch}[0.75]
\beginbox{when I receive \rbb{message1}}
\end{Scratch}
\\

\texttt{\small\textbackslash cb\{&lt;text&gt;\}}

\tiny(transparent)
&amp;\begin{Scratch}[0.75]
\scbox{\phantom{rex} \cb{answer}}{ctrl}
\end{Scratch}
\\
\texttt{\small\textbackslash cb[w]\{&lt;text&gt;\}}

\tiny(ou \textbackslash cb[white]\{&lt;text&gt;\})
&amp;\begin{Scratch}[0.75]
\scbox{\phantom{rex} \cb[w]{answer}}{ctrl}
\end{Scratch}
\\
\texttt{\small\textbackslash cb[&lt;color&gt;]\{&lt;text&gt;\}}

\texttt{\tiny\textbackslash cb[ope]\{answer\}}
&amp;\begin{Scratch}[0.75]
\scbox{\phantom{rex} \cb[ope]{answer}}{ctrl}
\end{Scratch}
\\
\texttt{\small\textbackslash hb\{&lt;text&gt;\}}

&amp;\begin{Scratch}[0.75]
\scbox{\phantom{rex} \hb{answer}}{ctrl}
\end{Scratch}
\\

\texttt{\small\textbackslash hb[capt]\{&lt;text&gt;\}}

&amp;\begin{Scratch}[0.75]
\scbox{\phantom{rex} \hb[capt]{answer}}{ctrl}
\end{Scratch}
\\
\texttt{\small\textbackslash sqb\{&lt;color&gt;\}}

&amp;\begin{Scratch}[0.75]
\scbox{set pen color to \sqb{red}}{stylo}
\end{Scratch}
\\

\end{tabular}

%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\newpage
\section{Examples of programs (in French):}

\begin{verbatim}
\begin{Scratch}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{5}{1}
\scbox{avancer de \cb[w]{10}}{mvt}
\boucle{rÃ©pÃ©ter \cb[w]{5} fois}{1}{1}
\scbox{ajouter \cb[w]{10} Ã&nbsp; x}{mvt}
\scbox{ce bloc est placÃ© autrement}{data}
\scbox{un nouveau bloc}{son}
\end{Scratch}
\end{verbatim}

\begin{verbatim}
\begin{Scratch}
\beginbox{quand \rbb{espace} est pressÃ©}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{8}{1}
	\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[data]{y}}{mvt}
	\boucle{rÃ©pÃ©ter \cb[w]{2} fois}{3}{1}
		\scbox{mettre \rb{x} Ã&nbsp; \rb[w]{0}}{data}
		\scbox{ajouter Ã&nbsp; \rb{y} \cb[w]{10}}{data}
		\scbox{mettre la couleur du stylo Ã&nbsp; \sqb{red}}{stylo}
	\scbox{mon bloc}{bloc}
	\scbox{montrer}{app}
\scbox{effacer tout}{stylo}
\end{Scratch}
\end{verbatim}
\begin{center}
\begin{tabular}{cc}%\hline
\parbox[b]{5.5cm}{
\hspace{1cm}deuxiÃ¨me programme $\rightarrow$
\vspace{2em}
\par
premier programme
\par
\hspace{1.25em}$\downarrow$
\par
\begin{Scratch}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{5}{1}
\scbox{avancer de \cb[w]{10}}{mvt}
\boucle{rÃ©pÃ©ter \cb[w]{5} fois}{1}{1}
\scbox{ajouter \cb[w]{10} Ã&nbsp; x}{mvt}
\scbox{ce bloc est placÃ© \dots}{data}
\scbox{un nouveau bloc}{son}
\end{Scratch}
}
&amp;
\begin{Scratch}
\beginbox{quand \rbb{espace} est pressÃ©}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{8}{1}
	\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[data]{y}}{mvt}
	\boucle{rÃ©pÃ©ter \cb[w]{2} fois}{3}{1}
		\scbox{mettre \rb{x} Ã&nbsp; \rb[w]{0}}{data}
		\scbox{ajouter Ã&nbsp; \rb{y} \cb[w]{10}}{data}
		\scbox{mettre la couleur du stylo Ã&nbsp; \sqb{red}}{stylo}
	\scbox{mon bloc}{bloc}
	\scbox{montrer}{app}
\scbox{effacer tout}{stylo}
\end{Scratch}
\end{tabular}
\end{center}
\newpage
%----------------------------------------------------------------------------------------------------------------------------------%
\subsection{Loops of loops}

%%%%%%%%%%%%%%%%%%%%%%%% 1
\begin{verbatim}
\begin{Scratch}
\beginbox{quand \rb{chronomÃ¨tre} &gt; \cb[w]{10}}

\sailors{si \hb[capt]{touche \rb{espace} pressÃ©e?} alors}{12}

	\sailors{si \hb[capt]{souris pressÃ©e?} alors}{1}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

	\simenon{2}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}

	\sailors{si couleur \sqb{son} touchÃ©e?}{1}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		
	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; y}{mvt}

\sailors{si \hb[capt]{souris pressÃ©e?} alors}{1}
	\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}

\simenon{2}
	\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
	\scbox{cacher la variable \rb{variable}}{data}

\end{Scratch}
\end{verbatim}

\begin{center}
\begin{Scratch}[1]%%%%%%%%%%%%%%%%%%%%%%%% 1
\beginbox{quand \rb{chronomÃ¨tre} &gt; \cb[w]{10}}

\sailors{si \hb[capt]{touche \rb{espace} pressÃ©e?} alors}{12}

	\sailors{si \hb[capt]{souris pressÃ©e?} alors}{1}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

	\simenon{2}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}

	\sailors{si couleur \sqb{son} touchÃ©e?}{1}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		
	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; y}{mvt}

\sailors{si \hb[capt]{souris pressÃ©e?} alors}{1}
	\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}

\simenon{2}
	\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
	\scbox{cacher la variable \rb{variable}}{data}

\end{Scratch}\end{center}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%% 2
\begin{verbatim}
\begin{Scratch}
\beginbox{}

\sailors{si couleur \sqb{stylo} touchÃ©e?}{12}

	\sailors{si \hb[capt]{souris pressÃ©e?} alors}{6}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}
		
 		\sailors{si \hb[capt]{touche \rb{espace} pressÃ©e?} alors}{1}
			\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

		\simenon{1}
			\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
			
	\simenon{2}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}
		
	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}

\end{Scratch}
\end{verbatim}
\begin{center}
\begin{Scratch}[1]%%%%%%%%%%%%%%%%%%%%%%%% 2
\beginbox{}

\sailors{si couleur \sqb{stylo} touchÃ©e?}{12}

	\sailors{si \hb[capt]{souris pressÃ©e?} alors}{6}
		\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}
		
 		\sailors{si \hb[capt]{touche \rb{espace} pressÃ©e?} alors}{1}
			\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}

		\simenon{1}
			\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
			
	\simenon{2}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}
		\scbox{ajouter \cb[w]{10} Ã&nbsp; y}{mvt}
		
	\simenon{1}
		\scbox{donner la valeur \cb[w]{0} Ã&nbsp; x}{mvt}

\end{Scratch}\end{center}

\newpage
%%%%%%%%%%%%%%%%%%%%%%%% 3
\begin{verbatim}
\begin{Scratch}
\beginbox{}
\boucle{rÃ©pÃ©ter indÃ©finiment}{13}{-1}
	\turnbox{}{24}
	\boucle{rÃ©pÃ©ter \cb[w]{4} fois}{2}{1}
		\scbox{stylo en position d'Ã©criture}{stylo}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
	\boucle{quand le lutin s'en va}{6}{1}
		\scbox{cacher la variable \rb{A}}{data}
		\scbox{costume suivant}{app}
		\scbox{arrÃªter tous les sons}{son}
		\turnbox{g}{24}
		\scbox{stylo en position d'Ã©criture}{stylo}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
	\blank
\end{Scratch}
\end{verbatim}
\begin{center}
\begin{Scratch}[1]%%%%%%%%%%%%%%%%%%%%%%%% 3
\beginbox{}
\boucle{rÃ©pÃ©ter indÃ©finiment}{13}{-1}
	\turnbox{}{24}
	\boucle{rÃ©pÃ©ter \cb[w]{4} fois}{2}{1}
		\scbox{stylo en position d'Ã©criture}{stylo}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
	\boucle{rÃ©pÃ©ter \cb[w]{4} fois}{6}{1}
		\scbox{cacher la variable \rb{A}}{data}
		\scbox{costume suivant}{app}
		\scbox{arrÃªter tous les sons}{son}
		\turnbox{g}{24}
		\scbox{stylo en position d'Ã©criture}{stylo}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
	\blank
\end{Scratch}
\end{center}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%% 4
\begin{verbatim}
\begin{Scratch}
\beginbox{quand on le veut}
\boucle{rÃ©pÃ©ter un certain nombre de fois}{8}{1}
	\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}
	\boucle{le dernier ??}{2}{1}
		\scbox{on peut faire}{gray}
		\scbox{ce que l'on veut}{black}
	\boucle{ne pas rÃ©pÃ©ter}{1}{1}
	\scbox{faux bloc}{brown}
	\blank
\scbox{dernier bloc}{pink}
\end{Scratch}
\end{verbatim}

\begin{center}
\begin{Scratch}[1]%%%%%%%%%%%%%%%%%%%%%%%% 4
\beginbox{quand on le veut}
\boucle{rÃ©pÃ©ter un certain nombre de fois}{8}{1}
	\scbox{aller Ã&nbsp; x: \cb[w]{0} y: \cb[w]{0}}{mvt}
	\boucle{se rÃ©pÃ©ter que}{2}{1}
		\scbox{l'on peut faire}{gray}
		\scbox{ce que l'on veut}{black}
	\boucle{ne pas rÃ©pÃ©ter}{1}{1}
	\scbox{faux bloc}{brown}
	\blank
\scbox{dernier bloc}{pink}
\end{Scratch}
\end{center}
\newpage
%%%%%%%%%%%%%%%%%%%%%%%% 5
\begin{verbatim}
\begin{Scratch}
\beginbox{}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{19}{1}
	\scbox{costume suivant}{app}
	\scbox{arrÃªter tous les sons}{son}
	\turnbox{1}{24}
	\scbox{stylo en position d'Ã©criture}{stylo}
	\boucle{rÃ©pÃ©ter \cb[data]{compteur} fois}{10}{1}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
		\boucle{rÃ©pÃ©ter \cb[ope]{\cb[data]{A}+1} fois}{6}{1}
			\scbox{rÃ©initialiser le chronomÃ¨tre}{capt}
			\boucle{rÃ©pÃ©ter jusqu'Ã&nbsp; \hb[capt]{\rb{pointeur de souris} touchÃ©?}}{2}{1}
				\scbox{cacher la variable \rb{A}}{data}
				\scbox{avancer de 35}{mvt}
			\scbox{regroupe \rb[w]{hello}\rb[w]{world}}{ope}
		\scbox{nouveau bloc}{bloc}
	\turnbox{2}{-146}
	\scbox{estampiller}{stylo}
	\scbox{annuler les effets graphiques}{app}
\sailors{si Ã§a marche}{1}
	\scbox{je suis content}{stylo}
\simenon{1}
	\scbox{je suis dÃ©Ã§u}{app}
\end{Scratch}
\end{verbatim}

\begin{center}
\begin{Scratch}[1]%%%%%%%%%%%%%%%%%%%%%%%% 5
\beginbox{}
\boucle{rÃ©pÃ©ter \cb[w]{3} fois}{19}{1}
	\scbox{costume suivant}{app}
	\scbox{arrÃªter tous les sons}{son}
	\turnbox{1}{24}
	\scbox{stylo en position d'Ã©criture}{stylo}
	\boucle{rÃ©pÃ©ter \cb[data]{compteur} fois}{10}{1}
		\scbox{ajouter \cb[w]{20} au tempo}{son}
		\boucle{rÃ©pÃ©ter \cb[ope]{\cb[data]{A}+1} fois}{6}{1}
			\scbox{rÃ©initialiser le chronomÃ¨tre}{capt}
			\boucle{rÃ©pÃ©ter jusqu'Ã&nbsp; \hb[capt]{\rb{pointeur de souris} touchÃ©?}}{2}{1}
				\scbox{cacher la variable \rb{A}}{data}
				\scbox{avancer de 35}{mvt}
			\scbox{regroupe \rb[w]{hello}\rb[w]{world}}{ope}
		\scbox{nouveau bloc}{bloc}
	\turnbox{2}{-146}
	\scbox{estampiller}{stylo}
	\scbox{annuler les effets gRaphiques}{app}
\sailors{si Ã§a marche}{1}
	\scbox{je suis content}{stylo}
\simenon{1}
	\scbox{je suis dÃ©Ã§u}{app}
\end{Scratch}
\end{center}

\newpage
%----------------------------------------------------------------------------------------------------------------------------------%
%----------------------------------------------------------------------------------------------------------------------------------%
\section{Conclusion}

Please feel free to leave a comment:

Thibault.Ralet\at ac-clermont.fr.

Thank you!

\end{document}
%%
%% This is file `ScratchX.sty',
%%
%% Copyright (C) Thibault Ralet - Thibault.Ralet@ac-clermont.fr
%%
%% 16 mars 2017 (version 0.1) - 27 juillet 2017 (version 1.1)
%% 
%% the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt
%%
%% Unlimited copying and redistribution of this file are permitted as
%% long as this file is not modified.  Modifications, and distribution
%% of modified versions, are permitted, but only if the resulting file
%% is renamed.</pre></body></html>