如何用 tikz 改变这些公式?

如何用 tikz 改变这些公式?

我想修改我的脚本,以获得类似于图片中发布的结果。

\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}

在此处输入图片描述

答案1

这是让tikz创造土豆的一次尝试。

\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}

编辑我根据要求调整了小页面的位置,并添加了更多下划线,并使箭头弯曲。如果您想知道节点的标签以便绘制更多箭头,您可以临时重新定义 ovalnode 命令以打印标签,例如,作为上标。

第二次(希望也是最后一次)编辑我把土豆移得离分数线稍远一点。(我开始清理代码,即删除空行和一个实例\usepackage{tikz},并重新组合前言。此代码仍然包含许多不必要的包。)更重要的是,我给节点起了更好的名字,在以前的版本中它们只有数字,这很容易与其他包中的其他节点发生冲突。我还引入了一个新的 if \ifshowmarmotlabels,允许人们确定节点的名称。请注意,由于某种原因,该\overset命令会移动节点编号。

在此处输入图片描述

相关内容