0

I'm currently trying to add arrows in my synthetic division example to show people clearly how synthetic division works. I'm working on Overleaf.

The code for my synthetic division right now is:

\begin{tabular}{c |r r r r r} 


 &1& 4 & -1&16&-20\\


1&& 1 & 5 & 4&20\\


\hline 


&1 &5 & 4 & 20 &\rule{3pt}{16pt}\;0\\


\end{tabular}

How would I add arrows to this? For instance, a down arrow going from the first 1 to 1, then an upwards arrow pointing right from 1 to 1, then an arrow pointing down from 1 to 5, etc. Basically I would like to add arrows that look like this:

enter image description here

  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See minimal working example (MWE). – Henri Menke Oct 1 '17 at 1:14
  • Possible duplicate of this? tex.stackexchange.com/a/248456/226 – LianTze Lim Oct 1 '17 at 3:14
3

I think this is more or less what you're looking for:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{arrows.meta}
\colorlet{mycolor}{pink!50!red}

\tikzset{
    mynode/.style={
        draw, circle, 
        #1, 
        dashed, very thick,
        align=center,
        text=black,
        inner sep=0pt 
        }
}

\begin{document}
\begin{tikzpicture}
\matrix[matrix of nodes,column sep=0pt,
    column sep=4pt,
    row 1/.style={nodes={mynode={white}}},
    row 3/.style={nodes={mynode={mycolor}}},
    nodes={text width=width{-20}},
    ] (M) {
    & 1 & \phantom{-}5 & \phantom{-}4 &[4pt] \phantom{-}20\\
    |[mynode={white}]|-5 &   & |[mynode={mycolor}]|-5 & |[mynode={mycolor}]|-5  & |[mynode={mycolor}]|-20\\[2ex]
    & 1 & 0 & 4 & 0\\
    };
\draw ([yshift=-2ex]M-2-1.south west) -- ([shift={(2pt,-2ex)}]M-2-5.south east);
\draw ([xshift=-8pt]M-1-2.north west) -- ([shift={(-8pt,-1ex)}]M-3-2.south west);
\draw[thick] ([shift={(-7pt,1.5ex)}]M-3-5.north west) -- ([shift={(-7pt,-1ex)}]M-3-5.south west);

\begin{scope}[ shorten >=1pt, shorten <=1pt, 
mycolor, -Stealth]
\draw (M-1-2) -- (M-3-2);
\draw (M-3-2) -- (M-2-3);
\draw (M-2-3) -- (M-3-3);
\draw (M-3-3) -- (M-2-4);
\draw (M-2-4) -- (M-3-4);
\draw (M-3-4) -- (M-2-5);
\draw (M-2-5) -- (M-3-5);
\end{scope}
\end{tikzpicture}   
\end{document}

enter image description here

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.