5

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?

cbutcher12
  • 177
  • 1
  • 9
  • Er... well... what error? If this is due to differing versions of PGF, one alternative (to not having arrows) is to (1) update the code or (2) update your system (whichever is applicable). – cfr Feb 01 '15 at 01:28
  • Are all those packages really necessary to help you? Will I not be able to reproduce the problem if I don't have them all installed? [It surely isn't necessary to load half of them twice, in any case.] – cfr Feb 01 '15 at 01:28
  • I can edit my post to include all my code so it can be rendered but it'll be a little more lengthier...it must be clashing with something else in my document. Would you like the full code? – cbutcher12 Feb 01 '15 at 01:29
  • 1
    No. We need a minimal working example (MWE) that illustrates your problem. Note that there is a second solution using pstricks. So that's another alternative. Also, tikzmark is now available as a TiKZ library. – cfr Feb 01 '15 at 01:32
  • I used the code from the previous example and rendered it again and it worked so must be a typo on my part...however, I wanted to add more to the chart so I changed the code to compensate and I've edited my post but now I'm getting an error again. Could you advise? – cbutcher12 Feb 01 '15 at 01:44
  • Never mind, the \bottomline was giving me an error...I removed it and it rendered fine. – cbutcher12 Feb 01 '15 at 02:11
  • 1
    Probably you wanted \bottomrule? – cfr Feb 01 '15 at 02:12

2 Answers2

7

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}

Peter Grill
  • 223,288
1

With {NiceArray} of nicematrix and Tikz.

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

\begin{document} [\renewcommand{\arraystretch}{1.5} \begin{NiceArray}{@{\hspace{1em}}c @{\hspace*{1.0cm}}c@{\hspace{1em}}}[create-medium-nodes] \toprule D & I \ \cmidrule(lr){1-2} x^6 & e^x \ 6x^5 & e^x \ 30x^4 & e^x \ 120x^3 & e^x \ 360x^2 & e^x \ 720x & e^x \ 720 & e^x \ 0 & e^x \\bottomrule \CodeAfter \begin{tikzpicture} [name suffix = -medium, ->, shorten > = 2pt,every node/.style={above}] \draw (2-1.south east) to node {$+$} (3-2.west) ; \draw (3-1.south east) to node {$-$} (4-2.west) ; \draw (4-1.south east) to node {$+$} (5-2.west) ; \draw (5-1.south east) to node {$-$} (6-2.west) ; \draw (6-1.south east) to node {$+$} (7-2.west) ; \draw (7-1.south east) to node {$-$} (8-2.west) ; \draw (8-1.south east) to node {$+$} (9-2.west) ; \end{tikzpicture} \end{NiceArray} ] \end{document}

You need several compilations (because of the PGF/Tikz nodes).

Output of the above code

F. Pantigny
  • 40,250