0

I would like to insert a array (e.g. a stencil) inside an array (e.g. a tabular), in a cell next to the formula. Is there a way to do it?

\documentclass[a4paper, 12pt]{book}
\usepackage{amssymb, amsmath,mathtools, tikz}

\newcommand{\stencilpt}[4][]{\node[circle,draw,inner sep=0.1em,minimum size=0.8cm,font=\tiny,#1] at (#2) (#3) {#4}}

\begin{document}

\begin{center}
    \begin{tabular}{ |l|c| }  
        \hline
        backward approximation & $f'(t) \approx \frac{f(t) - f(t-h)}{h}+ O(h)$\\ \hline 
    \end{tabular}
\end{center}

\begin{tikzpicture}
\stencilpt{ 0,0}{i}  {$\frac{-1}{h}$};
\stencilpt{ 1,0}{i+1}{$\frac{1}{h}$};
\draw
(i)   -- (i+1);
\end{tikzpicture}
\end{document}

enter image description here

1 Answer 1

1

Add a new column to the tabular preamble and put the tikzpicture environment in the appropriate cell:

\documentclass[a4paper, 12pt]{book}
\usepackage{amssymb, amsmath,mathtools, tikz}

\newcommand{\stencilpt}[4][]{\node[circle,draw,inner sep=0.1em,minimum size=0.8cm,font=\tiny,#1] at (#2) (#3) {#4}}

\begin{document}

\begin{center}
    \begin{tabular}{|l |l|c| }  
        \hline
        backward approximation & $f'(t) \approx \frac{f(t) - f(t-h)}{h}+ O(h)$ &\begin{tikzpicture}[baseline=(i)]
\stencilpt{ 0,0}{i}  {$\frac{-1}{h}$};
\stencilpt{ 1,0}{i+1}{$\frac{1}{h}$};
\draw
(i)   -- (i+1);
\end{tikzpicture}\\ \hline 
    \end{tabular}
\end{center}


\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .