# Usage of Tabular method for Integration by Parts

By using nice threads e.g. this and this we find out how the method could be visible in a text. I did the following MWE to do it again:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage{tikz}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\usepackage[warnings-off={mathtools-colon,mathtools-overbracket}]{unicode-math}
\usepackage[computeautoilg=off]{xepersian}
\settextfont[Scale=1.1]{IRXLotus}
\ExplSyntaxOn
\cs_set_eq:NN
\etex_iffontchar:D
\tex_iffontchar:D
\cs_undefine:N \c_one
\int_const:Nn \c_one { 1 }
\ExplSyntaxOff
\setmathfont[Scale=0.85]{Latin Modern Math}
\setmathfont{Cambria Math}[range={\int}, Scale=MatchUppercase ]
\newcommand{\rn}[2]{%% "rn": "remember node"
\tikz[remember picture,baseline=(#1.base)]\node [inner sep=0] (#1){$#2$};}
\begin{document}
\begin{align*}
\int t^2\sin tdt&=~~{\footnotesize\begin{matrix}
\rn{11}{t^2~} & \vrule& \sin tdt&&\\
\hline
\rn{21}{2t~} & \vrule& \rn{23}{~-\cos t~~}&&\rn{24}{~}\\
\hline
\rn{31}{2~} & \vrule& \rn{33}{-\sin t~~}&&\hspace*{-0.2cm}\rn{34}{{\oplus}}\\
\hline
0 & \vrule& \rn{43}{\cos t~}&&\hspace*{-0.2cm}\rn{44}{\ominus}\\
& & &&\hspace*{-0.2cm}\rn{54}{\oplus}
\end{matrix}}\\
&=
t^2(-\cos t)+2t\sin t +\cos t\\
&=-t^2\cos t+2t\sin t +\cos t.
\end{align*}
\begin{tikzpicture}[overlay,remember picture]
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (21) -- (44) ;
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (31) -- (54) ;
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (11) -- (34) ;
\end{tikzpicture}
\end{document}


How to make the functions bring forward so that the arrows will be back of them? Play with 'opacity' did not work as I had expected! Thanks for any help!

• Take a look at nicematrix which allows to do that very easily. Commented Aug 4 at 12:31
• I think you don't want to write the dt after sin(t). Commented Aug 4 at 12:31
• And I think you also lost a coefficient "2" before the last term. Commented Aug 5 at 14:37
• @BenjaminMcKay Thanks for saying so. I did it for someone as he wanted and I had already told him that this notation is not mathematically standard. Commented Aug 7 at 6:55

Add the option blend mode=multiply to the overlay environment.

 \end{align*}
\begin{tikzpicture}[overlay,remember picture,blend mode=multiply]% <<<<<<<<<
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (21) -- (44) ;


\documentclass[a4paper,12pt,twoside]{book}
\usepackage{tikz}
\usepackage{amsmath,amssymb,amsthm,amsfonts}
\newcommand{\rn}[2]{%% "rn": "remember node"
\tikz[remember picture,baseline=(#1.base)]\node [inner sep=0] (#1){$#2$};}
\begin{document}
\begin{align*}
\int t^2\sin tdt&=~~{\footnotesize\begin{matrix}
\rn{11}{t^2~} & \vrule& \sin tdt&&\\
\hline
\rn{21}{2t~} & \vrule& \rn{23}{~-\cos t~~}&&\rn{24}{~}\\
\hline
\rn{31}{2~} & \vrule& \rn{33}{-\sin t~~}&&\hspace*{-0.2cm}\rn{34}{{\oplus}}\\
\hline
0 & \vrule& \rn{43}{\cos t~}&&\hspace*{-0.2cm}\rn{44}{\ominus}\\
& & &&\hspace*{-0.2cm}\rn{54}{\oplus}
\end{matrix}}\\
&=
t^2(-\cos t)+2t\sin t +\cos t\\
&=-t^2\cos t+2t\sin t +\cos t.
\end{align*}
\begin{tikzpicture}[overlay,remember picture,blend mode=multiply]
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (21) -- (44) ;
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (31) -- (54) ;
\draw [-stealth,line width=4pt, gray!35, opacity=0.6] (11) -- (34) ;
\end{tikzpicture}
\end{document}


With opacity you would need to introduce a transparency group so that the arrow tip and the line look like one.

I try to draw the lines below the matrix.

With your code, this can be achieved via the shipout/background hook:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage{tikz}
\usepackage{amsmath}
\newcommand{\rn}[2]{%% "rn": "remember node"
\tikz[remember picture,baseline=(#1.base)]
\node[inner sep=+0pt, outer sep=+.3333em](#1){$#2$};}
\begin{document}
\begin{align*}
\int t^2 \sin tdt & =~~
\begin{matrix}
\rn{11}{t^2} & \vrule & \sin tdt         &  &                                   \\ \hline
\rn{21}{2t}  & \vrule & \rn{23}{-\cos t} &  &                                   \\ \hline
\rn{31}{2}   & \vrule & \rn{33}{-\sin t} &  & \hspace*{-0.2cm}\rn{34}{{\oplus}} \\ \hline
0            & \vrule & \rn{43}{\cos t}  &  & \hspace*{-0.2cm}\rn{44}{\ominus}  \\
&        &                  &  & \hspace*{-0.2cm}\rn{54}{\oplus}
\end{matrix}\\
& = t^2(-\cos t)+2t\sin t +\cos t\\
& =-t^2\cos t+2t\sin t +\cos t.
\end{align*}
\begin{tikzpicture}[overlay,remember picture]
\draw [-stealth, line width=4pt, gray!35] (21) -- (44) ;
\draw [-stealth, line width=4pt, gray!35] (31) -- (54) ;
\draw [-stealth, line width=4pt, gray!35] (11) -- (34) ;
\end{tikzpicture}}
\end{document}


With the tikzmark library, the arrows can literally be drawn before the matrix will be typeset by drawing them with the first node since it has the ability to save nodes for the next compilation run.

\documentclass[a4paper,12pt,twoside]{book}
\usepackage{tikz}\usetikzlibrary{tikzmark}
\usepackage{amsmath}
\newcommand*\rn[3][]{% "rn": "remember node"
\begingroup % https://tex.stackexchange.com/a/685722/16595
\tikzset{every tikzmarknode picture/.append style=save nodes to file}%
\tikzmarknode[outer sep=+.3333em,save node,anchor=center,#1]{#2}{#3}%
\endgroup
}
\newcommand*\rnconn[3]{%
\rn[append after command={[overlay]edge[-stealth, line width=4pt, gray!35]
(\iftikzmark{#3-d}{#3-d}{\iftikzmark{#3-t}{#3-t}{%
\iftikzmark{#3-s}{#3-s}{\iftikzmark{#3-ss}{#3-ss}{0pt,0pt}}}})}]{#1}{#2}}
\tikzset{restore nodes from file}
\begin{document}
\begin{align*}
\int t^2 \sin tdt & =~~
\begin{matrix}
\rnconn{11}{t^2}{34} & \vrule & \sin tdt         &  &                                   \\ \hline
\rnconn{21}{2t}{44}  & \vrule & \rn{23}{-\cos t} &  &                                   \\ \hline
\rnconn{31}{2}{54}   & \vrule & \rn{33}{-\sin t} &  & \hspace*{-0.2cm}\rn{34}{{\oplus}} \\ \hline
0                    & \vrule & \rn{43}{\cos t}  &  & \hspace*{-0.2cm}\rn{44}{\ominus}  \\
&        &                  &  & \hspace*{-0.2cm}\rn{54}{\oplus}
\end{matrix}\\
& = t^2(-\cos t)+2t\sin t +\cos t\\
& =-t^2\cos t+2t\sin t +\cos t.
\end{align*}
\end{document}


Here is a solution with {NiceArray} of nicematrix. That environment is similar to the classical environment {array} (as defined by the package array) but creates also PGF/TikZ nodes under the cells. With the so-called \CodeBefore, it's possible to use these nodes before the construction of the main array. Thus, you don't need transparency.

However, you need several compilations.

\documentclass{article}
\usepackage{nicematrix,tikz}

\begin{document}

$\begin{NiceArray}{w{c}{1cm}|w{c}{15mm}c} \CodeBefore [create-cell-nodes] \begin{tikzpicture} [-stealth,line width=4pt, gray!35] \draw (1-1) -- (3-3) ; \draw (2-1) -- (4-3) ; \draw (3-1) -- (5-3) ; \end{tikzpicture} \Body t^2 & \sin t d t \\ \Hline 2t & -\cos t & \\ \Hline 2 & -\sin t & \oplus \\ \Hline 0 & \cos t & \ominus \\ \Block{1-3}{} % to prevent the vertical rule in the last row & & \oplus \\ \end{NiceArray}$

\end{document}


• Many thanks for the time! Commented Aug 5 at 11:21