[Tex/LaTex] Draw a long arrow next to multiple rows of tabular

multirowtables

I have the following table which I use to teach limits in calculus class (don't worry if you don't know what that is)

\begin{tabular}{l|l}
  \bm{x}  & \bm{h(x)} \\
  \hline
    1.9    & 3.61   \\
    1.99   & 3.9601 \\
    1.999  & 3.9960 \\
    1.9999 & 3.9996 \\
    \hline
    2.0001 & 4.0004 \\
    2.001  & 4.004  \\
    2.01   & 4.0401 \\
    2.1    & 4.41   \\
    \hline
\end{tabular}

In class I point out that the numbers in the left column get closer to 2 as we got down the column by drawing an arrow down to the left of the first column for four rows and writing "2" at the bottom of it (except that I can't draw on screens).

I also point out that the bottom half of the table, left side, gets closer to 2 as we go up by drawing an arrow up the rows (to their left).

The right column gets closer to 4 and I point that out (or would if I could draw on the screen) by drawing a down arrow to the right of the right column, etc.

How can I draw an arrow over multiple rows to the right or left of those columns to show the numbers progression?

Best Answer

enter image description here

\documentclass{article}

\let\bm\textbf

\usepackage{tikz}
\usetikzlibrary{tikzmark,calc}

\begin{document}

\begin{tabular}{cl|lc}
  &\bm{x}  & \bm{h(x)} \\
  \cline{2-3}
    \tikzmark{a}&1.9    & 3.61&\tikzmark{aa}   \\
    &1.99   & 3.9601& \\
    &1.999  & 3.9960 &\\
    \tikzmark{b}&1.9999 & 3.9996&\tikzmark{bb} \\
    \cline{2-3}
    &2.0001 & 4.0004& \\
    &2.001  & 4.004 & \\
    &2.01   & 4.0401& \\
    \tikzmark{c}&2.1    & 4.41&\tikzmark{cc}   \\
    \cline{2-3}
\end{tabular}

\begin{tikzpicture}[overlay,remember picture]
\draw[->,line width=3pt, color=red] ($(pic cs:a)+(0pt,.5ex)$) to ($(pic cs:b)+(0pt,-.1ex)$);
\node[color=red] at ($(pic cs:b)+(0pt,-1ex)$) {\Large 2};
\draw[->,line width=3pt, color=red] ($(pic cs:c)+(0pt,.5ex)$) to ($(pic cs:b)+(0pt,-2.5ex)$);

\draw[->,line width=3pt, color=red] ($(pic cs:aa)+(0pt,.5ex)$) to ($(pic cs:bb)+(0pt,-.1ex)$);
\node[color=red] at ($(pic cs:bb)+(0pt,-1ex)$) {\Large 4};
\draw[->,line width=3pt, color=red] ($(pic cs:cc)+(0pt,.5ex)$) to ($(pic cs:bb)+(0pt,-2.5ex)$);

\end{tikzpicture}

\end{document}