[Tex/LaTex] Line Arrows for Tabular Integration Table

tablestikz-pgf

I've recently reviewed this question to try to make a table for Integration by parts:

Tabular integration by parts

I tried using the code sample from it but LaTeX gives me a rendering error with the tikz arrows (and I don't know what it was so I just removed the tikz code entirely); however, it does not when I just use the table. My code is below:

    \documentclass{article}
    \usepackage{gensymb}
    \usepackage{graphicx}
    \usepackage[fleqn]{amsmath}
    \usepackage{amsfonts}
    \usepackage{amssymb}
    \usepackage[usenames,dvipsnames]{color}
    \usepackage{fullpage}
    \usepackage{cancel}
    \usepackage{easylist}
    \usepackage{booktabs}
    \usepackage{xparse}
    \usepackage{graphicx}
    \usepackage{tikz}
    \usepackage{framed} 
    \usepackage{tcolorbox}
    \usepackage[fleqn]{amsmath}
    \usepackage{framed,varwidth}
    \usepackage{enumitem, color, amssymb}
    \providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}
    \begin{document}
    1. $\displaystyle{\int x^6\cdot e^x dx}$ \\
    \newline
    Make a table of u and its derivatives \& dv and its integrals...
   \[\renewcommand{\arraystretch}{1.5}
\begin{array}{c @{\hspace*{1.0cm}} c}\toprule
   D & I \\\cmidrule{1-2}
 x^6\tikzmark{Left 1} & \tikzmark{Right 1}e^x \\
  6x^5\tikzmark{Left 2} & \tikzmark{Right 2}e^x \\
  30x^4 \tikzmark{Left 3} & \tikzmark{Right 3}e^x \\
 120x^3  \tikzmark{Left 4} & \tikzmark{Right 4}e^x \\
 360x^2 \tikzmark{Left 5} & \tikzmark{Right 5} e^x \\
 720x \tikzmark{Left 6} & \tikzmark{Right 6} e^x \\
 720 \tikzmark{Left 7} & \tikzmark{Right 7} e^x \\
 0 \tikzmark{Left 8} & \tikzmark{Right 8} e^x \\\bottomline
\end{array}
\]

\DrawArrow{Left 1}{Right 2}{$+$}
\DrawArrow{Left 2}{Right 3}{$-$}
\DrawArrow{Left 3}{Right 4}{$+$}
\DrawArrow{Left 4}{Right 5}{$-$}
\DrawArrow{Left 5}{Right 6}{$+$}
\DrawArrow{Left 6}{Right 7}{$-$}
\DrawArrow{Left 7}{Right 8}{$+$}
\end{document}

Is there an alternative to the post I linked to make the arrows & the plus or minus signs?

Best Answer

Here is the corrected version of your code:

enter image description here

Changes:

  1. Included the required \tikzmark, \DrawArrow and related macros from the linked question and eliminated the unnecessary packages.
  2. Used enumerate to number it -- am assuming that there may be more.
  3. Added trailing % following the calls to \DrawArrow.
  4. Used \dots instead of ....
  5. Replaced \bottomrule with \bottomline.

References:

Code:

\documentclass{article}
\usepackage{booktabs}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}
    
\tikzset{Arrow Style/.style={text=black, font=\boldmath}}

\newcommand{\tikzmark}[1]{%
    \tikz[overlay, remember picture, baseline] \node (#1) {};%
}
\newcommand*{\XShift}{0.5em}
\newcommand*{\YShift}{0.5ex}
\NewDocumentCommand{\DrawArrow}{s O{} m m m}{%
    \begin{tikzpicture}[overlay,remember picture]
        \draw[->, thick, Arrow Style, #2] 
                ($(#3.west)+(\XShift,\YShift)$) -- 
                ($(#4.east)+(-\XShift,\YShift)$)
        node [midway,above] {#5};
    \end{tikzpicture}%
}

\begin{document}
\begin{enumerate}
    \item $\displaystyle{\int x^6\cdot e^x dx}$
    
    Make a table of $u$ and its derivatives \& $\mathrm{d}v$ and its integrals\dots
   \[\renewcommand{\arraystretch}{1.5}
    \begin{array}{c @{\hspace*{1.0cm}} c}\toprule
       D & I \\\cmidrule(lr){1-2}
       x^6  \tikzmark{Left 1} & \tikzmark{Right 1} e^x \\
      6x^5  \tikzmark{Left 2} & \tikzmark{Right 2} e^x \\
      30x^4 \tikzmark{Left 3} & \tikzmark{Right 3} e^x \\
     120x^3 \tikzmark{Left 4} & \tikzmark{Right 4} e^x \\
     360x^2 \tikzmark{Left 5} & \tikzmark{Right 5} e^x \\
     720x   \tikzmark{Left 6} & \tikzmark{Right 6} e^x \\
     720    \tikzmark{Left 7} & \tikzmark{Right 7} e^x \\
       0    \tikzmark{Left 8} & \tikzmark{Right 8} e^x \\\bottomrule
    \end{array}%
    \]
    % --------
    \DrawArrow{Left 1}{Right 2}{$+$}% <-- Don't forget there.
    \DrawArrow{Left 2}{Right 3}{$-$}%
    \DrawArrow{Left 3}{Right 4}{$+$}%
    \DrawArrow{Left 4}{Right 5}{$-$}%
    \DrawArrow{Left 5}{Right 6}{$+$}%
    \DrawArrow{Left 6}{Right 7}{$-$}%
    \DrawArrow{Left 7}{Right 8}{$+$}%
\end{enumerate}
\end{document}
Related Question