2

I want to draw this:

enter image description here

Till now I am able to draw this much but struggling with red arrows

\documentclass{article} 
\usepackage{etoolbox}
\begin{document}
\begin{center}
\begin{tabular}{ |c|c|c|c|c|c|c|c| } 
\hline
 3 & 4 & 2 & 1 & 4 & 1 & 2 & 3  \\
\hline
\hline 
\end{tabular}
\end{center}
\end{document}
7

If you accept a pure TikZ solution:

\documentclass[tikz,border=2mm]{standalone} 
\usetikzlibrary{positioning,matrix, arrows.meta}

\begin{document}
\begin{tikzpicture}
\matrix (A) [matrix of nodes, nodes={draw, minimum size=8mm},
    column sep=-\pgflinewidth]{
    3 & 4 & 2 & 1 & 4 & 1 & 2 & 3\\};
\foreach \i [evaluate=\i as \ni using {int(\i)},
                evaluate=\i as \ntext using {int(\i-1)}] in {1,3,4,6} 
    \draw [{Stealth}-, red!70] (A-1-\ni.south west)--++(-90:5mm) node[below] {\ntext};
\end{tikzpicture}
\end{document}

enter image description here

  • In beamer class it is giving error how to fix it for beamer class – new_born Nov 20 '17 at 15:39
  • it works with beamer as expected: just replace first code line with \documentclass{beamer} \usepackage{tikz} – Zarko Nov 20 '17 at 15:43
  • 3
    @new_born Works with beamer. Add [fragile] option to frame containing this matrix or add ampersand replacement=\& into matrix options and replace all & with \&. Next time, inform us that you want to use beamer: it's an important information. – Ignasi Nov 20 '17 at 16:05

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.