1

How can I draw the diagram in top left of the following image in latex?

enter image description here

  • By "top left" you mean the "ladder-like structure" only? – Werner Jul 22 '15 at 19:40
3

Some arrays and the tikzmark library:

enter image description here

The code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,shapes.geometric,fit}

\newcommand\AddSpa[2][6pt]{\hspace{#1}#2\hspace{#1}}

\begin{document}

\[
\begin{array}{@{}c@{}}
\begin{array}[t]{c|l} 
2 & 12 \\ 
\hline 
2 & 6 \\ 
\hline 
3 & 3 \\ 
\hline 
& 1 
\end{array}\qquad
\begin{array}[t]{c|l} 
3 & 15 \\ 
\hline 
5 & 5\\ 
\hline 
& 1 
\end{array}\qquad
\begin{array}[t]{c|l} 
2 & 18 \\ 
\hline 
3 & 9 \\ 
\hline 
3 & 3 \\ 
\hline 
& 1 
\end{array}
\\[2cm]
\begin{array}{c@{\AddSpa{=}}c@{\AddSpa{\times}}c@{\AddSpa{\times}}c}
12 & \tikzmark{startcol1}2 & 2 & \tikzmark{startcol2}3 \\
15 &  \multicolumn{1}{c}{}& 5 & 3 \\
18 & \tikzmark{endcol1}2 & 3 & \tikzmark{endcol2}3 \\
\end{array}
\end{array}
\]

\begin{tikzpicture}[remember picture,overlay]
\coordinate (aux1) at ([xshift=6pt,yshift=4pt]{pic cs:startcol1});
\coordinate (aux2) at ([xshift=6pt,yshift=4pt]{pic cs:startcol2});
\node[inner ysep=1pt,inner xsep=2pt,draw,ellipse,fit={(aux1) (pic cs:endcol1)}] {};
\node[inner ysep=1pt,inner xsep=2pt,draw,ellipse,fit={(aux2) (pic cs:endcol2)}] {};
\end{tikzpicture}

\end{document}

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.