6

I would like to modify my script, in order to obtain a similar result like the one posted in the picture.

\documentclass[a4paper,12pt]{article}[12pt] 


\usepackage[italian]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage{anysize}
\usepackage{graphicx}
\usepackage{float}
\usepackage{etoolbox}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx} 
\usepackage{booktabs} 
\usepackage{multirow} 
\usepackage{longtable} 
\usepackage{natbib} 
\usepackage{tikz}




\usepackage{subfig}                         

\usepackage{xcolor}



\usepackage{amsmath}
\usepackage{amssymb} 
\usepackage{mathrsfs} 

\usepackage{textcomp} 

\linespread{1.4}                



\frenchspacing 

\newcommand{\abs}[1]{\lvert#1\rvert}

\usepackage{floatflt,epsfig}

\usepackage{multicol}




  \usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}


   \renewcommand{\rmdefault}{phv}
   %\usepackage{mathpple}
   %\usepackage{palatino}

   \usepackage{lxfonts}
%   
%   \usepackage{multicol}







 \usepackage{pifont}
 \usepackage{lipsum}

 \usepackage{tikz}

 \usepackage{bbding}

 \newcommand{\cuthere}{%
 \noindent
 \raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}
 \unskip{\tiny\dotfill}
 }




 \newcommand\yellowbigsqcup[1][\displaystyle]{%
   \fboxrule0pt
   \ifx#1\textstyle\fboxsep-0.6pt\else\fboxsep-1.25pt\fi
   \mathrel{\fcolorbox{white}{yellow}{$#1\bigsqcup$}}}



   \newcommand{\makenonemptybox}[2]{%
     \par\nobreak\vspace{\ht\strutbox}\noindent
     \fbox{%
       \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
         \hrule width \hsize height 0pt
         #2
       }%
     }%
     \par\vspace{\ht\strutbox}
   }

\begin{document}

\begin{enumerate}


\begin{minipage}{.4\linewidth}
\item $ \dfrac{17}{\colorbox{yellow}{5}}+\dfrac{13}{\colorbox{orange}{6}}-\dfrac{11}{\colorbox{pink}{30}} = \\
\\ \\ \\=\dfrac{17 \cdot 6 +13 \cdot 5 -11  \cdot 1}{\colorbox{green}{30}} \\
\\ \\ \\=\dfrac{\text{\dots\dots} +\text{\dots\dots}- \text{\dots\dots}}{\colorbox{green}{30}} 
\\ \\ \\ =  \dfrac{\text{\dots\dots}}{30} =   \dfrac{\text{\dots\dots}}{\text{\dots\dots}}  \\ $
 \end{minipage}%
\begin{minipage}{.5\linewidth}
$ \text{m.c.m.}\left(5,6,30\right) =\colorbox{green}{30} \\
$\[\begin{pmatrix}
%prima riga
\colorbox{green}{30}:\textbf{\colorbox{yellow}{5}}=\colorbox{yellow}{\text{6};}
& \colorbox{green}{30}:\textbf{\colorbox{orange}{6}}=\colorbox{orange}{5};
& \colorbox{green}{30}:\textbf{\colorbox{pink}{30}}=\textbf{\colorbox{pink}{1}};  \\
%%seconda riga
%15 \cdot 1 = 15 
%& \text{\dots}\cdot 2 = \text{\dots}
%& \text{\dots}\cdot \text{\dots} = \text{\dots}
\end{pmatrix}\]$
$
\end{minipage}            


\end{enumerate}


\end{document}

enter image description here

4
  • 1
    Regular, green and yellow potatoes. ;-) – Przemysław Scherwentke Dec 8 '17 at 16:08
  • @PrzemysławScherwentke Why are orange and pink potatoes regular? – user121799 Dec 8 '17 at 16:59
  • @marmot They looked for me more brown than orange. :-) – Przemysław Scherwentke Dec 9 '17 at 0:19
  • @PrzemysławScherwentke Now I'm relieved. I started believing I'm eating the wrong potatoes ;-) – user121799 Dec 9 '17 at 0:31
10

Here is an attempt to let tikz create potatoes.

\documentclass[a4paper,12pt]{article}[12pt] 
\usepackage[italian]{babel} 
\usepackage[T1]{fontenc} 
\usepackage[utf8]{inputenc} 
\usepackage{anysize}
\usepackage{graphicx}
\usepackage{float}
\usepackage{etoolbox}
\usepackage{amsbsy}
\usepackage{amsmath}
\usepackage{pbox}
\usepackage{fancyhdr}
\usepackage{cancel}
\usepackage{tabularx} 
\usepackage{booktabs} 
\usepackage{multirow} 
\usepackage{longtable} 
\usepackage{natbib} 
\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{subfig}                         
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage{amssymb} 
\usepackage{mathrsfs} 
\usepackage{textcomp} 
\usepackage{floatflt,epsfig}
\usepackage{multicol}
\usepackage[a4paper,top=1.0cm,bottom=1.0cm,left=1.0cm,right=1.0cm]{geometry}
\usepackage{lxfonts}
\usepackage{pifont}
\usepackage{lipsum}
\usepackage{bbding}
%
\linespread{1.4}                
\frenchspacing 
\newcommand{\abs}[1]{\lvert#1\rvert}
\renewcommand{\rmdefault}{phv}
\newcommand{\cuthere}{%
 \noindent
 \raisebox{-2.8pt}[0pt][0.75\baselineskip]{\small\ding{34}}
 \unskip{\tiny\dotfill}
 }
% marmot code
\newif\ifshowmarmotlabels
\showmarmotlabelstrue
\showmarmotlabelsfalse % comment this line out if you want so see the labels
\newcounter{mynode}\setcounter{mynode}{0}
\newcommand{\ovalnode}[2]{
    \stepcounter{mynode}
    \tikz[remember picture,baseline=(marmotnode\themynode.base),inner sep=0pt]{%
    \node[ellipse,fill=#1,inner sep=2pt] (marmotnode\themynode) 
    {#2\ifshowmarmotlabels{$^{\themynode}$}\else\fi};}
    }
\newcommand{\underdots}[1]{%
\ifmmode{\underset{\boldsymbol{\scriptscriptstyle\bullet\,\bullet\,\bullet}}{#1}}
\else{$\underset{\boldsymbol{\scriptscriptstyle\bullet\,\bullet\,\bullet}}{\text{#1}}$}
\fi}
% end marmot code
\newcommand\yellowbigsqcup[1][\displaystyle]{%
   \fboxrule0pt
   \ifx#1\textstyle\fboxsep-0.6pt\else\fboxsep-1.25pt\fi
   \mathrel{\fcolorbox{white}{yellow}{$#1\bigsqcup$}}}
\newcommand{\makenonemptybox}[2]{%
     \par\nobreak\vspace{\ht\strutbox}\noindent
     \fbox{%
       \parbox[c][\dimexpr#1-2\fboxsep][t]{\dimexpr\linewidth-2\fboxsep}{
         \hrule width \hsize height 0pt
         #2
       }%
     }%
     \par\vspace{\ht\strutbox}
   }
%
\begin{document}
\begin{enumerate}
\hspace*{-1cm}% I moved the things to the left such that they fit better.
\begin{minipage}[t]{.4\linewidth}
\item $ \dfrac{17}{\overset{~}{\ovalnode{yellow}{5}}}
+\dfrac{13}{\overset{~}{\ovalnode{orange}{6}}}-
\dfrac{11}{\overset{~}{\ovalnode{pink}{30}}} = \\
\\ \\ \\=\dfrac{17 \cdot 6 +13 \cdot 5 -11\cdot 1}{%
\overset{~}{\ovalnode{green}{\underdots{30}}}} \\
\\ \\ \\=\dfrac{\text{\dots\dots} -\text{\dots\dots}+
\text{\dots\dots}}{\overset{~}{\ovalnode{green}{\underdots{30}}}}
\\ \\ \\ =  \dfrac{\text{\dots\dots}}{30} =   
\dfrac{\text{\dots\dots}}{\text{\dots\dots}}  \\ $
 \end{minipage}%
 \hspace*{-1cm}%
\begin{minipage}[t]{.5\linewidth}
$ \text{m.c.m.}\left(5,6,30\right) =\ovalnode{green}{\underdots{30}} \\
$\[\begin{pmatrix}
%prima riga
\ovalnode{green}{\underdots{30}}:\ovalnode{yellow}{\underdots{\textbf{5}}}
=\ovalnode{yellow}{\underdots{\text{6}}};
& \ovalnode{green}{\underdots{30}}:\ovalnode{orange}{\underdots{\textbf{6}}}
=\ovalnode{orange}{\underdots{5}};
& \ovalnode{green}{\underdots{30}}:\ovalnode{pink}{\underdots{\textbf{30}}}
=\ovalnode{pink}{\underdots{\textbf{1}}};  \\
\end{pmatrix}\]
\tikz[overlay,remember picture]{%
\draw[->,thick] (marmotnode16) to[out=-135, in=45] (marmotnode17);
\draw[->,thick] (marmotnode16) to[out=-90, in=90] (marmotnode20);
\draw[->,thick] (marmotnode16) to[out=-45, in=135] (marmotnode23);}
\end{minipage}            
\end{enumerate}
\end{document}

EDIT I adjusted the positions of the minipages, as requested, and added more underdots, and made the arrows curved. If you want to know the labels of the nodes in order to draw more arrows, you may temporarily redefine the ovalnode command to also print the label, say, as a superscript.

2nd (and hopefully final) EDIT I moved the potatoes a bit further away from the fraction lines. (And I started cleaning up the code, i.e. removed empty lines and one instance of \usepackage{tikz}, and regrouped the preamble. This code still contains a lot of unnecessary packages.) More importantly, I gave the nodes somewhat nicer names, in the previous version they had just numbers, and this may easily collide with other nodes from other packages. I also introduced a new if \ifshowmarmotlabels that allows one to determine the names of the nodes. Notice that for some reason the \overset command shifts the node numbers.

enter image description here

5
  • Thank you very much for your help. I would like to put the dots under and I'll do as you did ($\underset{\boldsymbol{\cdots}}{\textbf{30}}$). How can I move the tikz image at the top instead of the centre? – ryuk Dec 8 '17 at 16:43
  • 1
    @ryuk Just change both \begin{minipage} to \begin{minipage}[t]. Will look at the dots later... – user121799 Dec 8 '17 at 16:57
  • how to increase the distance between denominator and fraction line? (see the pic) thanks – ryuk Dec 8 '17 at 20:26
  • 3
    @ryuk Done. Notice that, as you can easily see from my profile picture, I am very small and fluffy, so I am very slow when typing. Therefore I'd appreciate it very much if you could make further requests in the form of new questions. ;-) – user121799 Dec 8 '17 at 21:11
  • 1
    @ryuk If the solution worked for you please see How do you accept an answer? and perhaps How does accepting an answer work?. – user121799 Dec 8 '17 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.